akhauriyash/Code-Regression huggingface dataset:
h, w, n = gets.split.map(&:to_i)

sr, sc = gets.split.map(&:to_i)

s = gets.chomp.chars
t = gets.chomp.chars

x = sc
0.upto(n-1) do |i|
  if s[i] == 'L'
    x -= 1
  end
  if x < 1
    puts "NO"
    exit
  end
  if t[i] == 'R'
    x = [x + 1, w].min
  end
end

x = sc
0.upto(n-1) do |i|
  if s[i] == 'R'
    x += 1
  end
  if x > w
    puts "NO"
    exit
  end
  if t[i] == 'L'
    x = [x - 1, 1].max
  end
end

y = sr
0.upto(n-1) do |i|
  if s[i] == 'U'
    y -= 1
  end
  if y < 1
    puts "NO"
    exit
  end
  if t[i] == 'D'
    y = [y + 1, h].min
  end
end

y = sr
0.upto(n-1) do |i|
  if s[i] == 'D'
    y += 1
  end
  if y > h
    puts "NO"
    exit
  end
  if t[i] == 'U'
    y = [y - 1, 1].max
  end
end

puts "YES"


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int k , x;

int main()
{
    _FastIO;
    cin >> k >> x;
    for(int i = x - k + 1; i < x + k; i++){
        cout << i << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;

int main() {

	char in[256];
	int year, month, day;
	
	scanf("%s", &in);
	
	sscanf(in, "%4d/%2d/%2d", &year, &month, &day);
	if(year < 2019){
		printf("Heisei\n");
	}else if(year > 2019){
		printf("TBD\n");
	}else{
		if(month <= 4) printf("Heisei\n");
		else printf("TBD\n");
	}
	
	return 0;
	
}


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

int main() {
  int n;
  cin >> n;
  vector<string> grid(n);
  for (int i = 0; i < n; i++) {
    cin >> grid[i];
  }
  int good = 0;
  for (int i = 0; i < n; i++) {
    vector<string> g = grid;
    for (int j = 0; j < n; j++) {
      g[j] = grid[(i + j) % n];
    }

    bool ok = true;
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (g[j][k] != g[k][j]) {
          ok = false;
        }
      }
    }
    if (ok)
      good++;
  }
  cout << good * n << endl;
}


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

int n, k;
int W[100000+1];

int check(int value){
    int cur_load;
    int j=0;
    for(int i=0;i<k;++i){
        cur_load = 0;
        while(cur_load+W[j]<=value){
            cur_load += W[j];
            j++;
            if(j==n) return j;
        }
    }
    return j;
}


void calcu(int *left, int *right){
    int sum = 0;
    int maxi = W[0];
    for(int i=0;i<n;++i){
        sum += W[i];
        if(W[i]>maxi) maxi = W[i];
    }
    *left = maxi;
    *right = sum+1;
}

int main(){

    scanf("%d %d",&n,&k);
    for(int i=0;i<n;++i) scanf("%d",&W[i]);

    int left, right, mid, cur_n, P;
    calcu(&left, &right);
    while(left<right){
        mid = (left+right)/2;
        cur_n = check(mid);
        if(cur_n == n){
            P = mid;
            right = mid;
        }
        else{
            left = mid+1;
        }
    }

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



Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
using namespace std;


int main() {
    int n,k;
    cin>>n>>k;
    vector<int> v;
    int x;
    int ans=0;
    for(int i=0;i<n;++i)cin>>x,v.push_back(x);
    for(int left=0;left<=n;++left){
        for(int right=0;right<=n-left;++right){
            if(left+right>k)continue;
            vector<int> w;
            for(int i=0;i<left;++i){
                w.push_back(v[i]);
            }
            for(int i=0,j=n-1;i<right;++i,--j){
                w.push_back(v[j]);
            }
            sort(w.begin(),w.end());
            int cur=0;
            for(int u:w)cur+=u;
            ans=max(ans,cur);
            for(int i=0;i<k-(left+right)&&i<(left+right);++i){
                cur-=w[i];
                ans=max(ans,cur);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
A= list(map(int,input().split()))
B=[0,0,0]
C=1
for i in range(N):
 E=0
 F=0
 for j in range(3):
  if A[i]==B[j]:
   E+=1
   if E==1:
    B[j]+=1
    F=j
 C*=E
 C%=1000000007
print(C)


Measured memory_bytes: 52952
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  long int sum=0;
  cin>>N;
  for(int i=1;i<N+1;i++){
    if(i%3!=0&&i%5!=0){
      sum+=i;
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

long long modpow(long long a,long long n, long long mod){
    long long res = 1;
    while(n>0){
        if ( n & 1 ) res = (res * a) % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return res;
}

int main(){
    //std::ifstream in("sample_01.txt");
    //std::cin.rdbuf(in.rdbuf());

    ll n ; cin >> n;
    map<pair<ll,ll>,ll> mp_plus,mp_minus;
    ll zerocount = 0;
    ll azero = 0, bzero = 0;
    rep(i,n){
        ll a,b; cin >> a >> b;
        if(a==0 && b==0){
            zerocount++;
            continue;
        }
        if(b==0){
            bzero++;
            continue;
        }
        if(a==0){
            azero++;
            continue;
        }
        if( (a>0 && b>0) || (a<0 && b<0)){
            a = abs(a), b = abs(b);
            pair<ll,ll> x = make_pair(a/__gcd(a,b),b/__gcd(a,b));
            if(mp_plus.count(x)){
                mp_plus.at(x)++;
            }else{
                mp_plus[x] = 1;
            }
        }else{
            a = abs(a), b= abs(b);
            pair<ll,ll> x = make_pair(b/__gcd(a,b),a/__gcd(a,b));
            if(mp_minus.count(x)){
                mp_minus.at(x)++;
            }else{
                mp_minus[x] = 1;
            }
        }
    }
    ll hategaitoucount = 0;
    ll hate_comb = 1;
    for(auto a:mp_plus){
        if(mp_minus.count(a.first)){
            hate_comb = hate_comb * ((modpow(2,a.second,mod) -1 )+ (modpow(2,mp_minus.at(a.first),mod) - 1) + 1) %mod; //hate_combだけの組み合わせ
            hategaitoucount += a.second + mp_minus.at(a.first); //hateペアになりうるものの数
        }
    }
    
    ll non_hate = n - hategaitoucount - zerocount - azero - bzero;
    hate_comb = hate_comb * ((modpow(2,azero,mod) -1 )+ (modpow(2,bzero,mod) - 1) + 1) %mod;

    ll ans = modpow(2,non_hate,mod) * hate_comb % mod;
    ans--;
    ans+=zerocount;
    if(ans<0) ans+=mod;
    cout << ans << endl;
    
    return 0;    
}


Measured memory_bytes: 15980
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve();
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve()
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int n = int.Parse(Console.ReadLine());

			for (int i = n; i > 0; i--) {
				for (int j = 2; j < Math.Sqrt(n); j++) {
					int x = j;
					while (x < i) {
						x *= j;
					}
					if (i == x) {
						//System.Diagnostics.Debug.WriteLine($"{i} {j}");
						Console.WriteLine(i);
						return;
					}
				}
			}
			Console.WriteLine(1);
		}
	}
}


Measured memory_bytes: 27280
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;
// get<K>(tuple型の変数)

vector<int> G[100005];
vector<vector<ll>> memo(100005, vector<ll>(2, -1));

ll rec(int from, int now, int j){
    if(memo[now][j]!=-1) return memo[now][j];

    ll res=1;
    for(auto to:G[now]){
        if(to==from) continue;
        if(j==0) res*=(rec(now, to, 0)+rec(now, to, 1));
        else res*=rec(now, to, 0);
        chmod(res);
    }
    return memo[now][j]=res;
}

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

    int n; cin >> n;
    rep(i, n-1){
        int x, y; cin >> x >> y;
        --x; --y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    
    ll ans=0;
    rep(j, 2) ans+=rec(-1, 0, j);
    chmod(ans);
    cout << ans << endl;

    return 0;
}



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

int main() {
  ll N, M;
  cin >> N >> M;

  ll ans;
  ll sm = min(N, M), lg = max(N, M);

  if (lg == 1) ans = 1;
  else if (sm == 1) ans = lg - 2;
  else ans = N * M - 2 * N - 2 * M + 4;

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stack>
#include <deque>
#include <queue>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

#define pi acos(-1)

const int maxn = 1000000 + 5;

int father[maxn];
int dis[maxn];

int Find(int x)
{
    if(father[x] == x)
        return x;

    int r = Find(father[x]);

    dis[x] = dis[father[x]] + dis[x];

    return father[x] = r;
}

int Union(int x, int y, int z)
{
    int fx = Find(x);
    int fy = Find(y);

    if (fx == fy)
        return (z == dis[y] - dis[x]);

    father[fy] = fx;

    dis[fy] = dis[x] + z - dis[y];

    return 1;
}

int main()
{
    int N, M;
    int flag = 1;

    cin >> N >> M;

    for (int i = 1; i <= N; i++)
        father[i]=i;

    for (int i = 1; i <= M; i++)
    {
        int x, y, z;

        cin >> x >> y >> z;

        if (flag)
            flag = Union(x, y, z);
    }

    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 4864
public fun readln() = readLine()!!
public fun readlnByte() = readln().toByte()
public fun readlnShort() = readln().toShort()
public fun readlnInt() = readln().toInt()

fun main() {
    val input = readlnInt()
    if (input == 1) println(0)
    else if (input == 0) println(1)
}

Measured memory_bytes: 34524
R, G, B, N = map(int, input().split())
cnt = 0
for b in range(((N + 1) // B) + 1):
    for g in range(((N + 1) // G) + 1):
        if B * b + G * g > N:
            continue
        if (N - (B * b + G * g)) % R == 0:
            cnt += 1
print(cnt)


Measured memory_bytes: 66812
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int d = b / a;
  if (a > b) {
    cout << 0 << endl;
  }
  else if (d > c) {
    cout << c << endl;
  }
  else cout << d << endl;
}

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

int main() {
  int d, g;
  cin >> d >> g;
  int pc[20][2];
  for (int i = 0; i < d; i++) {
    cin >> pc[i][0] >> pc[i][1];
  }
  int ans = 999999999;
  for (int i = 0; i < (1 << d); i++) {
    int sum = 0, tmp = 0;
    for (int j = 0; j < d; j++) {
      if (i & (1 << j)) {
        sum += 100*(j + 1)*pc[j][0] + pc[j][1];
        tmp += pc[j][0];
      }
    }
    if (sum < g) {
      for (int j = d - 1; j >= 0; j--) {
        if (!(i & (1 << j))) {
          int k = pc[j][0];
          while (k >= 1) {
            if (sum >= g) {
              break;
            }
            sum += 100*(j + 1);
            tmp++;
            k--;
          }
        }
        if (sum >= g) {
          break;
        }
      }
    }
    if (tmp < ans) {
      ans = tmp;
    }
  }
  cout << ans << endl;
  return 0;
}

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

struct node_t {
	int x;
	struct node_t* next;
};

int main(void) {
	int n, q;
	struct node_t* stacks[1024];
	int i;
	if (scanf("%d%d", &n, &q) != 2) return 1;
	for (i = 0; i < n; i++) stacks[i] = NULL;
	for (i = 0; i < q; i++) {
		int query, t, x;
		if (scanf("%d%d", &query, &t) != 2) return 1;
		if (query == 0 && scanf("%d", &x) != 1) return 1;
		switch (query) {
			case 0:
				{
					struct node_t* new_node = malloc(sizeof(struct node_t));
					if (new_node == NULL) return 1;
					new_node->x = x;
					new_node->next = stacks[t];
					stacks[t] = new_node;
				}
				break;
			case 1:
				if (stacks[t] == NULL) {
					/* do nothing -> don't do "operation" */
					/* puts("an integer"); */
				} else {
					printf("%d\n", stacks[t]->x);
				}
				break;
			case 2:
				if (stacks[t] != NULL) {
					struct node_t* next = stacks[t]->next;
					free(stacks[t]);
					stacks[t] = next;
				}
				break;
		}
	}
	for (i = 0; i < n; i++) {
		while (stacks[i] != NULL) {
			struct node_t* next = stacks[i]->next;
			free(stacks[i]);
			stacks[i] = next;
		}
	}
	return 0;
}



Measured memory_bytes: 8004
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

int main(){
  int n, m;
  cin >> n >> m;

  vector<pair<ll, ll> > ab(n);
  vector<pair<ll, ll> > cd(m);
  for(ll idx = 0; idx < n; idx++) cin >> ab[idx].first >> ab[idx].second;
  for(ll idx = 0; idx < m; idx++) cin >> cd[idx].first >> cd[idx].second;
  
  vector<ll> ans(n);
  for(ll i = 0; i < n; i++){
    ll min_dist = LLONG_MAX;
    int min_idx;
    for(ll j = 0; j < m; j++){
      ll manhat_dist = abs(ab[i].first - cd[j].first) + abs(ab[i].second - cd[j].second);
      if(min_dist > manhat_dist){
        min_dist = manhat_dist;
        min_idx = j;
      }
    }
    ans[i] = min_idx;
  }

  for(int idx = 0; idx < n; idx++){
    cout << ans[idx] + 1 << '\n';
  }

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll n;
    string s;
    cin>>n;
    ll ans=0;
    cout<<n*n<<endl;
    return  0;
}


Measured memory_bytes: 256
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use num::Integer;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let n: usize = read!();
    println!("{}", 360.lcm(&n) / n);
}


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

using namespace std;
using int64 = long long;
const int mod = 1e9 + 7;

const int64 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 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

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); }

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

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

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

int main() {
  int H, W;
  cin >> H >> W;
  vector< string > S(H);
  cin >> S;

  auto dp = make_v< int64 >(4, H, W);
  fill_v(dp, -10101010);
  int vy[] = {0, 1, 0, -1};
  int vx[] = {1, 0, -1, 0};
  for(int i = 0; i < 4; i++) {
    for(int a = 0; a < H; a++) {
      for(int b = 0; b < W; b++) {
        int j = a;
        int k = b;
        if(i <= 1) {
          j = H - j - 1;
          k = W - k - 1;
        }
        if(S[j][k] == '.') {
          dp[i][j][k] = 1;
          int ny = j + vy[i], nx = k + vx[i];
          if(ny < 0 || nx < 0 || ny >= H || nx >= W) continue;
          chmax(dp[i][j][k], dp[i][ny][nx] + 1);
        }
      }
    }
  }

  int64 ret = -inf;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      if(S[i][j] == '#') continue;
      chmax(ret, dp[0][i][j] + dp[1][i][j] + dp[2][i][j] + dp[3][i][j]);
    }
  }
  cout << ret - 3 << endl;
}

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

int main() {
  string ab = "abcdefghijklmnopqrstuvwxyz";
  char c; cin >> c;
  for(int i = 0; i < 26; i++){
    if(ab.at(i) == c) cout << ab.at(i + 1);
  }
}

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

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
             string line;
             while ((line = Console.ReadLine()) != null)
             {
                 var ab = line.Split().Select(int.Parse).ToArray();
                 int a = ab[0];
                 int b = 0,c=10;
                for (int g = 0; g < c; g++)
                {
                    for (int h = 0; h < c; h++)
                    {
                        for (int i = 0; i < c; i++)
                        {
                            for (int j = 0; j < c; j++)
                            {
                                if (g + h + i + j == a)
                                    b += 1;
                                
                            }
                        }
                    }
                }
                Console.WriteLine(b);
           }
        }
    }
}

Measured memory_bytes: 9496
using System;
using System.Collections.Generic;

namespace AOJ.Volume0
{
    class Program0005
    {
        static void Main(string[] args)
        {
            string input;
            Queue<int[]> queue = new Queue<int[]>();

            while ((input = Console.ReadLine()) != null)
            {
                string[] splitedInput = input.Split(' ');
                int[] param = new int[2];

                for (int i = 0; i < 2; i++)
                {
                    param[i] = int.Parse(splitedInput[i]);
                }

                int maxKoyaku, minKobai;
                maxKoyaku = GetMaxKoyaku(param[0], param[1]);
                minKobai = GetMinKobai(param[0], param[1], maxKoyaku);

                queue.Enqueue(new[] { maxKoyaku, minKobai });
            }

            foreach (var ans in queue)
            {
                Console.WriteLine("{0} {1}", ans[0], ans[1]);
            }
        }

        static int GetMaxKoyaku(int x, int y)
        {
            int minXY = Math.Min(x, y);
            int maxXY = Math.Max(x, y);

            for (int i = 1; i <= minXY; i++)
            {
                if (minXY % i == 0)
                {
                    int temp = minXY / i;
                    if (maxXY % temp == 0)
                    {
                        return temp;
                    }
                }
            }

            return 1;
        }

        static int GetMinKobai(int x, int y, int maxKoyaku)
        {
            long kobai = Math.BigMul(x, y);
            return (int)(kobai / maxKoyaku);
        }
    }
}

Measured memory_bytes: 5964
from heapq import heappush, heappop

# 入力
N = int(input())
A = list(map(int, input().split()))

# 先頭からi(N <=i <= 2N)番目までの要素からN個の要素を選んだときの和の最大値を求める
ql = []
for a in A[:N]:
    heappush(ql, a)
L = [sum(A[:N])]
for a in A[N:(2 * N)]:
    heappush(ql, a)
    m = heappop(ql)
    L.append(L[-1] + a - m)

# 末尾からi(N <=i <= 2N)番目までの要素からN個の要素を選んだときの和の最小値を求める
qr = []
for a in A[-N:]:
    heappush(qr, -a)
R = [sum(A[-N:])]
for a in A[-(N + 1):-(2 * N + 1):-1]:
    heappush(qr, -a)
    m = -heappop(qr)
    R.append(R[-1] + a - m)

# L, R を用いて解を求める
ans = max(l - r for l, r in zip(L, R[::-1]))

# 出力
print(ans)


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

struct Line {
    ll a, b, get(ll x) { return a * x + b; }
};

struct ConvexHull {
    int size;
    Line *hull;
    ConvexHull(int maxSize) {
        hull = new Line[++maxSize], size = 0;
    }
    bool is_bad(ll curr, ll prev, ll next) {
        Line c = hull[curr], p = hull[prev], n = hull[next];
        return (c.b - n.b) * (c.a - p.a) >= (p.b - c.b) * (n.a - c.a);
    }
    void add_line(ll a, ll b) {
        hull[size++] = (Line){a, b};
        while (size > 2 && is_bad(size - 2, size - 3, size - 1))
            hull[size - 2] = hull[size - 1], size--;
    }
    ll query(ll x) {
        int l = -1, r = size - 1;
        while (r - l > 1) {
            int m = (l + r) / 2;
            if (hull[m].get(x) <= hull[m + 1].get(x))
                r = m;
            else

                l = m;
        }
        return hull[r].get(x);
    }
};
ll dp[200010], a[200010];
int main(){
    int n;
    ll c;
    cin>>n>>c;
    for(int i=0; i<n; ++i){
        scanf("%lld",a+i);
    }
    ConvexHull cv(n+10);
    dp[n-1]=0;
    cv.add_line(-2*a[n-1], a[n-1]*a[n-1]+c+dp[n-1]);
    for(int i=n-2; i>=0; --i){
        dp[i]=cv.query(a[i])+a[i]*a[i];
//        cout<<i<<" " <<dp[i]<<endl;
        cv.add_line(-2*a[i], a[i]*a[i]+c+dp[i]);
    }
    ll ans=dp[0];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

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

signed main(){
  int n;
  cin>>n;
  map<int,int> mp;
  rep(i,n){
    int a;
    cin>>a;
    mp[a]++;
  }
  int q;
  cin>>q;
  int ans=0;
  for(auto p: mp){
    ans+=p.first*p.second;
  }
  
  rep(i,q){
    int b,c;
    cin>>b>>c;
    mp[c]+=mp[b];
    ans+=(c-b)*mp[b];
    mp[b]=0;
    cout<<ans<<endl;
  }

  // cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 9404
const line = require('fs').readFileSync('/dev/stdin', 'utf-8').split('\n');

const insert = (map, str) => {
    map[str] = true;
    return map;
};

const find = (map, str) => str in map;

line.slice(1, line.length-1).reduce((acc, x) => {
    const cmd = x.split(' ');
    switch(cmd[0]) {
        case 'insert':
            acc = insert(acc, cmd[1]);
            break;
        case 'find':
            console.log(find(acc, cmd[1]) ? 'yes' : 'no');
            break;
    }

    return acc;
}, {});


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
//const int mod = 998244353;

const int64 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 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

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); }

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

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

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int H, W, M;
  cin >> H >> W >> M;
  const int V = 300001;
  vector< int > latte(V), malta(V);
  set< pair< int, int > > tap;
  for(int i = 0; i < M; i++) {
    int h, w;
    cin >> h >> w;
    latte[h]++;
    malta[w]++;
    tap.emplace(h, w);
  }
  map< int, vector< int > > y, x;
  for(int i = 0; i < V; i++) {
    y[latte[i]].emplace_back(i);
    x[malta[i]].emplace_back(i);
  }
  auto a = prev(y.end());
  auto b = prev(x.end());
  int64 c = 1LL * a->second.size() * b->second.size();
  int64 d = 0;
  for(auto &p : tap) {
    if(binary_search(begin(a->second), end(a->second), p.first) &&
       binary_search(begin(b->second), end(b->second), p.second))
      ++d;
  }
  cout << a->first + b->first - (c == d) << "\n";
}


Measured memory_bytes: 23452
import java.util.Scanner;

public class Main {
	static double N;
	static int K;
	static double ans;

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

		N = sc.nextInt();
		K = sc.nextInt();

		double prob = 1 / N;

		for (int point = 1; point <= N; point++) {
			dfs(point, 1/N);
		}

		System.out.println(ans);
	}

	private static void dfs(int point, double prob) {
		if (point >= K) {
			ans += prob;
			return;
		}

		dfs(point * 2, prob * 1/2);
	}

}

Measured memory_bytes: 21972
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
// const ll MOD = 1e9 + 7;
// const int INF = 1<<25;
// const ll INF = 1LL<<50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


// --------------------------------------------------------


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

  ll N;
  cin >> N;

  VL A(N + 2);
  ll sum = 0;
  A[0] = A[N + 1] = 0;
  NREP(i, N) {
    cin >> A[i];
    sum += abs(A[i] - A[i - 1]);
  }
  sum += abs(A[N + 1] - A[N]);

  NREP(i, N) {
    cout << sum - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1]) << endl;
  }

  return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <unordered_map>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	unordered_map<int, int> m;
	for (int i = 0; i < N; ++i) {
		int A;
		cin >> A;
		++m[A];
	}

	vector<pair<int, int>> v;
	for (const auto &e : m) {
		v.emplace_back(e.second, e.first);
	}
	sort(v.begin(), v.end());

	int ans = 0;

	if (m.size() > K) {
		int M = m.size() - K;
		for (int i = 0; i < M; ++i) {
			ans += v[i].first;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 11592
#include <bits/stdc++.h>
using namespace std;
//#pragma comment(linker, ”/STACK:36777216“)

typedef long long ll;
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define db long double

int n;
int a[200007];
map<int, int> was;
int dp[200007];

int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	int ans = n;
	for (int i = 0; i < n; i++){
		dp[i] = 1;
		if (was.find(a[i] - 1) != was.end()){
			dp[i] += dp[was[a[i] - 1]];
		}	
		was[a[i]] = i;
		ans = min(ans, n - dp[i]);
	}
	cout << ans;
}

Measured memory_bytes: 13184
#include<stdio.h>
#include<stdlib.h>

void push(int);
int pop(void);
int A[1000];
int top=0;

int main(){
  char a[100];
  int num1,num2,sum;
    
  while(scanf("%s",a)!=EOF){
    
     if(a[0]=='+'){
      num1=pop();
      num2=pop();
      push(num1+num2);
     } 

     else if(a[0]=='-'){
       num2=pop();
       num1=pop();
       push(num1-num2);
     }

     else if(a[0]=='*'){
	num1=pop();
        num2=pop();
	push(num1*num2);
     }

     else{
       push(atoi(a));	 
     }  
   }

   printf("%d\n",pop());
}

 void push(int a){
   A[++top]=a;
 }

 int pop(){
   top--;
   return A[top+1];
 }




Measured memory_bytes: 2104
S = input()
l = S.split("/")
if int(l[0]) >= 2020:
    print("TBD")
elif int(l[0]) <= 2018:
    print("Heisei")
else:
    if int(l[1]) >= 5:
        print("TBD")
    elif int(l[1]) <= 3:
        print("Heisei")
    else:
        if int(l[2]) >= 31:
            print("TBD")
        else:
            print("Heisei")


Measured memory_bytes: 3060
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n){
        cin>>v[i];
    }
    rep(i,n){
        if(v[i]%2==0){
            if(v[i]%3!=0&&v[i]%5!=0){
                cout<<"DENIED"<<endl;
                return 0;
            }
        }
    }
    cout<<"APPROVED"<<endl;


return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
from itertools import product, groupby
from math import pi
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10


def main():
    s = input()
    print(s[0] + str(len(s) - 2) + s[-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 ll INF=(1LL<<60);
const int mod=1000000007;

int main(){
    int d; cin >> d;
    switch(d){
        case 25:
            cout << "Christmas" << endl;
            break;
        case 24:
            cout << "Christmas Eve" << endl;
            break;
        case 23:
            cout << "Christmas Eve Eve" << endl;
            break;
        case 22:
            cout << "Christmas Eve Eve Eve" << endl;
            break;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<cstring>
#define  maxn 5500
using namespace std;
bitset<maxn>sum;
int a[maxn];
int n,k;
bool check(int x)
{
    if(a[x]>=k)
        return 1;
    sum.reset();
    sum[0]=1;
    for(int i=1;i<=n;i++)
        if(i!=x)
        sum|=sum<<a[i];
    for(int i=k-1;i>=k-a[x];i--)
        if(sum[i])
        return 1;
    return 0;
}

int main()
{scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++)
    scanf("%d",&a[i]);
sort(a+1,a+n+1);
    int l=0;
    int r=n+1;
    while(l<r)
    {
        int mid=(l+r)>>1;
        if(check(mid))
            r=mid;
        else
            l=mid+1;
    }
    printf("%d\n",l-1);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
int main()
{
	int a[300], b[300];
	int i = 0;
	int j = 0;
	int v = 0, t = 0;
	for ( int i = 0; i < 300; i++ )
	{
		std::cin >> a[i] >> b[i];
		if ( a[i] == 0 && b[i] == 0 )
		{
			break;
		}
		else
			{
				j++;
		    }
	}
		for ( int i = 0; i < j; i++ )
	{
		for ( int v = 0; v < a[i]; v++ )
	{
		for ( int t = 0; t <= b[i]; t++ )
	{
		if ( (v == 0 && t < b[i]) || ( v == (a[i]-1) && t < b[i]) || (t == 0 && v < a[i]) || ( t == (b[i]-1) && v < a[i]) )
	    {
			std::cout << '#';
		}
		else if ( t == b[i] )
		{
			std::cout << '\n';
		}
		else
			{
			std::cout << '.';
		    }
	}
	}
		std::cout << '\n';
		}
	return 0;
}


Measured memory_bytes: 3100
#include<iostream>
using namespace std;
int main()
{
	int a, b;
	while(true)
	{
		cin >> a >> b;
		if(a == 0 && b == 0)
			break;
		for(int i = 0;i < a;i++)
		{
			for(int j = 0;j < b;j++)
			{
				if((i & 1) == 0)
				{
					if ((j & 1) == 0)
						cout << "#";
					else
						cout << ".";
				}
				else
				{
					if ((j & 1) == 0)
						cout << ".";
					else
						cout << "#";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define pb push_back
#define mp make_pair
#define Sort(x) sort(x.begin(),x.end())
#define enld endl

typedef std::pair<int,int> pii;
using namespace std;

int main(void){
    int n,k;
    cin>>n>>k;
    vector<int> ct(n,0),ctt;
    rep(i,0,n){
        int x;
        cin>>x;
        ct[x-1]++;
    }
    Sort(ct);
    
    rep(i,0,n){
        if(ct[i]!=0){
            ctt.pb(ct[i]);
        }
    }
    int ans=0;
    if(ctt.size()<=k){
        cout<<0<<endl;
        return 0;
    }else{
    rep(i,0,ctt.size()-k){
        ans+=ctt[i];
    }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define IOS                                                                    \
  ios::sync_with_stdio(0);                                                     \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
ll bpow(ll b, ll p, ll m = 1000000007LL) {
  ll rt = 1;
  for (; p; p >>= 1, b = b * b % m)
    if (p & 1)
      rt = rt * b % m;
  return rt;
}
ll a[200005];
struct wtf {
  ll mn, a, b;
  const bool operator<(const wtf &e) const { return mn < e.mn; }
};
int main() {
  IOS;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n, greater<ll>());
  priority_queue<wtf> pq;
  pq.push({a[1], a[0], a[1]});
  ll ans = a[0];
  for (int i = 2; i < n; i++) {
    wtf mx = pq.top();
    if (i != 2)
      pq.pop();
    ans += mx.mn;
    wtf p1 = {min(mx.a, a[i]), mx.a, a[i]}, p2 = {min(mx.b, a[i]), mx.b, a[i]};
    // cout << mx.a << ' ' << mx.b << ' ' << p1.a << ' ' << p1.b << ' ' << p2.a
    //      << ' ' << p2.b << endl;
    pq.push(p1);
    pq.push(p2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 11080
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 10 03:18:11 2018

@author: Yuki
"""

X, Y = map(int, input().split())


cnt = 0
tmp_x_multi = X * 1
while True:
    if tmp_x_multi<=Y:
        cnt += 1
        tmp_x_multi *= 2
    else:
        break
print(cnt)
        
        

Measured memory_bytes: 2940
/**
 * File    : E.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-7-1 22:00:11
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;

const int M = (1 << 18);

typedef tuple<int, int> D;

int N;
int A[M];

set<D> DP[20][M];

int main()
{
  cin >> N;
  for (auto i = 0; i < (1 << N); i++)
  {
    cin >> A[i];
  }
  for (auto i = 0; i < (1 << N); i++)
  {
    DP[0][i].insert(D(-A[i], i));
  }
  for (auto i = 1; i <= N; i++)
  {
    for (auto j = 0; j < (1 << N); j++)
    {
      auto it = DP[i - 1][j].begin();
      DP[i][j].insert(*it);
      it++;
      if (it != DP[i - 1][j].end())
      {
        DP[i][j].insert(*it);
      }
      if ((j >> (i - 1)) & 1)
      {
        it = DP[i][j - (1 << (i - 1))].begin();
        DP[i][j].insert(*it);
        it++;
        if (it != DP[i][j - (1 << (i - 1))].end())
        {
          DP[i][j].insert(*it);
        }
      }
      /*
      cerr << "DP[" << i << "][" << j << "] = ";
      for (auto e : DP[i][j])
      {
        cerr << "(" << -get<0>(e) << ", " << get<1>(e) << ") ";
      }
      cerr << endl;
      */
    }
  }
  int ans = 0;
  for (auto i = 1; i < (1 << N); i++)
  {
    int tmp = 0;
    auto it = DP[N][i].begin();
    tmp += -get<0>(*it);
    it++;
    tmp += -get<0>(*it);
    ans = max(ans, tmp);
    cout << ans << endl;
  }
}

Measured memory_bytes: 888832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
    int n; cin >> n;
    ll L[87];
    L[0]=2LL, L[1]=1LL;
    REP(i, 2, n+1) L[i]=L[i-2]+L[i-1];
    cout << L[n];
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

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

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


Measured memory_bytes: 764
H, N = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

dp = [[100000000]*(10000*2)]*(N+1)
dp[0][0] = 0

for i in range(0, N):
    for h in range(0, H+1):
        dp[i+1][h] = min(dp[i+1][h], dp[i][h])
        dp[i+1][min(h+AB[i][0], H)] = min(dp[i+1][min(h+AB[i][0], H)], dp[i+1][h]+AB[i][1])

ans = {}
for i in range(N):
    ans[i] = dp[i][H]
print(min(ans.values()))

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

using namespace std;
typedef long long int ll;
ll N1097 = 1000000007LL;

int h[1000000];
int dp[1000000];
int main(){
    int N;
    cin >> N;
    for(int i=0;i<N;i++){
        scanf("%d", &h[i]);
    }
    dp[1] = abs(h[1]-h[0]);
    for(int i=2;i<N;i++){
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[N-1] << endl;
}




Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define int long long 

using namespace std ;

int a , b ;
const int hell = 1e9 + 7 ;
int fact[1000001];

int binpower(int a, int b){
        int res = 1;
        while(b){
                if(b&1)
                        (res *= a)%=hell;
                b/=2;
                (a*=a)%=hell;
        }
        return res;
}

int modinverse(int n){
        return binpower(n,hell-2);
}

int ncr(int n , int r){
        if(r==0) return 1 ;
        fact[0] = 1;
        for(int i = 1 ; i <= n ; i++ ){
                fact[i] = fact[i-1]*i%hell;
        }
        return ((fact[n]*modinverse(fact[r]))%hell*modinverse(fact[n-r])%hell)%hell;       
}

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

        cin >> a >> b ;

        if((a+b)%3!=0){
                cout << 0 << endl; 
                return 0 ;
        }

        int n = (2*a-b)/3 , m = (2*b-a)/3;

        if(n < 0 or m < 0 ){
                cout << 0 << endl ;
                return 0;
        }
        //cout << n <<' ' << m << endl ;
        cout << ncr(n+m,m) << endl; 
        
        for(int i = 0 ; i < 1000000 ; i++ ){
                for(int j = 0 ; j < 1000000000000 ; j++ )
                        true;
        }
        return 0;
        
}

Measured memory_bytes: 6528
#include <stdio.h>

int main(void){
  int n,y,m,d,D,cnt,i;


  scanf("%d" ,&n);
  for( i = 0 ; i < n ; i++ ){
    cnt = 0;
    scanf("%d %d %d" ,&y ,&m ,&d);
 
    while(1){

      if( y == 1000 && m == 1 && d == 1 ) break; 

      d++; cnt++;
      if( y % 3 == 0 || m % 2 == 1 ){
	D = 20;
	if( d > D ){ d = 1; m++; }
      }


      else{
	D = 19;
	if( d > D ){ d = 1; m++; }
      }
      
    if( m > 10 ){ y++; m = 1; }   

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

Measured memory_bytes: 596