akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
 
using namespace std;
 
int main(){
 int N,i,j=0;
 cin >> N;
 string s;
 for (i=0;i<N;i++) {
  cin >> s;
  if (s=="Y") {
   j=1;
   break;
  }
 }
 if (j==1) {
  cout << "Four";
 } else {
  cout << "Three";
 }
 return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int, int> pll;
bool visited[100005];
const int max_N = 1e5 + 10;

char b;
char b2;


int main(void) {
	cin >> b;
	if (b == 'A') {
		b2 = 'T';
	}
	else if(b=='T'){
		b2 = 'A';
	}
	else if (b == 'G') {
		b2 = 'C';
	}
	else if (b == 'C') {
		b2 = 'G';
	}

	cout << b2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1402;
int n, m;
int G[N][N];
inline int nextInt(void) {
	int r; scanf("%d", &r); return r;
}
struct K {
	int h, c;
};
stack<K> st;
inline int maxRec(int d) {
	int ans = 0;
	for (int i = 1; i <= m; i++) {
		int h = G[d][i];
		int tmp = 0;
		while (!st.empty() && st.top().h >= h) {
			int newAns = st.top().h*(st.top().c + tmp);
			ans = max(ans, newAns);
			tmp += st.top().c;
			st.pop();
		}
		st.push((K) { h, 1 + tmp });
	}
	int tmp = 0;
	while (!st.empty()) {
		int newAns = st.top().h*(st.top().c + tmp);
		ans = max(ans, newAns);
		tmp += st.top().c;
		st.pop();
	}
	return ans;
}
signed main(void) {
	n = nextInt();
	m = nextInt();
	memset(G, 0, sizeof(G));
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			if (!nextInt())
				G[i][j] = G[i-1][j] + 1;
	int ans = 0;
	for (int i = 1; i <= n; i++)
		ans = max(ans, maxRec(i));
	printf("%d\n", ans);
}

Measured memory_bytes: 8880
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int  n,m;
    cin>>n>>m;
    int  r=1;
    for(int i=0;i<m;i++){
        r=r*2;
    }
    
    cout<<(1900*m+100*(n-m))*r;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int G[500][500];

void rec(int x, int y, int l){
    // cout << x << " " << y << endl;
    if(x == y) return;
    if(x+1 == y){
        G[x][y] = l;
        G[y][x] = l;
    }
    else{
        int mid = (x+y)/2;
        REP(i, x, mid+1){
            REP(j, mid+1, y+1){
                G[i][j] = l;
                G[j][i] = l;
            }
        }
        rec(x, mid, l+1);
        rec(mid+1, y, l+1);
    }
}


int main(){
    int n;
    cin >> n;
    rec(0, n-1, 1);
    rep(i, n){
        REP(j, i+1, n) cout << G[i][j] << (j == n-1 ? "\n":" ");
    }







}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#define printjudge(cond) {if(cond) printf("Yes\n"); else printf("No\n");}
#define printans(ans) {printf("%d\n",(ans));}
#define intscan(x) {scanf("%d", &x);}
#define Ntimes(N) for(int i=0; i<N; i++)
#define min(x,y) (((x)<(y)) ? (x) : (y))
#define max(x,y) (((x)>(y)) ? (x) : (y))
typedef int* intarray;
typedef char* string;

int main(){
    int N, M, C, sum, ans = 0;
    scanf("%d%d%d", &N, &M, &C);
    int* A = new int[M];
    int* B = new int[M];
    Ntimes(M) intscan(B[i]);
    for(int j=0; j<N; j++){
        sum = 0;
        Ntimes(M){
            intscan(A[i]);
            sum += A[i]*B[i];
        }
        ans += (sum+C>0);
    }
    printans(ans);
    return 0;
}

Measured memory_bytes: 256
from collections import Counter


def primeFactors(n):
    # Returns a counter of prime factors of n
    # e.g., 12 returns {2: 2, 3: 1}
    assert n >= 1
    factors = Counter()
    while n % 2 == 0:
        factors[2] += 1
        n //= 2
    x = 3
    while x * x <= n:
        while n % x == 0:
            factors[x] += 1
            n //= x
        x += 2
    if n != 1:
        factors[n] += 1
    return factors


(N,) = [int(x) for x in input().split()]
ans = 0
for p, count in primeFactors(N).items():
    for i in range(1, count + 1):
        if count - i >= 0:
            ans += 1
            count -= i
        else:
            break
print(ans)


Measured memory_bytes: 65720
s = input()+'R'
n = len(s)
flag = 0
cr=1
cl=0
l=[]
for i in range(1,n):
    if(s[i]=='L'):
        flag=1
        cl+=1
    elif s[i]=='R' and flag == 0:
        cr+=1
    elif i==n-1 or s[i]=='R' and flag!=0:
        temp = [0]*(cl+cr)
        if(cr>cl):
            diff = cr-cl
            temp[cr-1] = cl+diff-diff//2
            temp[cr] = cl + diff//2
            if (cl+diff-1)%2==1:
                temp[cr-1],temp[cr] = temp[cr],temp[cr-1]
        elif(cr<cl):
            diff = cl-cr
            temp[cr-1] = cr+diff-diff//2
            temp[cr] = cr + diff//2
            if (cr+diff-1)%2==0:
                temp[cr-1],temp[cr] = temp[cr],temp[cr-1]
        else:                #cr==cl
            temp[cr-1] = cr
            temp[cr] = cl  #cr==cl
        l+=temp
        flag = 0
        cr = 1
        cl=0
        #continue
    
print(" ".join(map(str,l)))

Measured memory_bytes: 11276
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1001001001;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll memo[100000];
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/

int main(){
    string S1;
    cin >> S1;
    ll s = S1.size();
    string T1 = S1.substr(0,(s - 1)/2);
    string U1 = S1.substr((s + 3)/2 - 1,(s - 1) / 2);
    string S2 = S1;
    string T2 = T1;
    string U2 = U1;
    reverse(all(S2));
    reverse(all(T2));
    reverse(all(U2));
    if(S1 == S2 && T1 == T2 && U1 == U2)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
ll minn(ll x, ll y){
    if(x<y)
        return x;
    return y;
}
ll maxx(ll x, ll y){
    if(x>y)
        return x;
    return y;
}
double a[309][309][309];
int z[5];
int main() {
    int n,x;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        z[x]++;
    }
    a[0][0][0] =0.0;
    for(int k=0;k<=n;k++){
        for(int j=0;j<=n;j++){
            for(int i=0;i<=n;i++){
                if(i+j+k>n)
                    continue;
                if(i>0)
                    a[i][j][k] +=   i * a[i-1][j][k]/(double)n;
                if(j>0)
                     a[i][j][k] +=   j * a[i+1][j-1][k] /(double)n ;
                if(k>0)
                    a[i][j][k] +=   k * a[i][j+1][k-1]/(double)n;
                if(i>0 || j>0 || k>0){
                    a[i][j][k] +=1.0;
                    a[i][j][k] *= ((double)n/(double)(i+j+k));
                }
            }
        }
    }
    // cout<<a[1][0][0]<<" "<<a[2][0][0];
    printf("%.10f",a[z[1]][z[2]][z[3]]);
}


Measured memory_bytes: 225536
import fractions
n=int(input())
v=list(map(int,input().split()))
def g(a,b):
  if a==0:return b
  if b==0:return a
  return fractions.gcd(a,b)
l=[0]*(n+1)
r=[0]*(n+1)
for i in range(1,n+1):
  l[i]=g(l[i-1],v[i-1])
for i in range(n)[::-1]:
  r[i]=g(r[i+1],v[i])
x=0
for i in range(n):
  c=g(l[i],r[i+1])
  x=max(c,x)
print(x)

Measured memory_bytes: 16100
#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <functional>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod2 = 1000000007;
constexpr ll mod = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// --------------------------------------------------------------------------


int main(){
  int N;
  cin >> N;
  ll ans = 0;
  for(int i=1; i<N; i++){
    if(N%i == 0){
      ans += N/i-1;
    }else{
      ans += N/i;
    }
  }
  cout << ans << "\n";
}

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


def solve(a: int, b: int, c: int, d: int, e: int, k: int):
    print('Yay!' if e - a <= k else ':(')



# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    c = int(next(tokens))  # type: int
    d = int(next(tokens))  # type: int
    e = int(next(tokens))  # type: int
    k = int(next(tokens))  # type: int
    solve(a, b, c, d, e, k)

if __name__ == '__main__':
    main()


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

int main()
{
  string S;
  cin >> S;
  S.pop_back();
  while (true)
  {
    bool ok = true;
    if (S.size() % 2 != 0)
    {
      S.pop_back();
      continue;
    }
    else
    {
      for (int i = 0; i < S.size() / 2; i++)
      {
        if (S[i] != S[i + S.size() / 2])
        {
          ok = false;
          break;
        }
      }
      if (ok)
        break;
      else
      {
        S.pop_back();
      }
    }
  }
  cout << S.size() << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>

#include <string>

const int MAX_N = 60;
long long N, X;

long long all[MAX_N][2];

long long solve(const long long n, const long long x) {
    if (x == 0) { return 0; }
    if (x == 1) { return (n == 0) ? 1 : 0; }

    if (all[n][0] + all[n][1] <= x) { return all[n][0]; }

    long long tmp_idx = 0;
    long long ret = 0;

    tmp_idx++;
    
    if (x < tmp_idx + all[n-1][0] + all[n-1][1]) {
        return solve(n-1, x - tmp_idx);
    }

    tmp_idx += all[n-1][0] + all[n-1][1];
    ret += all[n-1][0];

    if (x == tmp_idx) {
        return ret;
    }

    tmp_idx++; 
    ret++;

    return ret + solve(n-1, x - tmp_idx);
}


main(int argc, char **argv) {
    std::cin >> N >> X;

    all[0][0] = 1;
    all[0][1] = 0;

    for (int i = 1; i <= N; i++) {
        all[i][0] = all[i-1][0] * 2 + 1;
        all[i][1] = all[i-1][1] * 2 + 2;
    }

    //std::cout << "check" << std::endl;

    std::cout << solve(N, X) << std::endl;
}

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

#define mp make_pair
#define ss second
#define ff first
#define ll long long int
#define tcase ll t;cin>>t;while(t--)
#define sz(a) int((a).size())
#define pb push_back
#define present(c,x) (©.find(x) != ©.end())
#define cpresent(c,x) (find(all©,x) != ©.end())
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
#define Yes cout<<"Yes\n";
#define No cout<<"No\n";
#define f(i,a) for(int i=0;i<a;i++)
using namespace std;

void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

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

int main()
{
	fast();
	string s;
	cin>>s;
	if(s=="ARC")
		cout<<"ABC";
	else
		cout<<"ARC";
	



	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,M; cin >> N >> M;
    int A[N],B[N],C[N];
    rep(i,N){
        cin >> A[i] >> B[i] >> C[i];
    }
    vi v[8];
    rep(i,8){
        rep(j,N){
            int a=((i>>0)&1?A[j]:-A[j])+((i>>1)&1?B[j]:-B[j])+((i>>2)&1?C[j]:-C[j]);
            v[i].pb(a);
        }
    }
    rep(i,8) sort(all(v[i]),greater<int>());
    int ans=0;
    rep(i,8){
        int pos=0;
        rep(j,M) pos+=v[i][j];
        ans = max(ans,pos);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <complex>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second.first
#define T4 second.second.second

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

int main(){
	string str;
	cin>>str;
	reverse(ALL(str));
	cout<<str<<endl;
	return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline int Get(){
	static char c; c = getchar();
	while (!isdigit(c)) c = getchar();
	return c-'0';
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }

const int N = 1000005;
int n,k,a[N];
inline int C(int n,int m){
	if (n<m||n<0||m<0) return 0;
	if (n<2&&m<2) return 1;
	return C(n&1,m&1) * C(n>>1,m>>1) % 2;
}
inline void work(){
	--n;
	for (int i = 1; i <= n; ++i) a[i] = (a[i+1]>a[i])?(a[i+1]-a[i]):(a[i]-a[i+1]);
//	for (int i = 1; i <= n; ++i) cout<<a[i]; cout<<endl;
	bool f = 1;
	for (int i = 1; i <= n; ++i) if (a[i]){ f = 0; break; }
	if (f){ k = 0; return; }
	if (k == 0 || n == 1) return;
	f = 1;
	for (int i = 1; i <= n; ++i) if (a[i] && a[i] != 1){ f = 0; break; }
	if (f){
		int ans = 0;
		for (int i = 1; i <= n; ++i){
			if (C(k,i-1)) ans ^= a[i];
		}
		cout << ans << endl;
		exit(0);
	}
	
	f = 1;
	for (int i = 1; i <= n; ++i) if (a[i] && a[i] != 2){ f = 0; break; }
	if (f){
		int ans = 0;
		for (int i = 1; i <= n; ++i){
			if (C(k,i-1)) ans ^= a[i];
		}
		cout << ans << endl;
		exit(0);
	}
	
	f = 1;
	for (int i = 1; i <= n; ++i) if (a[i] && a[i] != 3){ f = 0; break; }
	if (f){
		int ans = 0;
		for (int i = 1; i <= n; ++i){
			if (C(k,i-1)) ans ^= a[i];
		}
		cout << ans << endl;
		exit(0);
	}
}
int main(){
	int i;
	read(n),k=n-1;
	for (i = 1; i <= n; ++i) a[i] = Get();
	while (k--) work();
	cout << a[1]<<endl;
	return 0;
}

Measured memory_bytes: 4096
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
#include <boost/any.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
typedef vector<pair<lint,lint>> pvec;
typedef vector<vector<pair<lint,lint>>> pmat;
typedef vector<vector<vector<pair<lint,lint>>>> pmat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<"\n";}while(0)
#define output2(v) for(auto i:v)output(i);
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define sum(v) accumulate(all(v),0LL)
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
int main(){
    string s,t;
    cin>>s>>t;
    map<char,vec> l;
    rep(i,s.size()){
        if(l.count(s[i]))l.at(s[i]).push_back(i);
        else l.emplace(s[i],vec{i});
    }
    lint h=0,w=0;
    rep(i,t.size()){
        if(l.count(t[i])){
            auto it=lower_bound(all(l.at(t[i])),w);
            if(it==l.at(t[i]).end()){
                w=l.at(t[i])[0]+1;
                h++;
            }else{
                w=(*it)+1;
                if(w==(lint)s.size()){
                    w=0;
                    h++;
                }
            }
        }else{
            cout<<-1;
            return 0;
        }
    }
    cout<<h*s.size()+w;
}

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

#define ll long long
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define viit vector<int>::iterator
#define MOD 1000000007
#define endl "\n"
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repe(i, a, b) for (int i = (a); i <= (b); i++)
#define repd(i, a, b) for (int i = (a); i >= (b); i--)
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, W;
    cin >> n >> W;
    vi w(n), v(n);
    rep(i, 0, n) cin >> w[i] >> v[i];
    ll ans[n + 1][W + 1];
    repe(i, 0, n) ans[i][0] = 0;
    repe(i, 0, W) ans[0][i] = 0;
    repe(i, 1, n) {
        repe(j, 1, W) {
            if (w[i - 1] <= j) {
                ans[i][j] = max(v[i - 1] + ans[i - 1][j - w[i - 1]], ans[i - 1][j]);
            } else {
                ans[i][j] = ans[i - 1][j];
            }
        }
    }
    cout << ans[n][W];
    return 0;
}


Measured memory_bytes: 79232
import java.util.Scanner;

public class Main {

	public static final int MOD = 1000000007;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
		long a = sc.nextInt();
		long b = sc.nextInt();
		sc.close();

		long answer = pow(2, n, MOD);
		// nC0
		answer = answer - 1;

		// nCa
		answer = answer - nCk(n, a, MOD);

		// nCb
		answer = answer - nCk(n, b, MOD);

		while (answer < 0) {
			answer = answer + MOD;
		}

		while (answer >= MOD) {
			answer = answer - MOD;
		}

		print(answer);
	}

	public static void print(Object obj) {
		System.out.println(obj);
	}

	// return nCk mod M (M must be prime number) O(min(k,n-k)*logM)
	public static long nCk(long n, long k, long M) {
		long ret = 1;
		long min = Math.min(k, n - k);
		for (long i = 1; i <= min; i++) {
			ret = (ret * pow(i, M - 2, M)) % M;
		}
		for (long i = n - min + 1; i <= n; i++) {
			ret = (ret * i) % M;
		}
		return ret;
	}

	// return a^b mod M O(logB)
	public static long pow(long a, long b, long M) {
		long ret = 1;
		long tmp = a;
		while (b > 0) {
			if ((b & 1) == 1)
				ret = (ret * tmp) % M;
			tmp = (tmp * tmp) % M;
			b = b >> 1;
		}
		return ret;
	}

}


Measured memory_bytes: 23892
n = gets.to_i
x = gets.split.map(&:to_i)

# y = x.map.with_index{|t,i| [t,i] }.sort_by{|f,_| f }
y = x.sort

l = y[n/2]
s = y[n/2-1]

x.each do |t|
  if t <= s
    puts l
  else
    puts s
  end
end

Measured memory_bytes: 23396
N, M = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(M)]
ab.sort()
result = 0
min_b = N + 1
p = 0
for i in range(1, N + 1):
    if i == min_b:
        result += 1
        min_b = N + 1
    while p < M and i == ab[p][0]:
        min_b = min(min_b, ab[p][1])
        p += 1
print(result)

Measured memory_bytes: 16992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

double cal(int T, int h){
    return T - (h*0.006);
}

int main() {
    int N;
    cin >> N;
    int T, A;
    cin >> T >> A;
    vector<int>Hs(N);
    double nin = 1000;
    int ans = 0;
    for(int i=0; i<N; i++){
        cin >> Hs.at(i);
        if(chmin(nin, abs(A-cal(T,Hs.at(i))))){
            ans = i+1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def check(remarks, animals)
  animals = animals.dup
  remarks.each{|c|
    animals << (animals[-1] == c ? animals[-2] : !animals[-2])
  }
  return animals[0, 2] == animals[-2, 2] ? animals[1...-1].map{|c| c ? "S" : "W"} * "" : nil
end

N = gets.to_i
remarks = gets.chomp.each_char.map{|c| c == "o"}
puts [[true, true], [true, false], [false, true], [false, false]].map{|animals|
  check(remarks, animals)
}.find{|s| s} || -1


Measured memory_bytes: 12212
#include<stdio.h>

int main(void) {
	int a, b, d, r;
	double f;
	scanf("%d%d", &a, &b);
	d = a / b;
	r = a%b;
	f = (double)a/b;
	printf("%d %d %f\n", d, r, f);

	return 0;

}


Measured memory_bytes: 2732
#include  <stdio.h>

int main(void)
{
    long long int a,b=1,c,d=1000000000000000000;
    scanf("%lld",&a);
    
    for(int i=0;i<a;i++)
    {
        scanf("%lld",&c);
        if(c==0)
        {
            printf("0");
            return 0;
        }
        
        b = b * c;
        if(c>d)
        {
            b=-1;
        }
            
        d = d / c;
    }
    
    printf("%lld",b);
    return 0;
}

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

using namespace std;

const int maxn = 100001;

int dp[maxn][3], a[maxn], b[maxn], c[maxn], n;

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

    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i] >> b[i] >> c[i];
    for(int i = 1; i <= n; i++){
        dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b[i];
        dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + c[i];
    }

    cout << max(dp[n][0], max(dp[n][1], dp[n][2]));

    return 0;
}


Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(10**8)

N = int(input())
abc = [list(map(int, input().split())) for i in range(N)]
abc.append([0, 0, 0])

dp = [[-1] * 4 for i in range(N + 1)]


def happy(n, p):
    if n < 0:
        return 0
    if dp[n][p] >= 0:
        return dp[n][p]

    a = 0 if p == 0 else happy(n - 1, 0) + abc[n][0]
    b = 0 if p == 1 else happy(n - 1, 1) + abc[n][1]
    c = 0 if p == 2 else happy(n - 1, 2) + abc[n][2]
    dp[n][p] = max([a, b, c])

    return dp[n][p]


print(happy(N - 1, 3))


Measured memory_bytes: 123824
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

X,Y = IL()
P(int_log(Y//X,2)+1)

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

int main(){
	long long int sum=0;
	int N;
	cin>>N;
	int a[N],i,j;
	for(i=0;i<N;i++){
		cin>>a[i];
	}
	for(i=0;i<N;i++){
		for(j=i+1;j<N;j++){
			sum+=a[i]*a[j];
		}
	}
	cout<<sum;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int NIL = -1;
const int INF = (1<<21);
const long long MOD = 1e9+7;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main() {
  int h, w, sx, sy, gx, gy; cin >> h >> w >> sx >> sy >> gx >> gy;
  sx--;sy--;gx--;gy--;
  vector<string> field(h);
  for (int i = 0; i < h; ++i) cin >> field[i];
  vector<vector<int>> dist(h, vector<int>(w, INF));
  deque<pair<int, int>> q;
  q.emplace_back(make_pair(sx, sy));
  dist[sx][sy] = 0;
  while(!q.empty()) {
    pair<int, int> p = q.front();
    q.pop_front();
    int x = p.first;
    int y = p.second;
    for (int i = 0; i < 4; ++i) {
      int nx = x+di[i];
      int ny = y+dj[i];
      if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
      if (field[nx][ny] == '#') continue;
      if (dist[nx][ny] <= dist[x][y]) continue;
      dist[nx][ny] = dist[x][y];
      q.emplace_front(make_pair(nx, ny));
    }
    for (int i = -2; i <= 2; ++i) {
      for (int j = -2; j <= 2; ++j) {
        int nx = x + i;
        int ny = y + j;
        if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
        if (field[nx][ny] == '#') continue;
        if (dist[nx][ny] <= dist[x][y]+1) continue;
        dist[nx][ny] = dist[x][y]+1;
        q.emplace_back(make_pair(nx, ny));
      }
    }

  }
  if (dist[gx][gy] == INF) cout << -1 << endl;
  else cout << dist[gx][gy] << endl;
}


Measured memory_bytes: 9536
//:Ditttoo
#include<bits/stdc++.h>
#define int long long int 
using namespace std;
int32_t main()
{
	int n;
	cin>>n;

	int a[n], b[n] , c[n] ;

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

	int s1 = a[0] , s2 =b[0] ,s3 = c[0];
	int t1 = s1,t2 = s2,t3 = s3;

	for(int i=1;i<n;i++){

		s1 = max(t2,t3) + a[i];
		s2 = max(t1,t3) + b[i];
		s3 = max(t1,t2) + c[i];

		t1 = s1 , t2=s2 , t3=s3 ;
	}

	cout<<max({s1,s2,s3});
	return 0;
}        

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

int stoi(string s){
  int num=0;
  for(int i=s.size()-1,digit=1;i>=0;i--,digit*=10){
    if(s[i]=='-') num*=-1; 
    else num+=(s[i]-'0')*digit;
  }
  return num;
}

int main(){
  int n;
  while(cin>>n,n){
    string sig[n+2];
    sig[0]="1000000005";
    for(int i=1;i<=n;i++)
      cin>>sig[i];
    if(n%2==0) sig[n+1]="-1000000005";
    else sig[n+1]="1000000005";
    int Min=-1000000005,Max=1000000005;
    bool checker=true;
    for(int i=1;i<=n;i++){
      if(sig[i]=="x"){
	if(sig[i+1]=="x"){
	  cout<<"none"<<endl; checker=false; break;
	}
	int left=stoi(sig[i-1]),right=stoi(sig[i+1]);
	if(i%2==0){
	  if(max(left,right)>Min) Min=max(left,right);
	} else{
	  if(min(left,right)<Max) Max=min(left,right);
	}   
      } else{
	if(sig[i-1]=="x") continue;
	int num=stoi(sig[i]);
	if(i%2==1){
	  if(num>stoi(sig[i-1])){
	    cout<<"none"<<endl; checker=false; break;
	  }
	} else{
	  if(num<stoi(sig[i-1])){
	    cout<<"none"<<endl; checker=false; break;
	  }
	}
      }
    }
    if(checker){
      if(Max-Min==2) cout<<Max-1<<endl;
      else if(Max-Min>2) cout<<"ambiguous"<<endl;
      else cout<<"none"<<endl;
    }
  }
}


Measured memory_bytes: 1324
#include <bits/stdc++.h>
using namespace std;
#define fast            ios_base::sync_with_stdio(false)
#define mems(x, y)      memset(x, y, sizeof x)
#define pii             pair < int, int >
#define prec(x)         << fixed << setprecision(x)
#define ll              long long
#define nl              << endl
#define spc             << " "
#define pb              push_back
#define PI              3.14159265358979323846
#define E               2.71828182845904523536
#define toint(x)        atoi(x.c_str())
//int fx[] = {1, -1, 0, 0};
//int fy[] = {0, 0, 1, -1};
const int mod=1e9+7;
const int mxn=1e5+2;
bool fl[10000002];
int n;
int arr[mxn];
ll dp[mxn];
ll frog_jump(int i, ll cost)
{
    if(i >= n)  return -1;
    if(dp[i] != -1)   return cost + dp[i];
    ll c1, c2;
    c1 = frog_jump(i + 1, abs(arr[i] - arr[i + 1]));
//    cout << i spc << "c1 " <<  c1 nl;
    c2 = frog_jump(i + 2, abs(arr[i] - arr[i + 2]));
//    cout << i spc << "c2 " << c2 nl;
    if(c1 == -1 && c2 == -1)    dp[i] = 0;
    else if(c1 == -1)    dp[i] = c2;
    else if(c2 == -1)    dp[i] = c1;
    else dp[i] = min(c1, c2);
    return cost + dp[i];
}
int main()
{
    mems(dp, -1);
    cin >> n;
    for(int i = 0; i < n; i++)  cin >> arr[i];
    cout << frog_jump(0, 0) nl;
    return 0;
}




Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> C(H);
    rep(i, H) cin >> C[i];

    int ans = 0;
    rep(bith, 1 << H) {
        rep(bitw, 1 << W) {
            vector<string> CT(H);
            rep(i, H) CT[i] = C[i];
            rep(i, H) {
                if ((bith >> i) & 1) {
                    rep(j, W) {
                        CT[i][j] = '.';
                    }
                }
            }
            rep(i, W) {
                if ((bitw >> i) & 1) {
                    rep(j, H) {
                        CT[j][i] = '.';
                    }
                }
            }
            int cnt = 0;
            rep(i, H) {
                rep(j, W) {
                    if (CT[i][j] == '#') cnt++;
                }
            }
            if (cnt == K) ans++;
        }
    }

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

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };

bool even_check(string S) {
	int num = S.size() / 2;
	string str_f = S.substr(0, num);
	string str_b = S.substr(num, num);
	if (str_f == str_b) return true;
	else {
		return false;
	}
}

int main() {

	string str;
	cin >> str;
	
	bool check = false;

	while (check != true) {
		str.pop_back();
		if (str.size() % 2 == 0) {
			check = even_check(str);
		}
	}

	cout << str.size() << endl;

	return 0;
}



Measured memory_bytes: 256
use std::io::{stdin, stdout, Write};

fn main() {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    let n: i32 = line.trim().parse().unwrap();
    line.clear();
    let mut ac = 0;
    let mut wa = 0;
    let mut tle = 0;
    let mut re = 0;
    for _ in 0..n {
        stdin().read_line(&mut line).unwrap();
        match line.trim() {
            "AC" => ac += 1,
            "WA" => wa += 1,
            "TLE" => tle += 1,
            "RE" => re += 1,
            _ => {}
        }
        line.clear();
    }
    println!("AC x {}", ac);
    println!("WA x {}", wa);
    println!("TLE x {}", tle);
    println!("RE x {}", re);
}

Measured memory_bytes: 2132
from collections import defaultdict, deque
import sys
import heapq
import bisect
import math
import itertools
import string
import queue
import copy
import time
# import numpy as np
from fractions import gcd

sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7


def inp(): return int(sys.stdin.readline())


def inp_list(): return list(map(int, sys.stdin.readline().split()))


def lcm(x, y): return (x * y) // gcd(x, y)


N, M = inp_list()
s = [0] * M
c = [0] * M
for i in range(M): s[i], c[i] = inp_list()

if M == 0:
    if N == 1:
        print(0)
        exit()
    else:
        print(10 ** (N - 1))
        exit()


# N 桁の整数 10 ** (N - 1) ~ 10 ** N - 1 を全探索
for i in range(10 ** (N - 1) - 1, 10 ** N):
    if N != 1 and i == 10 ** (N - 1) - 1: continue
    i_str = str(i)
    for m in range(M):
        if i_str[s[m] - 1] != str(c[m]):
            break
        if m == M - 1:
            print(i)
            exit()
print(-1)


Measured memory_bytes: 5192
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,j;
    scanf("%d %d",&n,&m);
    long long a[n+10],b[n+10],c[m+10],d[m+10];
    long long d1,d2,dist;
    for(i=1;i<=n;i++)
    {
        scanf("%lld %lld",&a[i],&b[i]);
    }
    for(i=1;i<=m;i++)
    {
        scanf("%lld %lld",&c[i],&d[i]);
    }
    int indx;
    long long dmin;
    for(i=1;i<=n;i++)
    {

        for(j=1;j<=m;j++)
        {
            d1=a[i]-c[j];
            if(d1<0)
            {
                d1=d1*(-1);
            }
            d2=b[i]-d[j];
            if(d2<0)
            {
                d2=d2*(-1);
            }
            dist=d1+d2;
            if(j==1)
            {
                dmin=dist;
                indx=1;
            }
            else
            {
                if(dist<dmin)
                {
                    dmin=dist;
                    indx=j;
                }
                else if(dist==dmin)
                {
                    if(j<indx)
                    {
                        indx=j;
                    }
                }
            }
        }
        printf("%d\n",indx);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <deque>

using namespace std;

int main()
{
    string s1,s2,s3;
    deque<char>deq1,deq2,deq3;
    char turn;
    cin>>s1>>s2>>s3;
    for(int i=0;i<s1.size();i++)deq1.push_back(s1[i]);
    for(int i=0;i<s2.size();i++)deq2.push_back(s2[i]);
    for(int i=0;i<s3.size();i++)deq3.push_back(s3[i]);
    turn =deq1.front();
    deq1.pop_front();
    while(true){
        if(turn=='a'){
            if(!deq1.empty()){
                turn=deq1.front();
                deq1.pop_front();
            }
            else {
                cout<<"A"<<endl;
                return 0;
            }
        }
        else if(turn =='b'){
            if(!deq2.empty()){
                turn=deq2.front();
                deq2.pop_front();
            }
             else {
                cout<<"B"<<endl;
                return 0;
            }
        }
        else{
            if(!deq3.empty()){
                turn=deq3.front();
                deq3.pop_front();
            }
             else {
                cout<<"C"<<endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
using ll = long long;
using P = pair<ll, ll>;

const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void fail() {
    cout << -1 << endl;
    exit(0);
}

int main(){
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    for(ll i=0; i < n; i++){
        cin >> a[i];
    }
    ll cnt = 0;
    sort(a.begin(), a.end());
    for(ll i=0; i < n; i++){
        if(i == n - 1 && a[i] == x){
            x -= a[i];
            cnt++;
            continue;
        }else if(i != n - 1 && a[i] <= x){
            x -= a[i];
            cnt++;
            continue;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
cnt_1 = 0
cnt_2 = 0
TF = False
for i in range(n):
    if (i + 1) == p[i]:
        if TF:
            TF = False
            cnt_2 += 1
            cnt_1 -= 1
        else:
            TF = True
            cnt_1 += 1
    else:
        TF = False
print(cnt_1 + cnt_2)

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

graph = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

ans = 0
for i in range(n):
    h = hs[i]
    maxi = 0
    for x in graph[i]:
        maxi = max(hs[x], maxi)

    if h > maxi:
        ans += 1

print(ans)


Measured memory_bytes: 29368
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    long long A, B, N;
    cin >> A >> B >> N;
    long long ans1, ans2;
    long double xb1 = (N - (N%B) - 1)/(double)B;
    if (xb1 < 0) xb1 = 0;
    long double xb2 = N/(double)B;
    ans1 = floor(A*(xb1 - floor(xb1)));
    ans2 = floor(A*(xb2 - floor(xb2)));
    cout << max(ans1, ans2) << endl;
}


Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;

signed main() {
	int n, m; cin >> n >> m; cout << n*m << endl;
}


Measured memory_bytes: 3120
import copy
import heapq
import math
import fractions

def j(n):
    if n:print("Yes")
    else:print("No")
    exit(0)
rem = 10 ** 9 + 7

"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def ipmultiplerow(n):
    a = []
    for i in range(n):
        a.append(ip())
    return a
def printrow(a):
    for i in a:
        print(i)
n = ip()
a=iprow()

s=0
for i in range(n-2):
	s+=min(a[i],a[i+1])
s+=a[0]+a[-1]
print(s)

Measured memory_bytes: 5388
/*
 * A.cpp
 *
 *  Created on: 2018/07/04
 *      Author: saca
 */

#include <iostream>

#include <math.h>

using namespace std;

int main() {
	int n, x;

	cin >> n;

	if(n%2 == 0)
	{
		cout << n << endl;
	}else
	{
		cout << n*2 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
n, x = map(int, input().split())
l = list(map(int, input().split()))
# ボールが跳ねる座標の数列を作成する。
# 初期値は、0である。
d = [0]
for i in range(n):
    d.append(d[i]+l[i])
a = 0
for dd in d:
  	# ボールが何回、跳ねるかどうか？
    # X座標以下である座標は跳ねるので、カウントする。
    if dd <= x:
        a += 1
print(a)


Measured memory_bytes: 9144
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m;
int main()
{
    scanf("%lld%lld",&n,&m);
    if(n==1||m==1)
    {
        printf("1");
        return 0;
    }
    printf("%lld",(n*m+1)/2);
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int main(){
	int a,b,c;
	cin>>a>>b;
	cout<<a-b+1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxV = 90010;
const int maxN = 1e5+10;
const int inf = 0x3f3f3f3f;
const int MOD = 998244353;
const ll INF = 1000000000000000010LL;


int n;
int a[maxN],b[maxN];
int a1[maxN],b1[maxN];
pii c[maxN];
int main() {
	string x;
	scanf("%d",&n);
	cin>>x;
	string s = x.substr(0,n/2);
	string t = x.substr(n/2);
	if(n%2 != 0)
	{
		puts("No");
		return 0;
	}
	if(s == t)
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  bool can = true;

  ll a, b;
  string s;
  cin >> a >> b >> s;

  for (int i = 0; i < a; i++)
    if (!('0' <= s[i] && s[i] <= '9')) {
      cout << "No"
           << "\n";
      return 0;
    }
  if (s[a] != '-') {
    cout << "No"
         << "\n";
    return 0;
  }
  for (int i = a + 1; i <= a + b; i++)
    if (!('0' <= s[i] && s[i] <= '9')) {
      cout << "No"
           << "\n";

      return 0;
    }
  cout << "Yes"
       << "\n";
}

Measured memory_bytes: 256