akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound
#define treap_pair pair<treap*, treap*>
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 2e5 + 2;
const int M = 1e5 + 2;
const int mod = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e16;

void data() {
	#ifdef PC
		freopen("main.in", "r", stdin);
		freopen("main.out", "w", stdout);
	#endif
}

int dp[M], pr[M], n, k, a[N];

int add(int a, int b) {
	return (a + b + ((a + b < 0) ? mod : 0)) % mod;
}

int main() {
	data();
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	dp[0] = 1;
	for (int i = 0; i <= k; ++i)
		pr[i] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= k; ++j)
			dp[j] = add(pr[j], - (j > a[i] ? pr[j - a[i] - 1] : 0LL));	
		for (int j = 0; j <= k; ++j) {
			pr[j] = 0;
			if (j)
				pr[j] = add(pr[j - 1], dp[j]);
			else
				pr[j] = dp[0];
		}
	}
	printf("%d", dp[k]);
}

/*
	Timus: 288481RF
	CodeForces: fractal
*/


Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
  int n,d,i,s;
  int n_1,n_2,n_s;

  scanf("%d %d", &n, &d);

  n_1 = n - d;
  n_2 = n + d;
  n_s = n_2 - n_1 + 1;
 
  s = 0;
  
  for (i = 0; n > 0; i++){
    n -= n_s;
    s++;
  }

  printf("%d\n", s);

  return (0);
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)


int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	int A;
	int odd = 0;	rep(i, N) {
		cin >> A;
		if (A % 2 == 1)odd++;
	}
	if (odd % 2 == 1)
	{
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "



int main(){
    double h, w, x, y;cin>>h>>w>>x>>y;
    printf("%.8f %d\n", h*w/2, (x==h/2&&y==w/2)?1:0);
}


Measured memory_bytes: 256
#include <cstddef>
#include <iostream>
#include <vector>

template <typename T>
class WeightedDisjointSet {
 private:
  class Node {
    friend WeightedDisjointSet;

    std::size_t parent;
    std::size_t size;
    T weight = 0;

    Node(const std::size_t parent, const std::size_t size) : parent(parent), size(size) {}
  };

  std::vector<Node> nodes;

 public:
  WeightedDisjointSet(const std::size_t n) : nodes(n, Node(n, 1)) {}

  std::size_t size() const { return nodes.size(); }

  std::size_t size(const std::size_t x) { return nodes[root(x)].size; }

  std::size_t root(const std::size_t x) {
    if (nodes[x].parent == size()) return x;
    std::size_t rx = root(nodes[x].parent);
    nodes[x].weight += nodes[nodes[x].parent].weight;
    return nodes[x].parent = rx;
  }

  bool is_same(const std::size_t x, const std::size_t y) { return root(x) == root(y); }

  T weight(const std::size_t x) {
    root(x);
    return nodes[x].weight;
  }

  T diff(const std::size_t x, const std::size_t y) { return weight(y) - weight(x); }

  bool unite(const std::size_t x, const std::size_t y, T w) {
    std::size_t rx = root(x), ry = root(y);
    w += weight(x) - weight(y);
    if (rx == ry) return false;
    if (nodes[rx].size < nodes[ry].size) {
      std::swap(rx, ry);
      w *= -1;
    }
    nodes[ry].weight = w;
    nodes[rx].size += nodes[ry].size;
    nodes[ry].parent = rx;
    return true;
  }
};

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int N, M;
  std::cin >> N >> M;
  WeightedDisjointSet<int64_t> ds(N);
  for (int i = 0; i < M; i++) {
    int l, r, d;
    std::cin >> l >> r >> d;
    l--, r--;
    if (!ds.unite(l, r, d) && ds.diff(l, r) != d) {
      std::cout << "No" << '\n';
      return 0;
    }
  }
  std::cout << "Yes" << '\n';
  return 0;
}


Measured memory_bytes: 5544
(setq a(read))
(setq b(read))
(setq c(read))
(setq d(read))
(setq e(read))
(setq f(read))
(setq g(read))
(setq h(read))
(setq i(read))
(setq x(+ a (* c -151) (* b 150)))
(setq y(+ d (* f -151) (* e 150)))
(setq z(+ g (* i -151) (* h 150)))
(princ(if(= x y z)"Yes""No"))

Measured memory_bytes: 24380
#include<iostream>
#include<cmath>
#include<vector>
#include<bitset>
#include<bitset>
#include<string>
#include<utility>
#include<queue>

using namespace std;

int main(){
    string s,t;
    cin >> s >> t;
    int ans =0;
    for(int i=0;i<s.length();i++){
        if(s.at(i)!=t.at(i)){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3464
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e3 + 10;
LL gcd(LL a, LL b)
{
	return b == 0 ? a : gcd(b, a % b);
}
LL solve(LL a, LL b, LL d)
{
	return b / d - (a - 1) / d;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	LL a, b, c, d;
	cin >> a >> b >> c >> d;
	LL lcm = d / gcd(c, d) * c;
	cout << solve(a, b, 1) - solve(a, b, c) - solve(a, b, d) + solve(a, b, lcm) << endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



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;
  


  return 0;
}


Measured memory_bytes: 256
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_099_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE SECTION.
    01 N PIC 9(4).
PROCEDURE                        DIVISION.
MAIN.
    ACCEPT N FROM CONSOLE.
    IF 999 < N THEN
        DISPLAY "ABD" UPON CONSOLE
    ELSE
        DISPLAY "ABC" UPON CONSOLE
    END-IF.
    STOP RUN.


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    ll n, m; cin >> n >> m;
    V<ll> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    V<P<ll, ll> > cb(m);
    for(int i = 0; i < m; i++){
        ll b, c; cin >> b >> c;
        cb[i] = make_pair(c, b);
    }

    sort(ALL(a));
    sort(ALL(cb), greater<P<ll, ll>>());

    V<ll> x = a;
    ll cnt = 0;
    for(int i = 0; i < m; i++){
        auto ite = lower_bound(ALL(a), cb[i].first);
        ll j = ite - a.begin();
        ll c = 0;
        for(int k = cnt; k < j; k++){
            if(x[k] < cb[i].first){
                x[k] = cb[i].first;
                cnt++;
                c++;
            }
            if(c == cb[i].second) break;
        }
    }

    cout << accumulate(ALL(x), 0LL) << endl;


    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
#define int long long
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }

using ll = long long;
const ll mod = LLONG_MAX;

ll N,a,b,c;
signed main(){
  cin>>N;

  for(int a=1;a<=3500;a++){
    for(int b=1;b<=3500;b++){
      if(4*a*b-N*b-N*a==0)continue;
      if((N*a*b)%(4*a*b-N*b-N*a)==0){
        c=N*a*b/(4*a*b-N*b-N*a);
        if(c<0)continue;
        cout<<a<<" "<<b<<" "<<c<<endl;

        //cout<<fixed<<setprecision(10)<<(double)4/N<<endl;

        //cout<<fixed<<setprecision(10)<<(double)1/a+(double)1/b+(double)1/c<<endl;
        return 0;
      }
    }
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define multitest 0
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pqgreater(x) x, vector<x>, greater<x>
const ll mod=998244353;
int solve();
int main(){ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t=1;
	if(multitest) cin>>t;
	while(t--) solve();
	return 0;
}
vector<int>adj[100005];
int ans[100005];
int solve(){
	int n, m; cin>>n>>m;
	for(int i=0; i<m; i++){
		int u, v; cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for(int i=1; i<=n; i++) ans[i]=-1;
	queue<pair<int, int> >bfs;
	bfs.push({1, 1});
	while(!bfs.empty()){
		int nw=bfs.front().first, bf=bfs.front().second;
		bfs.pop();
		if(ans[nw]!=-1) continue;
		ans[nw]=bf;
		for(int nx:adj[nw]) if(nx!=bf)
			bfs.push({nx, nw});
	}
	for(int i=2; i<=n; i++){
		if(ans[i]==-1){
			cout<<"No\n"; return 0;
		}
	}
	cout<<"Yes\n";
	for(int i=2; i<=n; i++) cout<<ans[i]<<endl;
	return 0;
}

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

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

	string s1, s2;	
	cin >> s1 >> s2;
	int a, b;
	cin >> a >> b;
	string s3;
	cin >> s3;
	if (s3 == s1)
	{
		a--;
	}
	else if (s3 == s2)
	{
		b--;
	}
	cout << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 3616
use std::io;
use std::cmp::max;
use std::collections::VecDeque;

fn main() {
    let mut input = Input::new();
    let a = input.next().parse::<i64>().unwrap();
    let b = input.next().parse::<i64>().unwrap();
    println!("{}", test(a, b));
}

fn solve(a_: i64, b_: i64) -> i64 {
    let mut a = a_;
    let mut b = b_;
    if a == b {
        return 1;
    }
    let c = a ^ b;
    let r = (0..62).filter(|x| ((1i64 << x) & c) > 0i64).max().unwrap();
    let t = 1i64 << r;
    a &= t - 1;
    b &= t - 1;
    let s1 = a;
    let l1 = t;
    let s3 = t + a;
    let l3 = t << 1;
    let mut x: i64 = l1 - s1 + l3 - s3;
    if b > 0 {
        let s2 = t;
        let l2 = t + (2i64 << (0..62).filter(|x| ((1i64 << x) & b) > 0i64).max().unwrap());
        x += l2 - s2 - max(l2 - s3, 0);
    }
    return x;
}

fn test(a_: i64, b_: i64) -> i64 {
    let mut a = a_;
    let mut b = b_;
    if a == b {
        return 1;
    }
    let c = a ^ b;
    let r = (0..62).filter(|x| ((1i64 << x) & c) > 0i64).max().unwrap();
    let t = 1i64 << r;
    a &= t - 1;
    b &= t - 1;
    let u = (0..62).filter(|x| (1i64 << x) > b).min().unwrap();
    let mi = a;
    let ma = 1i64 << u;
    return t + t - mi + if ma > mi { 0 } else { ma - mi };
}

struct Input {
    queue: VecDeque<String>,
}

impl Input {
    fn new() -> Input {
        Input { queue: VecDeque::new() }
    }

    fn next(&mut self) -> String {
        if self.queue.is_empty() {
            let mut line = String::new();
            let _ = io::stdin().read_line(&mut line);
            for x in line.split_whitespace() {
                self.queue.push_back(String::from(x));
            }
        }
        return self.queue.pop_front().unwrap();
    }
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 1e6+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

ll cal[MAXN];
ll su[MAXN];
ll sq[MAXN];
ll val[MAXN];

ll mypow(ll n,ll m)
{
    ll res = 1;
    while(m){
        if(m&1)res = (res*n)%PMOD;
        n = (n*n)%PMOD;
        m>>=1;
    }
    return res;
}

int main()
{
    int n,m,k,a,b,x,y,q;
    ll sum = 0;
    ll sqsum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;
    ll inver2;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    for(int i=0;i<n;i++){
        cin>>x;
        cal[x]++;
    }

    inver2 = mypow(2,PMOD-2);

    for(ll i=1;i<=1000000;i++){
        su[i] = i*cal[i];
        su[i]%=PMOD;
        sq[i] = i*i*cal[i];
        sq[i]%=PMOD;
    }

    for(int i=1;i<=1000000;i++){
        sum = 0;
        sqsum = 0;
        for(int j=i;j<=1000000;j+=i){
            sum+=su[j];
            sqsum+=sq[j];
        }
        sum%=PMOD;
        sqsum%=PMOD;
        val[i] = sum*sum+PMOD-sqsum;
        val[i]%=PMOD;
        val[i] = (val[i]*inver2)%PMOD;
    }

    for(int i=1000000;i>=1;i--){
        for(int j=2*i;j<=1000000;j+=i)
            val[i]+=(PMOD-val[j]);
        val[i]%=PMOD;
    }

    ll inver;
    ll res = 0;

    for(int i=1;i<=1000000;i++){
        inver = mypow(i,PMOD-2);
        res+=((val[i]*inver)%PMOD);
    }

    res%=PMOD;

    cout<<res<<"\n";

    return 0;
}


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

const int mod = 1000000007;
struct mint {
    ll x;
    mint(ll x=0):x( (x%mod + mod) % mod ) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ( (x += a.x) >= mod ) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ( ( x += mod - a.x) >= mod ) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        ( x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) { return mint(*this) /= a; }
};

istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n+1), ifact(n+1) {
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator() (int n, int k) {
        if ( k < 0 || k > n ) return 0;
        return fact[n] * ifact[k] * ifact[n-k];
    }
};

int main() {
    int k, n;
    string s;
    cin >> k >> s;
    n = s.size();
    mint ans = 0;
    combination c(k+n);
    for (int i = 0; i <= k; ++i) {
        mint cur = c(i + n - 1, n-1);
        cur *= mint(25).pow(i);
        cur *= mint(26).pow(k-i);
        ans += cur;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35624
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  string s;
  cin >> s;
  for(int i = 0; i < s.size()-1; i++){
    if(s[i] == s[i+1]){
      cout << i+1 << " " << i+2 << endl;
      return 0;
    }
  }
  for(int i = 0; i < s.size()-1; i++){
    if(s[i] == s[i+2]){
      cout << i+1 << " " << i+3 << endl;
      return 0;
    }
  }
  cout << "-1 -1" << endl;
}

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

#define  rep(i,n)   for(int i=0; i<(int)n; i++)
#define  per(i,n)   for(int i=((int)n)-1; i>=0; i--)
#define  mem(x,y)   memset(x,y,sizeof(x))
#define  read(f)    freopen(f, "r", stdin)
#define  write(f)   freopen(f, "w", stdout)
#define  pii        pair<int,int>
#define  mp         make_pair
#define  ff         first
#define  ll         long long
#define  ss         second
#define  pb         push_back
#define  MAX        100000


int main()
{
    int s, a, b, f, ans ;
    int ar[101] = {0}, arr[101] = {0};
    while( cin >> s )
    {

        rep( j, s )
        {
            cin >> ar[j] >> arr[j];
        }
        for( int i = 0; i < s; )
        {
            if( ar[i] == arr[i] )
            {
                f = 0, ans = 0;
                while( i < s && ar[i] == arr[i] )
                {
                    f++;
                    i++;
                }
                if( f >= 3 )
                {
                    ans = 1;
                    break;
                }
            }
            else
                i++;
        }

        if( ans ) puts( "Yes" );
        else puts( "No" );

    }
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  int A=1;
  cin>>N>>K;
  for(int i=0;i<N;i++){
    if(A>K)
      A+=K;
    else
      A*=2;
  }
  cout<<A<<endl;
}

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

int main(){
    int a, b, c, x, i;
    i=0;
    cin >> a >> b >> c;
    for (int x = a; x <= b; x++){
        if (c%x == 0){
            i++;
        }
    }
    cout << i << endl;
    
    return 0;
}


Measured memory_bytes: 3116
import java.util.*;
class Main{public static void main(String[]args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int m=sc.nextInt();
int x=sc.nextInt();
int[]a=new int[n];
int []b=new int[m];
int nmin=Integer.MAX_VALUE;
int mmin=Integer.MAX_VALUE;
for(int i=0;i<n;i++){
    a[i]=sc.nextInt();
    nmin=(nmin<a[i])?nmin:a[i];
}

for(int i=0;i<m;i++){
    b[i]=sc.nextInt();
    mmin=(mmin<b[i])?mmin:b[i];
}
int sum=nmin+mmin;
for(int i=0;i<x;i++){
    int po=a[sc.nextInt()-1]+b[sc.nextInt()-1]-sc.nextInt();
    sum=(sum<po)?sum:po;
}System.out.println(sum);
}}

Measured memory_bytes: 150836
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int x;
  scanf("%d",&x);
  printf("%s\n",x==3 || x==5 || x==7?"YES":"NO");
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#define llinf 4154118101919364364

int main(void){
  long long i,j,narr[524288][32],sl,tl,mem[32],r=0,k;
  char s[524288],t[524288];
  scanf("%s%s",&s[1],&t[1]);
  sl=strlen(&s[1]);
  for(i=1;i<=sl;i++){
    s[sl+i]=s[i];
  }
  s[2*sl+1]=0;
  tl=strlen(&t[1]);
  for(i=0;i<32;i++){mem[i]=llinf;}
  for(i=2*sl;i>=0;i--){
    for(j=0;j<32;j++){
      narr[i][j]=mem[j];
    }
    mem[s[i]-'a']=i;
  }
  for(i=1;i<=tl;i++){
    if(narr[r%sl][t[i]-'a']==llinf){
      printf("-1\n");
      return 0;
    }
    k=narr[r%sl][t[i]-'a'];
    r-=(r%sl);
    r+=k;
  }
  printf("%lld\n",r);
  return 0;
}


Measured memory_bytes: 54272
#include<bits/stdc++.h>
using namespace std;
/*********ANISH***********ANISH*************ANISH***********ANISH******/
#define pb push_back
#define ll long long
#define ff first
#define ss second
ll max(ll a,ll b)
{
    if(a>b) return a;
    return b;
}
ll min(ll a,ll b)
{
    if(a<b) return a;
    return b;
}
/********ANISH************ANISH*************ANISH**********ANISH*********/
int n;
double p[2999];
double dp[3000][3000];
double fun(int pos,int h,int t)
{
    if(pos==n)
    {
        if(h>t)
            return 1;
        return 0;
    }
    if(dp[h][t]!=-1) return dp[h][t];
    double heads=1,tails=1;
    heads*=p[pos]*fun(pos+1,h+1,t);
    tails*=(1-p[pos])*fun(pos+1,h,t+1);
    return dp[h][t]=heads+tails;
}
int main()
{
    int t=1;
    while(t--)
    {
      cin>>n;
      for(int i=0;i<n;++i) cin>>p[i];
      for(int i=0;i<3000;++i)
      {
          for(int j=0;j<3000;++j)
            dp[i][j]=-1;
      }
      cout<<fixed<<setprecision(20)<<fun(0,0,0);//0 or 1s represent head and tail

    }
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
   ll t,a,b,c,d,i,j,k,l,n,m,x,y,g,f,h;
    cin>>g>>f>>n;
    ll s[n+5],v[n+6];
    map<ll,ll>dp,sp,mp,bp;
    l=0;
    k=0;
     y=0;
    x=0;
     set<ll>sa,sb;
    for(i=0;i<n;i++){
       cin>>s[i]>>v[i];
        sa.insert(s[i]);
        sb.insert(v[i]);
       dp[s[i]]++;
       sp[v[i]]++;
      x=max(dp[s[i]],x);
      y=max(sp[v[i]],y);
}
    vector<ll>p(sa.begin(),sa.end());
    vector<ll>p1(sb.begin(),sb.end());
   for(i=0;i<p.size();i++){
      if(dp[p[i]]==x){
        l++;
        mp[p[i]]=1;
    }
  }
    for(i=0;i<p1.size();i++){
       if(sp[p1[i]]==y){
         k++;
         bp[p1[i]]=1;
        }
  }
    ll bul=k*l;
   for(i=0;i<n;i++){
      if(mp[s[i]]==1&&bp[v[i]]==1){
      bul--;
  }
  }
    if(bul>0)
      cout<<x+y;
    else if(bul==0)
      cout<<(x+y)-1;
}

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

int main() {
  long long N,M,X;
  cin >> N >> M >> X;
  vector<vector<long long>> A(N,vector<long long>(M));
  vector<long long> C(N);
  for(int i=0; i<N; i++){
    cin >> C[i];
    for(int j=0; j<M; j++){
      cin >> A[i][j];
    }
  }
  queue<vector<bool>> que;
  vector<bool> pat(0),tmp;
  que.push(pat);
  long long money,minmoney=1e10;
  while(que.size()){
    pat = que.front();
    que.pop();
    if(pat.size() == N){
      money = 0;
      vector<long long> rikai(M,0);
      for(int i=0; i<N; i++){
        if(pat[i]){
          money += C[i];
          for(int j=0; j<M; j++){
            rikai[j] += A[i][j];
          }
        }
      }
      int flag = 1;
      for(int j=0; j<M; j++){
        if(rikai[j] < X){flag = 0; break;}
      }
      if(flag) minmoney = min(money,minmoney);
    }
    else{
      tmp = pat;
      tmp.push_back(true);
      que.push(tmp);
      tmp = pat;
      tmp.push_back(false);
      que.push(tmp);   
    }
  }
  if(minmoney == 1e10) cout << -1;
  else cout << minmoney;
  return 0;
}

Measured memory_bytes: 3904
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String s = sc.next();
		
		int wcount = 0;
		int bcount = 0;
		
		System.out.println();
		
		char[] schar = s.toCharArray();
		
		for (int i = 0; i < n; i++) {
			if (schar[i] == '.') {
				wcount++;
			} else {
				
			}
			
		}
			
			int maxWcount = wcount; 
			
			int bwmin = maxWcount;
			
		for (int i = 0; i < n; i++) {
			if (schar[i] == '#') {
				bcount++;
			} else {
				wcount--;
			}
			
			int tmp = bcount + wcount;
			
			if (tmp < bwmin) {
				bwmin = tmp;
			}
			
		}
		
		int min = Math.min(maxWcount, bwmin);
 	
	System.out.println(min);
	}
}


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


int main(){
  int n, r, k;
  cin>> n >> r;
  if(n >= 10){
    cout << r << endl;
  }
  else{
    k = r + (100 * (10 - n));
    cout << k << endl;
  }
  return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll x,y;
    cin >> x >> y;
    if(abs(x - y) < 2) cout << "Brown" << endl;
    else cout << "Alice" << endl;

    return 0;
}

Measured memory_bytes: 3588
{-# OPTIONS_GHC -O2 -optc-O2 #-}
module Main where

import Control.Monad
import Control.Monad.State
import Data.List
import qualified Data.ByteString.Lazy.Char8 as L

data Type = Increasing | Decreasing | Unknown
            deriving (Show, Eq)

unique :: (Eq a) => [a] -> [a]
unique = map head . group

getType :: Int -> Int -> Type
getType x y | x < y = Increasing
            | otherwise = Decreasing

solve :: [Int] -> Int
solve xs = groups + 1
    where (h:ts) = unique xs
          (groups, _, _) = foldl' update (0, Unknown, h) ts
          update (ng, t, x) y = case t of
                                  Unknown -> (ng, getType x y, y)
                                  Increasing -> if x < y
                                                then (ng, t, y)
                                                else (ng + 1, Unknown, y)
                                  Decreasing -> if x > y
                                                then (ng, t, y)
                                                else (ng + 1, Unknown, y)

test0 = [1, 2, 3, 2, 2, 1] :: [Int]
test1 = [1, 2, 1, 2, 1, 2, 1, 2, 1] :: [Int]
test2 = [1, 2, 3, 2, 1, 999999999, 1000000000] :: [Int]

type Tokenizer = State [L.ByteString]

nextInt :: Tokenizer Int
nextInt = state $ \(s:ss) -> case L.readInt s of
                               Just (x, _) -> (x, ss)
                               Nothing -> error $ "Can't parse Int from: " ++ (L.unpack s)

go :: Tokenizer Int
go = do
  n <- nextInt
  xs <- replicateM n nextInt
  return $ solve xs

main :: IO ()
main = do
  contents <- L.getContents
  let result = evalState go (L.words contents)
  print result


Measured memory_bytes: 1916
import collections
c=collections.Counter()
n=input()
for a in map(int, raw_input().split()):
	c[a]+=1
l=[a for a, num in c.items() if num>=2]+[a for a, num in c.items() if num>=4]
if len(l)<2:
	print 0
else:
	m=max(l)
	l.remove(m)
	print m*max(l)

Measured memory_bytes: 20196
#include<bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
typedef pair<int, string> Pis;

int main()
{
  int n;
  map<Pis, int> m;

  cin >> n;

  for(int i=0; i<n; i++) {
    string s; int tmp;
    cin >> s >> tmp;
    m[Pis(s.size(), s)] += tmp;
  }

  for(map<Pis, int>::iterator it = m.begin(); it != m.end(); it++) {
    cout << (*it).fr.sc << " " << (*it).sc << endl;
  }
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s; cin>>s;
	if(s=="SUN")printf("7\n");
	else if(s=="SAT")printf("1\n");
	else if(s=="FRI")printf("2\n");
	else if(s=="THU")printf("3\n");
	else if(s=="WED")printf("4\n");
	else if(s=="TUE")printf("5\n");
	else printf("6\n");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long X=1000000000+7;

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

Measured memory_bytes: 256
s=input()
length=len(s)
ans=0
for i in range(2**(length-1)):
  bi=bin(i)[2:].zfill(length-1) #0埋め2進数
  temp=0
  for index,j in enumerate(bi):
    if j=="1":
      ans+=int(s[temp:index+1])
      temp=index+1
  ans+=int(s[temp:]) #最後の+より後ろを足す
print(ans)

Measured memory_bytes: 3060
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <math.h> 

using namespace std;


void removeDupWord(char str[]);

double H, A;

int main()
{
    string s;
    getline(cin,s) ;
    
    char *cstr = new char[s.length() + 1];
    strcpy(cstr, s.c_str());
    
    removeDupWord(cstr);

    cout <<ceil( H/A);
    
    return 0;
}

void removeDupWord(char str[])
{ 
    // Returns first token  
    char *token = strtok(str, " "); 
   
    // Keep printing tokens while one of the 
    // delimiters present in str[]. 
    H= atof(token);
    token = strtok(NULL, " ");
    A=atof(token);

} 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>

using namespace std;

int main() {
  int a;
  cin >> a;

  if (a == 1) {
    cout << "Hello World" << endl;
  } else {
    int b,c;
    cin >> b >> c;
    cout << (b + c) << endl;
  }
}


Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0:
        break
    a=[0]*10
    for i in range(n):
        a[(int(input()))]+=1
        #print(a)
        
    for i in range(10):
        if a[i]==0:
            print("-")
        else:
            print("*"*a[i])


Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a,b,c,e;
  cin>>a>>b>>c;
  e=c%a;
  if(c-b>=e){
    cout<<"OK"<<endl;
  }
  else{
    cout<<"NG"<<endl;
  }
  
}


Measured memory_bytes: 3612
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	const grid = "#"

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	var in [][]int64
	for {
		h := nextInt(sc)
		w := nextInt(sc)

		if h == 0 && w == 0 {
			break
		}
		in = append(in, []int64{h, w})
	}

	var results []string
	for _, l := range in {
		line := strings.Repeat(grid, int(l[1])) + "\n"
		set := strings.Repeat(line, int(l[0]))
		results = append(results, set)
	}

	fmt.Println(strings.Join(results, "\n"))
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) int64 {
	i, err := strconv.ParseInt(nextString(sc), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}



Measured memory_bytes: 1360
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

long long gcd(long long x, long long y) {
    if (x < y) swap(x, y);
    while (x % y != 0) {
        long long divisor = x % y;
        x = y;
        y = divisor;
    }
    return y;
}

int main() {

    int K;
    cin >> K;

    long long sum = 0;

    for (int a = 1; a <= K; a++) {
        for (int b = 1; b <= K; b++) {
            for (int c = 1; c <= K; c++) {
                sum += gcd(a, gcd(b, c));
            }
        }
    }

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

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
 
int main () {
	int n,m;
	cin >> n >> m;
	vector <int> a(n+1,0);
	vector <int> b(n+1,0);
	int p;
	string s;
	for (int i = 0 ; i< m ;i++) {
		cin >> p >> s;
		if (s == "AC") {
			a[p] ++;
		} else {
			if (a[p] == 0) {
				b[p]++;
			}

		}

	}
	int count =0,count2 =0;
	rep(i,n+1) {
		if (a[i] >0) {
			count ++;
		}
		if (a[i] >0) {
			count2 += b[i];
		}
	}
	cout << count << ' ' << count2 << endl;
}


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

int main(){
    string str;
    cin >> str;
    long int ans=0;
    
    int numEq = 1 << (str.size()-1); // num of equation
    
    for(int n=0; n<numEq; ++n){ // ビットフラグで全通りを表現できる
        string tmp;
        tmp += str[0];
        
        for(int i=0; i<str.size()-1; ++i){
            if(n & (1<<i)){
                ans += stol(tmp); // str to longInt
                tmp = str[i+1];
            }else{
                tmp += str[i+1];
            }
        }
        ans += stol(tmp);
    }
    
    cout << ans << endl;
    
    return 0;
}

/*
// Ref: https://atcoder.jp/contests/arc061/submissions/8289928

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

int main() {
    string str;
    cin >> str;
    long ans = 0;
    for (int i = 0; i < (1 << (str.size() - 1)); i++) {
        string tmp;
        tmp += str[0];
        for (int j = 0; j < str.size() - 1; j++) {
            if (i & (1 << j)) {
                ans += stol(tmp);
                tmp = str[j + 1];
            }
            else {
                tmp += str[j + 1];
            }
        }
        ans += stol(tmp);
    }
    cout << ans << endl;			
}
//*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,k,a[100000];
ll f[100000],ans=1e18;
int main(){
    cin>>n>>k;
	memset(f,0x3f,sizeof(f));
    for(int i=0;i<n;i++){
		cin>>a[i];
	}
    for(int i=0;i<=n;i++){
        for(int j=0;j<n;j++)
            f[j]=min(f[j],a[(j-i+n)%n]);
        ll ret=0;
        for (int j=0;j<n;++j) ret+=f[j];
        ans=min(ans,ret+1ll*k*i);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define fix(n) cout<<fixed<<setprecision(n);
using namespace std;
//using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int x,y,z; cin>>x>>y>>z;
  string s[x];
  rep(i,0,x) cin>>s[i];
  int ra=1,rb=1;
  rep(i,0,x) ra*=2;
  rep(i,0,y) rb*=2;
  int ans=0;
  
  rep(i,0,ra){
    vector<vector<int>> v(x,vector<int> (y,0));
    
    int n=i;
    rep(j,0,x){
      if(n%2==1) rep(k,0,y) v[j][k]++;
      n/=2;
    }
    rep(j,0,rb){
      vector<vector<int>> w=v;
      int m=j;
      rep(k,0,y){
        if(m%2==1) rep(l,0,x) w[l][k]++;
        m/=2;
      }
      int c=0;
      rep(k,0,x){
        rep(l,0,y){
          if(s[k][l]=='#' && w[k][l]==0) c++;
        }
      }
      if(c==z) ans++;
      
    }

  }
  co(ans);  
  return 0;
}

Measured memory_bytes: 3600
n=int(input())

posi=[]
for _ in range(n):
  posi.append(list(map(int,input().split())))

x=0
y=0
t=0
for item in posi:
  temp=abs(x-item[1])+abs(y-item[2])
  #print(t,x,y,item)
  if item[0]-t<temp:
    #print("error")
    print("No")
    exit()
  flag=(item[0]-t-temp)%2
  #print("flag",flag)
  if flag==0:
    #print("hoge")
    t=item[0]
    x=item[1]
    y=item[2]
  else:
    print("No")
    exit()
print("Yes")

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

int main() {
  int N;
  double A[100] = {0.0};
  double divisor = 0.0;
  int temp;
  
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> temp;
    divisor += 1.0 / (double)temp;
  }
  
  cout << (1.0 / divisor) << endl;
}


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

int main() {
    int n; cin >> n;
    string s = "MARCH";
    vector<int> c(5);
    rep(i, n) {
        string t;
        cin >> t;
        for (int i = 0; i < (int)s.size(); i++) {
            if (t[0] == s[i]) {
                c[i]++;
                break;
            }
        }
    }
    Int ans = 0;
    for (int i = 0; i < 5; i++) {
        for (int j=i+1; j < 5; j++) {
            for (int k= j+1; k < 5; k++) {
                ans += Int(Int(c[i]) * c[j] * c[k]);
            }
        }
    }
    cout << ans << endl;
}

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

int main(){
    string s,t,u;
    ll a,b,ans;
    cin >> s >> t >> a >> b >> u;
    if(s==u){
        a--;
    }else{
        b--;
    }
    cout << a << " " << b;
    return 0;
}


Measured memory_bytes: 256
#!python3

LI = lambda: list(map(int, input().split()))

# input
N, M = LI()
AB = [LI() for _ in range(N)]
CD = [LI() for _ in range(M)]

INF = 10 ** 15


def distance(i, j):
    d = abs(AB[i][0] - CD[j][0]) + abs(AB[i][1] - CD[j][1])
    return d


def solve(i):
    # distance, number
    w = (INF, INF)
    for j in range(M):
        t = (distance(i, j), j + 1)
        w = min(w, t)
    return w[1]


def main():
    for i in range(N):
        ans = solve(i)
        print(ans)
    
    
if __name__ == "__main__":
    main()


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

using namespace std;

const int N_MAX = 200002;

typedef long long ll;

int n;

ll k;

int a[N_MAX];

int last[N_MAX];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    for(int i = 1; i <= n; i++)
        last[i] = -1;
    int pos = 1;
    bool ok = false;
    for(int i = 1; i <= k; i++)
    {
        last[pos] = i - 1;
        pos = a[pos];
        if(last[pos] != -1 && ok == false)
        {
            k = (k - i) % (i - last[pos]) + i;
            ok = true;
        }
    }
    cout << pos << "\n";
    return 0;
}


Measured memory_bytes: 5232
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Integer[] data = new Integer[N];
		for (int i = 0; i < N; i++) {
			data[i] = sc.nextInt();
		}

		Arrays.sort(data, Comparator.reverseOrder());

		int Alice = 0;
		int Bob = 0;

		for (int i = 0; i < data.length; i++) {
			if (i % 2 == 0) {
				Alice += data[i];
			} else {
				Bob += data[i];
			}
		}
		
		System.out.println(Alice - Bob);

		sc.close();
	}

}

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

using namespace std ; 

const int N = 1e5 + 7 ; 


int main(){
    ios_base::sync_with_stdio(0) ; 
    cin.tie(0) ; 
   // freopen("in.in" , "r" , stdin) ; 
    long long a , b , ans; 
    cin>>a>>b ; 
    ans = a ;
    a%=b ; 
    cout<<min(a , b-a) ; 
    return 0 ; 
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <iomanip>
#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 <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main()
{
    int N, T;
    cin >> N >> T;
    vector<int> tt(N);
    rep(i, N) cin >> tt.at(i);
    int total = T;
    rep(i, N - 1)
    {
        if (tt.at(i + 1) - tt.at(i) >= T)
        {
            total += T;
        }
        else
        {
            total += tt.at(i + 1) - tt.at(i);
        }
    }
    cout << total << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;
#define all(a) a.begin(), a.end()
#define eall(a) a.begin()+1, a.end()
#define show(ans)  cout << ans << endl;

long N, X;

long a(long n){
    long tmp = 1;
    rep(i, n+2) tmp *= 2;
    return tmp - 3; 
}
long b(long n){
    long tmp = 1;
    rep(i, n+1) tmp *= 2;
    return tmp - 1;
}

long DP(long x, long n){
    if(x == 1 && n == 0) return 1;
    else if(x == 0) return 0;
    else if(x == a(n)){
        x--;
        if(x <= 1 + a(n-1)) return DP(x - 1, n - 1);
        else return b(n - 1) + 1 + DP(x - (2 + a(n - 1)), n - 1);
    }
    else{
        if(x <= 1 + a(n-1)) return DP(x - 1, n - 1);
        else return b(n - 1) + 1 + DP(x - (2 + a(n - 1)), n - 1);
    }
}

int main(){
cin >> N >> X;
show(DP(X, N));









return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int i,j,max,memo,mt[10];
	
	for(i = 0;i < 10;i ++){
		scanf("%d",&mt[i]);
	}
	for(j = 0;j < 3;j ++){
		max = mt[0];
		for(i = 0;i < 10;i ++){
			if(max < mt[i]){
				max = mt[i];
				memo = i;
			}
		}
		printf("%d\n",max);
		mt[memo] = 0;
	}
	return 0;
}

Measured memory_bytes: 600
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <iomanip>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  //cout<<fixed<<setprecision(10);
  ll n,ans=0;
  ll a,b,c;
  cin>>a>>b>>c;
  ll f=1;
  if(a==b&&b==c)f=0;
  if(a!=b&&b!=c&&c!=a)f=0;
  if(f)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text.RegularExpressions;

class C
{
	static void Main()
	{
		Console.ReadLine();
		string s = Console.ReadLine();

		foreach (var c in s.Distinct())
			s = Regex.Replace(s, $"({c})+", "$1");
		Console.WriteLine(s.Length);
	}
}


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

int BinarySearch(int size, int *array, int key){
    int left = 0, right = size;
    while (left < right){
        int mid = (left + right)/2;
        if (key == array[mid]) return 1;
        else if (key > array[mid]) left = mid + 1;
        else if (key < array[mid]) right = mid;
    }
    return 0;
}

int main(int argc, char* argv[]) {
    int n, q, cnt = 0;
    cin >> n;
    int s[n];
    for (int i = 0; i < n; i++) cin >> s[i];
    cin >> q;
    int t[q];
    for (int i = 0; i < q; i++) cin >> t[i];

    for (int i = 0; i < q; i++) cnt += BinarySearch(n, s, t[i]);
    cout << cnt << "\n";

    return 0;
}



Measured memory_bytes: 3640
#include <vector>
#include <stdio.h>

/////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////// ここからコピペ /////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////

//////////////////
// Union-Find木 //
//////////////////

class UnionFind {
private:
	std::vector<int> parent_, size_;
public:
	UnionFind(const int size)
		:parent_(size), size_(size, 1)
	{
		for (int i{}; i < size; i++) parent_[i] = i;
	}
	int calcRoot(const int index)
	{
		if (parent_[index] == index) return index;
		const int p{calcRoot(parent_[index])};
		parent_[index] = p;
		return p;
	}
	bool areConnected(const int index1, const int index2)
	{
		return calcRoot(index1) == calcRoot(index2);
	}
	void unite(const int index1, const int index2)
	{
		const int root1{calcRoot(index1)}, root2{calcRoot(index2)};
		if (root1 == root2) return;
		if (size_[root1] <= size_[root2])
		{
			size_[root2] += size_[root1];
			parent_[root1] = root2;
		}
		else
		{
			size_[root1] += size_[root2];
			parent_[root2] = root1;
		}
		return;
	}
	int calcSize(const int index)
	{
		return size_[calcRoot(index)];
	}
};

/////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////// ここまでコピペ /////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A&lang=jp
int main()
{
	int n, q;
	scanf("%d%d", &n, &q);

	UnionFind uf(n);
	for (int q_i{}; q_i < q; q_i++)
	{
		int com, x, y;
		scanf("%d%d%d", &com, &x, &y);
		if (com)
		{
			if (uf.areConnected(x, y))
				puts("1");
			else
				puts("0");
		}
		else
		{
			uf.unite(x, y);
		}
	}
	return 0;
}


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

string N;
int cnt = 0;

int main() {
	cin >> N;
	for (int i = 0; i < N.length(); i++) {
		if (N[i] == '7') {
			cnt++;
		}
	}

	if (cnt != 0) {
		printf("Yes");
	}
	else {
		printf("No");
	}
}

Measured memory_bytes: 3260
#include <iostream>
#include<string>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define endl '\n'
const int INF = (1 << 30);
using namespace std;
typedef long long int ll;

void solve(){
    char s[13];
    cin >> s;
    cout << s[0] << s[1] << s[2] << s[3] << " " << s+4 << endl;;
}

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

    solve();
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

typedef long long ll;

int main(){
  char key1[6] = "maerd";
  char key2[8] = "remaerd";
  char key3[6] = "esare";
  char key4[7] = "resare";
  char s[100007];
  int n,i,j,flag;
  char t;

  scanf("%s", s);

  n = strlen(s);
  for(i = 0,j = n - 1;i < n/2;i++,j--){
    t = s[i]; s[i] = s[j]; s[j] = t;
  }

  i = 0; flag = 0;
  while(s[i] != '\0'){
    if(s[i] == 'm'){
      if(strncmp(s + i,key1,5) != 0){
        flag = 1;
        break;
      }

      else i = i + 5;
    }

    else if(s[i] == 'e'){
      if(strncmp(s + i,key3,5) != 0){
        flag = 1;
        break;
      }

      else i = i + 5;
    }

    else if(s[i] == 'r'){
      if(s[i + 2] == 'm'){
        if(strncmp(s + i,key2,7) != 0){
          flag = 1;
          break;
        }

        else i = i + 7;
      }

      else if(s[i + 2] == 's'){
        if(strncmp(s + i,key4,6) != 0){
          flag = 1;
          break;
        }

        else i = i + 6;
      }

      else{
        flag = 1;
        break;
      }
    }

    else{
      flag = 1;
      break;
    }
  }

  if(flag) printf("NO\n");

  else printf("YES\n");

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  bool p = S[0] == 'R';
  bool q = S[1] == 'R';
  bool r = S[2] == 'R';
  if(p and q and r){
    cout << 3 << endl;
  }else if ((p and q) or (q and r)) {
    cout << 2 << endl;
  }else if (p or q or r) {
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}




Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
    string str;
    int Q,T,F,rvflag=0;
    char C;
    cin >> str >> Q;
    for(int i=0; i<Q; i++){
        cin >> T;
        if(T==1){
            rvflag=!rvflag;
        }else{
            cin >> F >> C;
            if((rvflag&&F==1)||((!rvflag)&&F==2)){
                str.push_back(C);
            }else{
                str.insert(str.begin(),C);
            }
        }
    }
    if(rvflag) reverse(str.begin(),str.end());
    cout << str;
    return 0;
}


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


template<typename T>
vector<T> fast_zeta_transform(const vector<T>& f) {
    int n = f.size();
    vector<T> g = f;
    for (int i = 0; (1 << i) < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (j >> i & 1) {
                g[j] += g[j & ~(1<<i)];
            }
        }
    }
    return g;
}

struct Pair {
    int a, b;
    Pair& operator+=(const Pair &p) {
        vector<int> v{ a, b, p.a, p.b };
        sort(v.rbegin(), v.rend());
        a = v[0], b = v[1];
        return *this;
    }
};


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

    vector<Pair> f(1<<n);
    for (int i = 0; i < 1<<n; ++i) {
        f[i] = { a[i], 0 };
    }

    vector<Pair> g = fast_zeta_transform(f);

    int ans = 0;
    for (int i = 1; i < 1<<n; ++i) {
        ans = max(ans, g[i].a + g[i].b);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 8192