akhauriyash/Code-Regression huggingface dataset:
#define MYDEBUG
//
#include <bits/stdc++.h>
#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
using namespace std;

typedef struct Node {
  int parent, left, right;
} Node;

static const int NMAX = 25;
static const int NIL = -1;
Node T[NMAX];
int n, H[NMAX], D[NMAX];

int setHeight(int id) {
  int h1 = 0, h2 = 0;
  if (T[id].left != NIL) {
    h1 = setHeight(T[id].left) + 1;
  }
  if (T[id].right != NIL) {
    h2 = setHeight(T[id].right) + 1;
  }
  return H[id] = max(h1, h2);
}

void setDepth(int id, int depth) {
  D[id] = depth;
  if (T[id].left != NIL) {
    setDepth(T[id].left, depth + 1);
  }
  if (T[id].right != NIL) {
    setDepth(T[id].right, depth + 1);
  }
}

int getSibling(int id) {
  int par = T[id].parent;
  if (par == NIL) {
    return NIL;
  }
  if (T[par].left == id) {
    return (T[par].right != NIL) ? T[par].right : NIL;
  } else if (T[par].right == id) {
    return (T[par].left != NIL) ? T[par].left : NIL;
  }
  return NIL;
}

int getDegree(int id) {
  int deg = 0;
  if (T[id].left != NIL) {
    deg++;
  }
  if (T[id].right != NIL) {
    deg++;
  }
  return deg;
}

string nodeType(int id) {
  if (T[id].parent == NIL) {
    return "root";
  } else if (T[id].left == NIL && T[id].right == NIL) {
    return "leaf";
  }
  return "internal node";
}

void printNode(int id) {
  cout << "node " << id << ": ";
  cout << "parent = " << T[id].parent << ", ";
  cout << "sibling = " << getSibling(id) << ", ";
  cout << "degree = " << getDegree(id) << ", ";
  cout << "depth = " << D[id] << ", ";
  cout << "height = " << H[id] << ", ";
  cout << nodeType(id) << endl;
}

int main() {
  rep(i,0,NMAX)
  {
    T[i].parent = T[i].left = T[i].right = NIL;
  }
  cin >> n;
  rep(i,0,n)
  {
    int id, l, r;
    cin >> id >> l >> r;
    T[id].left = l;
    T[id].right = r;
    T[l].parent = T[r].parent = id;
  }
  int root = 0;
  rep(i,1,n)
  {
    if (T[i].parent == NIL) {
      root = i;
    }
  }
  setDepth(root, 0);
  setHeight(root);
  rep(i,0,n)
  {
    printNode(i);
  }
}



Measured memory_bytes: 3124
#include <stdio.h>
#include <string.h>

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>

using namespace std;

inline void print()
{
	std::cout << "\n";
}

template<class T>
inline void print(T obj, char* delim="\n")
{
    std::cout << obj << delim;
}

template<class T>
inline void print(std::vector<T> obj, char* delim = "\n")
{
    for (const auto& e : obj)
    {
        print(e, " ");
    }
	print();
}

std::vector<std::string> split(const std::string &s, char delim);
std::string getline(FILE* fp = stdin);
std::vector<std::string> getlines(FILE* fp = stdin);

template<class src, class Func>
auto map_vector(const std::vector<src>& v, const Func& func)
{
    std::vector<decltype(func(v[0]))> new_v;
    new_v.reserve(v.size());
    for (unsigned i = 0; i < v.size(); ++i)
    {
        new_v.emplace_back(func(v[i]));
    }
    return std::move(new_v);
}

std::vector<int> convert_line_into_ints(std::string line);

inline vector<string> split(const string &s, char delim)
{
	vector<string> elems;
	stringstream ss(s);
	string item;
	while (std::getline(ss, item, delim)) {
		if (!item.empty()) {
			elems.push_back(item);
		}
	}
	return move(elems);
}
string getline(FILE* fp)
{
	char buffer[256];
	if (!fgets(buffer, 256, fp)) return "";
	size_t length = strlen(buffer);
	if (length > 0 && buffer[length - 1] == '\n') buffer[--length] = '\0';
	return buffer;
}

vector<string> getlines(FILE* fp)
{
	vector<string> lines;
	while (fp)
	{
		std::string line = getline(fp);
		if (line.length() >= 1) lines.emplace_back(move(line));
		else break;
	}
	return move(lines);
}

std::vector<int> convert_line_into_ints(string line)
{
	auto func = [](string str) { return stoi(str); };
	return map_vector(split(line, ' '), func);
}

int q(vector<vector<int>>& values)
{
    auto N = values[0][0];
    auto H = values[1][0];
    auto W = values[2][0];

    return (N - H + 1) * (N - W + 1);
}

int main(int argc, char* argv[])
{
	auto lines = getlines();

	auto values = map_vector(lines, convert_line_into_ints);
    
    std::cout << q(values) << endl;

    return 0;
}


Measured memory_bytes: 256
import itertools
N = int(input())
P = [p for p in map(int,input().split())]
Q = [q for q in map(int,input().split())]

NL = [n for n in range(1,N+1)]

V = [list(v) for v in itertools.permutations(NL)]

ans = abs(V.index(P)-V.index(Q))

print(ans)

Measured memory_bytes: 10228
#include<iostream>
#include<set>
#include<cmath>
using namespace std;
int dfs(int n,int m,set<int> a,int N){
	if(m>=N) return m;
	if(n>=5) return 100000;
	int ret=100000;
	for(auto itr=a.begin();itr!=a.end();++itr){
		int num=*itr;
		ret = min(ret,dfs(n+1,m+num*pow(10,n),a,N));
	}
	return ret;
}
int main(){
	set<int> V={0,1,2,3,4,5,6,7,8,9};
	int N,K;
	cin >> N >> K;
	for(int i=0;i<K;i++){
		int D;
		cin >>D;
		V.erase(D);
	}
	cout<<dfs(0,0,V,N);
}
	


Measured memory_bytes: 256
//   __________________
//  | ________________ |
//  ||          ____  ||
//  ||   /\    |      ||
//  ||  /__\   |      ||
//  || /    \  |____  ||
//  ||________________||
//  |__________________|
//  \###################\
//   \###################\
//    \        ____       \
//     \_______\___\_______\
// An AC a day keeps the doctor away.

#pragma GCC optimize("Ofast")
#pragma loop_opt(on)
#include <bits/extc++.h>
#ifdef local
#define safe std::cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
#define debug(...) qqbx(#__VA_ARGS__,  __VA_ARGS__)
template <typename H, typename ...T> constexpr void qqbx(const char *s, const H &h, T &&...args) {
    for(; *s && *s != ','; ++s) if(*s != ' ') std::cerr << *s;
    std::cerr << " = " << h << (sizeof...(T) ? ", " : "\n");
    if constexpr(sizeof...(T)) qqbx(++s, args...); // C++ 17!
}
#else
#include <bits/stdc++.h>
#define debug(...) ((void)0)
#define safe ((void)0)
#endif // local
#define all(v) begin(v),end(v)
#define get_pos(v,x) (lower_bound(begin(v),end(v),x)-begin(v))
#define sort_uni(v) sort(begin(v),end(v)),v.erase(unique(begin(v),end(v)),end(v))
#define pb emplace_back
#define ff first
#define ss second
#define mem(v,x) memset(v,x,sizeof v)

using namespace std;
using namespace __gnu_pbds;
typedef int64_t ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
template <typename T> using max_heap = std::priority_queue<T,vector<T>,less<T> >;
template <typename T> using min_heap = std::priority_queue<T,vector<T>,greater<T> >;
template <typename T> using rbt = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
constexpr ld PI = acos(-1), eps = 1e-7;
constexpr ll N = 200025, INF = 1e18, MOD = 1000000007, K = 357, inf = 1e9;
constexpr inline ll cdiv(ll x, ll m) { return x/m + ((x<0 ^ m>0) && (x%m)); } // ceiling divide
constexpr inline ll modpow(ll e,ll p,ll m=MOD) { ll r=1; for(e%=m;p;p>>=1,e=e*e%m) if(p&1) r=r*e%m; return r; }

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int t;
    cin >> t;
    while(t--) {
        ll a, b;
        cin >> a >> b;
        auto calc = [&](ll n) {
            if(n == 0) return ll(0);
            auto f = [&](ll i){
                ll j = n-i;
                return (i+(i>=a)) * (j+(j>=b));
            };
            ll x = 1;
            for(ll s = 1LL<<31; s; s>>=1) if(x+s <= n && f(x+s)-f(x+s-1) > 0) x += s;
            if(f(x) < a*b) return n;
            ll l = 0, r = n+1;
            for(ll s = 1LL<<31; s; s>>=1) {
                if(l+s < x && f(l+s) < a*b) l += s;
                if(r-s > x && f(r-s) < a*b) r -= s;
            }
            // f(l) < a*b, f(l+1) >= a*b
            return n - (r-l-1);
        };
        //for(int i = 0; i < 100; i++) cout << calc(i) << ' '; cout << '\n';
        ll x = 0;
        for(ll s = 1LL<<31; s; s>>=1) if(calc(x+s)-calc(x+s-1) > 0) x += s;
        debug(x);
        cout << calc(x)-1 << '\n';
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

/*******************************************************/
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

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

ll powll(ll n, ll p) {
  if (p == 0) return 1;
  else if (p == 1) return n;
  else {
    ll ans = powll(n, p / 2);
    ans = ans * ans;
    if (p % 2 == 1) ans = ans * n;
    return ans;
  }
}

//A[k] = k!
vll factlist(ll n) {
  if (n < 0) return{};
  else {
    vll ret((int)n + 1);
    ret[0] = 1;
    Loop1(i, (int)n) ret[i] = ret[i - 1] * i;
    return ret;
  }
}

//A[n][r] = nCr 
vvll combinationlist(int n) {
  vvll ret(n, vll(n, 1));
  Loop1(i, n - 1) {
    Loop1(j, i - 1) {
      ret[i][j] = ret[i - 1][j - 1] + ret[i - 1][j];
    }
  }
  return ret;
}

int main() {
  int n, p; cin >> n >> p;
  int a = 0, b = 0;
  Loop(i, n) {
    int x; cin >> x;
    if (x % 2 == 1) a++;
    else b++;
  }
  vvll c = combinationlist(50);
  ll ans = 0;
  if (p == 1) {
    for (int k = 1; k <= a; k += 2) {
      ans += c[a][k];
    }
    ans *= powll(2, b);
  }
  else {
    for (int k = 0; k <= a; k += 2) {
      ans += c[a][k];
    }
    ans *= powll(2, b);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <functional>

using namespace std; using ll=long long; using ld=long double; using P=pair<ll,ll>; const int INF=1e9; const ll LINF=1e18;

int main() {
  string s; cin>>s;
  bool N=false,W=false,S=false,E=false;
  for(char ch:s) {
    N=max(N,ch=='N');
    W=max(W,ch=='W');
    S=max(S,ch=='S');
    E=max(E,ch=='E');
  }
  if((N==S)&&(W==E)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>

unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

#define LOCAL  1
#define UPLOAD 2

using namespace std;

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

  int N;
  cin >> N;

  vector<int> A;
  for(int i=0;i<N;i++){
    int currentNum;
    cin >> currentNum;
    A.push_back(currentNum);
  }

  vector<int> sorted = A;
  sort(sorted.begin(), sorted.end());

  int count = 0;
  for(int i=0;i<N;i++){
    if(A[i] != sorted[i]){
      count++;
    }
  }

  if(count == 0 || count == 2){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int n,i,j,max,sosu[60000];
  while(scanf("%d",&n)!=EOF){
    for(i=0;i<=n;i++)sosu[i]=0;
    max=0;
  for(i=2;i<=n;i++){
    if(sosu[i]==0){
      if(i!=n)max=i;
    for(j=2;i*j<=60000;j++){
      sosu[i*j]=1;
    }
    }
  }
  printf("%d ",max);
  for(i=n+1;;i++){
    if(sosu[i]!=1){
      printf("%d\n",i);
      break;
    }
  }
  }
  return 0;
}

Measured memory_bytes: 832
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define rep(i,n) for (int i=1;i<=n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
const int MOD=1000000007;
char s1[60],s2[60];
int n;
long long ans=1;
ll cnt(int pos){
	if (pos<0) return 0;
	if (s1[pos]==s2[pos]) return 1;
	return 2;
}
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    cin>>s1>>s2;
    for (int i=0;i<n;i++){
    	if (i<n-1&&s1[i]==s1[i+1]){
    		if (cnt(i-1)==0) ans=ans*6%MOD;
    		else if (cnt(i-1)==1) ans=ans*2%MOD;
    		else ans=ans*3%MOD;
    		i++;
    	}
    	else{
    		if (cnt(i-1)==0) ans=ans*3%MOD;
    		else if (cnt(i-1)==1) ans=ans*2%MOD;
    	}
    }
    cout<<ans;
}

Measured memory_bytes: 256
// ex3_4
//TKC001
#include<stdio.h>
 
int main(void){
    int N;
    //yn=1ならYes,0ならNo
    int yn = 0;
 
    scanf("%d", &N);
 
    for (int i = 9; i > 0; i--)
    {
        if(N/i<=9 && N/i>=1 && N%i==0){
            yn = 1;
            break;
        }
    }
 
    if(yn==1){
        printf("Yes");
    }else{
        printf("No");
    }
 
    return 0;
    
}

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

using namespace std;

const int max_coins = 21;
const int max_price = 50001;
const int inf = 100000000;

int n, m;
int c[max_coins];
int num_coins[max_price][max_coins];

void solve() {
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      num_coins[i][j] = inf;
    }
  }
  for (int i = 0; i <= m; i++) {
    num_coins[0][i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int p = i - c[j];
      int c1 = num_coins[i][j - 1];
      int c2 = inf;
      int c3 = inf;
      if (p >= 0) {
        c2 = num_coins[p][j - 1] + 1;
        c3 = num_coins[p][j] + 1;
      }
      num_coins[i][j] = min(min(c1, c2), c3);
    }
  }
  printf("%d\n", num_coins[n][m]);
}

int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &c[i]);
  }
  solve();
  return 0;
}

Measured memory_bytes: 5124
N = int(input())
A = list(map(int,input().split()))

dic_minus = {}
dic_plus = {}

for i in range(N):
    dic_minus.setdefault((i+1)-A[i], []).append(i+1)
    dic_plus.setdefault((i+1)+A[i], []).append(i+1)

ans = 0
for minus in dic_minus:
    len_minus = len(dic_minus[minus])
    if dic_plus.setdefault(minus, "hoge") != "hoge":
        ans += len_minus * len(dic_plus[minus])

print(ans)

Measured memory_bytes: 121576
object Main extends App {

  val input: String = scala.io.StdIn.readLine // S

  val es: List[String] = List("eraser", "erase", "dreamer", "dream")

  if (es.foldLeft(input)((s, e) => s.replace(e, "")).length == 0)
    println("YES")
  else
    println("NO")
}


Measured memory_bytes: 26692
import java.util.*;

class Main{
	public static void main(String[] $) {
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),d=s.nextInt();

		int[][]p=new int[n][d];
		for(int i=0;i<n;++i)
			for(int j=0;j<d;++j)
				p[i][j]=s.nextInt();

		int r=0;
		for(int i=0;i<n;++i) {
			for(int j=i+1;j<n;++j) {
				if(f(p[i],p[j],d))
					++r;
			}
		}
		System.out.println(r);
	}

	private static boolean f(int[] p,int[] p2,int n){
		int sum=0;
		for(int i=0;i<n;++i)
			sum+=(p[i]-p2[i])*(p[i]-p2[i]);
		return Math.abs(Math.pow((int)Math.sqrt(sum),2)-sum)<0.0001;
	}
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;

namespace ProgramingStydying
{
    class Program
    {
        static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var n = nk[0];
            var k = nk[1];

            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var count = new int[n];

            for(int i = 0; i < n; i++)
            {
                count[a[i] - 1]++;
            }

            var list = new List<int>();
            for(int i = 0; i < n; i++)
            {
                if(count[i] != 0)
                {
                    list.Add(count[i]);
                }
            }

            list.Sort();
            var avoidNum = list.Count - k;
            var ans = 0;
            if (avoidNum > 0)
            {
                for (int i = 0; i < avoidNum; i++)
                {
                    ans += list[i];
                }
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 45232
# include <bits/stdc++.h>
# define rr register
const int N=100010;
int size;
int a[N];
int k;
int main(void){
	scanf("%d",&k);
	size=1,a[1]=1;
	for(rr int i=2;i<=k;++i){
		for(rr int j=size;j>=1;--j){
			if((j>1&&a[j]<a[j-1]+1&&a[j]<9)||(j==1&&a[j]<9)){
				++a[j];
				for(rr int k=j+1;k<=size;++k){
					a[k]=std::max(0,a[k-1]-1);
				}
				goto ENd;
			}
		}
		++size;
		a[1]=1;
		for(rr int j=2;j<=size;++j){
			a[j]=0;
		}
		ENd:;
	}
	for(rr int i=1;i<=size;++i){
		printf("%d",a[i]);
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll n, x;

int main()
{
  while( std::cin >> n >> x, n|x )
  {
    ll ans = 0;

    repi( i, 1, n+1 ) repi( j, 1, i ) repi( k, 1, j )
      ans += i+j+k == x;
    
    std::cout << ans << std::endl;
  }

  return 0;
}


Measured memory_bytes: 3096
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}


fn main(){
    let s = read_as_string();
    let line = read_as_vec::<i64>();
    let (mut x, mut y) = (line[0], line[1]);

    let mut v: Vec<i64> = s.split("T").map(|s| s.len() as i64).collect();
    let mut x_arms: Vec<i64> = vec![];
    let mut y_arms: Vec<i64> = vec![];
    x -= v[0];
    let (x, y) = (x.abs(), y.abs());

    let mut i = 1;
    while i < v.len(){
        if v[i] > 0{
            y_arms.push(v[i]);
        }
        i += 2;
    }

    let mut i = 2;
    while i < v.len(){
        if v[i] > 0{
            x_arms.push(v[i]);
        }
        i += 2;
    }

    //solve x
    if x_arms.len() > 0{
        let mut dp = vec![vec![false;cmp::max(x_arms.iter().sum::<i64>(), x) as usize + 1];x_arms.len()];
        dp[0][x_arms[0] as usize] = true;
        for i in 1..dp.len(){
            let arm_len = x_arms[i];
            for j in 0..dp[0].len(){
                if dp[i-1][j]{
                    dp[i][((j as i64)+arm_len) as usize] = true;
                    dp[i][((j as i64)-arm_len).abs() as usize] = true;
                    dp[i][(-(j as i64)+arm_len).abs() as usize] = true;
                }
            }
        }
        if !dp.last().unwrap()[x as usize]{
            println!("No");
            return;
        }
    }else{
        if x != 0{
            println!("No");
            return;
        }
    }
    //solve y
    if y_arms.len() > 0{
        let mut dp = vec![vec![false;cmp::max(y_arms.iter().sum::<i64>(), y) as usize + 1];y_arms.len()];
        dp[0][y_arms[0] as usize] = true;
        for i in 1..dp.len(){
            let arm_len = y_arms[i];
            for j in 0..dp[0].len(){
                if dp[i-1][j]{
                    dp[i][((j as i64)+arm_len) as usize] = true;
                    dp[i][((j as i64)-arm_len).abs() as usize] = true;
                    dp[i][(-(j as i64)+arm_len).abs() as usize] = true;
                }
            }
        }
        if !dp.last().unwrap()[y as usize]{
            println!("No");
            return;
        }
    }else{
        if y != 0{
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 12540
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
  int H, W;
  cin >> H >> W;
  long long count = 0;
  if(H == 1 || W == 1){
    cout << 1;
    return 0;
  }
  else if(W % 2 == 0){
    cout << (long long)W / 2 * H;
    return 0;
  }
  else{
    for(int i = 0; i < W; i++){
      if(i % 2 == 0){
        count += (long long)(H + 1) / 2;
      }
      else count += (long long)H / 2;
    }
    cout << count;
  }
  return 0;
}


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

using std::pair;
using std::vector;
using std::string;

typedef long long ll;
typedef pair<int, int> pii;

#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) std::make_pair(a, b)
#define debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }

const int oo = 0x3f3f3f3f;

string procStatus() {
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}

template <typename T> T read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    return x *= f;
}

int n, m;
int main() {
#ifdef Wearry
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    read(n), read(m);
    if(n > m) std::swap(n, m);

    if(n == 1) {
        if(m == 1) 
            puts("1");
        else 
            printf("%d\n", m - 2);
    } else {
        printf("%lld\n", 1ll * n * m - n*2 - m*2 + 4);
    }

    return 0;
}


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

main(){
	int n,y,t,b ;
	while( cin >> n , n ){
		cin >> y ;
		int ans = 0 ;
		double r,mx = 0 ;
		for( int i=0 ; i<n ; i++ ){
			cin >> b >> r >> t ;
			double c ;
			if( t == 1 ) c = 1 + y*r/100 ;
			else c = pow( 1+r/100 , y ) ;
			
			if( mx < c ){
				mx = c ;
				ans = b ;
			}
		}
		cout << ans << endl ;
	}
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << min(A,B) + min(C,D) << endl;
}

Measured memory_bytes: 256
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();
		
		char c = ' ';
		int cnt = 0;
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) != c) {
				cnt++;
			}
			c = s.charAt(i);
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 27120
#include <bits/stdc++.h>
#define MAX (ll)(2e5 + 1)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e18)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false), cin.tie (nullptr);

using namespace std;
using ll = long long;
using ld = long double;

int main () {
	int n;
	cin >> n;
	map<string, int> ma;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		ma[s]++;
	}
	int mm = 0;
	for (auto x : ma) {
		mm = max (mm, x.second);
	}
	set<string> se;
	for (auto x : ma) {
		if (x.second == mm) {
			se.insert (x.first);
		}
	}
	for (auto x : se) {
		cout << x << "\n";
	}
}


Measured memory_bytes: 34560
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		for (int i = 0; i < 3; i++)
		{
			int h1 = sc.nextInt(),
				m1 = sc.nextInt(),
				s1 = sc.nextInt(),
				h2 = sc.nextInt(),
				m2 = sc.nextInt(),
				s2 = sc.nextInt();
			int h = h2 - h1,
				m = m2 - m1,
				s = s2 - s1;
			if (s < 0)
			{
				m--;
				s += 60;
			}
			if (m < 0)
			{
				h--;
				m += 60;
			}
			System.out.printf("%d %d %d\n", h, m, s);
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#define int1 long long int
using namespace std;
int main()
{
    int1 n;
    cin>>n;
    int1 a[n];
    int1 sum=0;
    for(int1 i=0;i<n;i++)
        {cin>>a[i];
        sum+=a[i];
        }
    int1 dp[n][n];
    for(int1 i=0;i<n;i++)
        for(int1 j=0;j<n;j++)
        dp[i][j]=0;
    for(int1 i=0;i<n;i++)
    {
        dp[i][i]=a[i];
    }
    for(int1 i=0;i<n-1;i++)
    {
        dp[i][i+1]=max(a[i],a[i+1]);
    }
    for(int1 siz=3;siz<=n;siz++)
    {
        int1 i=0;
        int1 j;
        while(i+siz-1<n)
        {
            j=i+siz-1;
            dp[i][j]=max(a[i]+min(dp[i+2][j],dp[i+1][j-1]),a[j]+min(dp[i][j-2],dp[i+1][j-1]));
            i++;
        }
    }

    int1 X=dp[0][n-1];
    int1 Y=sum-X;
    cout<<X-Y;
    return 0;
}


Measured memory_bytes: 70528
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

int main(){
    ll N;
    cin >> N;
    
    vector<ull> mask(N);
    FOR(i, 0, N){
        ll k;
        cin >> k;
        ull ms = 0;
        FOR(j, 0, k){
            ll b; cin >> b;
            ms += 1LL<<b;
        }
        mask[i] = ms;
    }

    ll Q;
    cin >> Q;

    ull f = 0;

    while(Q--){
        ll a, m;
        cin >> a >> m;
        
        switch(a){

            // test
            case 0:
            if((f>>m)&1){
                p(1);
            }else{
                p(0);
            }
            break;

            // set
            case 1:
            f |= mask[m];
            break;

            // clear
            case 2:
            {
                f &= ~mask[m];
            }
            break;

            // flip
            case 3:
            {
                f ^= mask[m];
            }
            break;

            // all
            case 4:
            {
                if((f&mask[m])==mask[m]){
                    p(1);
                }else{
                    p(0);
                }

            }
            break;

            // any
            case 5:
            if((f&mask[m])==0){
                p(0);
            }else{
                p(1);
            }
            break;

            // none
            case 6:
            if((f&mask[m])==0){
                p(1);
            }else{
                p(0);
            }
            break;

            // count
            case 7:
            {
                ll count = 0;
                ull temp = f&mask[m];
                while(temp){
                    if(temp&1){
                        count++;
                    }
                    temp = temp>>1;
                }
                p(count);
            }
            break;

            // val
            case 8:
            ull val = f&mask[m];
            p(val);
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3112
import sys

for line in sys.stdin:
    w_all = reversed([1, 2, 4, 8, 16, 32, 64, 128, 256, 512])
    n = int(line)
    use_w_list = []
    for w in w_all:
        if n >= w:
            n -= w
            use_w_list.append(w)
        if n == 0:
            break
    use_w_list = use_w_list[::-1]
    out = str(use_w_list[0])
    use_w_list.remove(use_w_list[0])
    for u in use_w_list:
        out += ' {0}'.format(str(u))
    print(out)



Measured memory_bytes: 5600
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
const int N = 100010;
const int M = 200010;
struct node{
	int pre, to;
}edge[M << 1];
int head[N], tot;
int n, m;
int dis[N], pre[N];
bool vis[N];
priority_queue<pair<int, int> > q;
void add(int u, int v) {
	edge[++tot] = node{head[u], v};
	head[u] = tot;
}
void dijkstra() {
	memset(dis, 0x3f, sizeof(dis));
	dis[1] = 0;
	q.push(make_pair(0, 1));
	while (!q.empty()) {
		int x = q.top().second;
		q.pop();
		if (vis[x]) continue;
		vis[x] = 1;
		for (int i = head[x]; i; i = edge[i].pre) {
			int y = edge[i].to;
			if (dis[y] > dis[x] + 1) {
				dis[y] = dis[x] + 1;
				pre[y] = x;
				q.push(make_pair(-dis[y], y));
			}
		}
	}
}
int main() {
	cin >> n >> m;
	for (int i = 1, u, v; i <= m; i++) {
		cin >> u >> v;
		add(u, v);
		add(v, u);
	}
	dijkstra();
	for (int i = 1; i <= n; i++) {
		if (dis[i] >= 0x3f3f3f3f) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	for (int i = 2; i <= n; i++) {
		cout << pre[i] << "\n";
	}
	return 0;
}

Measured memory_bytes: 8544
# 全ての集合のペアに、共通の値を一つずつ入れる
# 集合がA,B,Cの3個の場合、AとBを結ぶ数値は1,AとBを結ぶ数値は2、CとAは3、というようにペアごとに
# 異なる数値を割り振る
# A  B  C
# 1  1
# 2     2
#    3  3
# これにより、
# (1,2),(1,3),(2,3)となる。
# 集合の数が4個の場合は同様に
# A B C D
# 1 1
# 2   2  
# 3     3
#   4 4
#   5   5
#     6 6
# (1,2,3)(1,4,5)(2,4,6)(3,5,6)
# xC2で表現できるNの場合はこの構成が可能。(4C2 = 6なので、N = 6のとき可能)
# その際x個の集合ができる（上の場合4個）
# N = 10 ** 5のため、x * (x - 1) // 2 = たかだか10**5の数を2つずつ集合に割り振っていけば構成可能
# なおN = 1のときは(1)(1)が答え

N = int(input())
if N == 1:
  print("Yes")
  print(2)
  print(1,1)
  print(1,1)
  exit(0)
  
X = -1
for x in range(2,449):
  if (x * (x - 1) % 2) == 0 and (x * (x - 1) // 2) == N:
    X = x
    break
else:
  print("No")
  exit(0)
  
# X個の集合ができる
num = 1
ans = [set() for i in range(X)]
for i in range(len(ans)-1):
  for j in range(i+1,len(ans)):
    ans[i].add(num)
    ans[j].add(num)
    num += 1
    
print("Yes")
print(X)
for a in ans:
  print(len(a),*a)


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

int main(){
string S;
cin >> S;
long long ans = 0;
for(int i = 0; i < (1 << (S.size() - 1)); i++){ 
     string now;
     now = S.at(0);
     for(int j = 0; j < S.size() - 1; j++){ 
          if(i & (1 << j)) now += "+";
          now += S.at(j + 1);
     }
    long long sum = 0;
    int pos = 0;
    while(now.find("+", pos) != string::npos){
        int nextpos = now.find("+" , pos);
        sum += stoll(now.substr(pos, nextpos - pos));
        pos = nextpos + 1;
    }
    sum += stoll(now.substr(pos));
    ans += sum;

}
cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
L = sorted(list(map(int,input().split())))
import bisect
ans = 0
#print(L)
for a in range(n-2):
    for b in range(a+1,n-1):
        p = bisect.bisect_left(L,L[a] + L[b])
        #print(bisect.bisect_left(L,L[a]+L[b]),"-",L[a] + L[b])
        ans += p - (b+1)
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

int main() {
int N,W;
cin>>N>>W;
vector<pair<int,int>> A(N);
for(int i=0; i<N; i++){cin >> A[i].first>>A[i].second;}
vector<vector<int64_t>> dp(N+1,vector<int64_t>(W+1));
for(int i=0;i<=N;i++){
for(int j=0; j<=W;j++){ dp[i][j]=0;}}
for(int i=0;i<N;i++){
for(int j=0; j<=W;j++){
if(A[i].first>j)dp[i+1][j]=dp[i][j];
else dp[i+1][j]=max(dp[i][j],dp[i][j-A[i].first]+A[i].second);}}
cout<<dp[N][W]<<endl;
}


Measured memory_bytes: 80256
<?php
  list($n, $k) = explode(" ", trim(fgets(STDIN)));

  $p = explode(" ", trim(fgets(STDIN)));

  sort($p);

  $ans = 0;
  for ($i=0; $i<$k; $i++) {
    $ans += $p[$i];
  }
  echo $ans;

Measured memory_bytes: 16204
<?php
	$n = trim(fgets(STDIN));
 	$l = explode(" ", trim(fgets(STDIN)));
	$sum = 0;
  	for ($i = 0; $i < count($l); $i++) {
      if ($i != 0) {
        if ($l[$i] < $l[$i - 1]) {
        	$s = $l[$i - 1] - $l[$i];
          	$l[$i] += $s;
          	$sum += $s;
        }
      } 
    }
	echo($sum);
	
?>

Measured memory_bytes: 31868
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int a, b, c, x, ans=0;
	cin >> a >> b >> c >> x;
	rep(i,a+1){
		rep(j,b+1){
			rep(k,c+1){
				int kane = 500*i+100*j+50*k;
				if(kane == x) ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb           push_back
#define pf           push_front
#define in           insert
#define ff           first
#define ss           second
#define mp           make_pair
#define int          long long
#define uint         unsigned long long
#define rep(i,x,m)   for(int i=x;i<m;i++)
#define repr(i,x,m)  for(int i=x;i>=m;i--)
#define MOD          1000000007
#define endl         "\n"
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define vi           vector<int>
#define vs           vector<string>
#define pi           pair<int,int>
#define di           deque<int>
#define sz(x)       (int)x.size()
#define pq           priority_queue<int>
#define pqs          priority_queue<int,vi,greater<int> >
#define fix(y)       fixed<<setprecision(y)
#define print(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
#define noob         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int fac[2000005]={0};
void factorial(){ fac[0]=1; fac[1]=1; for(int i=2;i<2000005;i++) fac[i]=((i%MOD)*(fac[i-1]%MOD))%MOD;}
int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}
int ncr(int n,int r){return (((fac[n]%MOD)*(power(fac[r],MOD-2)%MOD))%MOD*power((fac[n-r])%MOD,(MOD-2)%MOD))%MOD;}

void ram5564()
{
     int n,k;
     cin>>n>>k;
     rep(i,1,k+1)
     {
        //cout<<i<<":";
        int m1=k-i;
        int n1=i;
        int sum1=(ncr(n1+m1-1,m1))%MOD;
        //cout<<sum1<<" ";
        int n2=i-1+2;
        int m2=(n-k)-(i-1);
        if(m1<0||m2<0)
        {
            cout<<0<<endl;continue;
        }
        int sum2=(ncr(n2+m2-1,m2))%MOD;
        //cout<<sum2<<endl;
       
        cout<<(sum1%MOD*sum2%MOD)%MOD<<endl;



     }

}

signed main()
{
        noob
       
        factorial();
        int t=1;
        //cin>>t;
        while(t--)
        ram5564();
        cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;

        return 0;
}

Measured memory_bytes: 19428
using System.Collections.Generic;
using System.Linq;
using System;
class Program
{
    static void Main()
    {
        int a = int.Parse(Console.ReadLine());
        int b = int.Parse(Console.ReadLine());
        int diff = b - a;
        int result = b + diff;
        Console.WriteLine(result.ToString());
    }
}

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

using namespace std;

using ll = long long;
const int mod = 1e9 + 7;

#define mem(a, b) memset(a, b, sizeof(a))
#define REP(i, a) for (int i = 0; i < a; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(a) a.begin(), a.end()

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(10);
}

inline void print_vector(vector<int> &A){
    for (auto&& x : A){
        cout << x << " ";
    }
    cout << endl;
}

inline void print_array(const int A[], int n) {
    REP(i, n) {
        if (i < n - 1) {
            cout << A[i] << " ";
        } else {
            cout << A[i] << endl;
        }
    }
}

inline void solve() {
    int n;
    cin >> n;

    ll n0 = 1, n1 = 0, n2 = 0, n3 = 0;

    while (n--) {
        ll nn0, nn1, nn2, nn3;
        nn0 = n0 * 8;
        nn1 = n0 * 1 + n1 * 9;
        nn2 = n0 * 1 + n2 * 9;
        nn3 = n1 * 1 + n2 * 1 + n3 * 10;

        n0 = nn0 % mod;
        n1 = nn1 % mod;
        n2 = nn2 % mod;
        n3 = nn3 % mod;
    }

    cout << n3 << endl;
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    int t = 1;

    for (int _ = 0; _ < t; _++) {
        solve();
    }

    return 0;
}


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

typedef long long ll;
const int INF = 1e9;
using namespace std;

ll N,S;

ll f(ll b,ll n){
    if(n<b) return n;
    return f(b,n/b)+n%b;
}

void solve(){
    if(S>N){
        printf("-1\n");return;
    }
    if(N==S){
        printf("%lld\n",N+1);
        return;
    }
    ll i=0;
    for (i = 2;i*i<=N;i++){
        if(S==f(i,N)){
            printf("%lld\n",i);
            return;
        }
    }
    ll b = 100000000001;
    for (int p = sqrt(N);p>0;p--){
            ll b = (N-S)/p + 1;
            if(b>1&&f(b,N)==S){
                cout << b <<endl;
                return;
            }
    }
    if(b<100000000001)printf("%lld\n",b);
    else printf("-1\n");
}

int main() {
    cin >> N;
    cin >> S;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
double dp[1<<16][17];
double prob[16][16];
int n, m;
/*
double solve(int bit, int k, double p){
  if(bit == 0){
    //cout << bit << " " << k << " " << p << " " << 0 << endl;
    return 0;
  }
  if(k == m){
    dp[bit][k] = max(dp[bit][k],p);
    //cout << bit << " " << k << " " << p << " " << dp[bit][k] << endl;
    return dp[bit][k];
  }
  double ret = 0.0;
  for(int i = 0; i < n; ++i){
    if((bit >> i) & 1){
      double t = p, s = 0.0;
      for(int j = k; j < m; ++j){
	s += solve(bit - (1<<i), j, t*(1.0-prob[i][j]));
	t *= prob[i][j];
      }
      s += solve(bit, m, t);
      ret = max(ret,s);
    }
  }
  dp[bit][k] = max(dp[bit][k], ret);
  //cout << bit << " " << k << " " << p << " " << dp[bit][k] << endl;
  return dp[bit][k];
}

int main(){
  cin >> n >> m;
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      cin >> prob[i][j];
    }
  }
  double ans = solve((1<<n)-1,0,1);
  printf("%.12f\n",ans);
  return 0;
}
*/
int main(){
  int n, m;
  cin >> n >> m;
  double dp[1<<n][m], prob[n][m];
  for(int i = 0; i < (1<<n); ++i){
    fill(dp[i],dp[i]+m,0);
  }
  //fill(dp[0],dp[0]+m,0);//テァツ個ォテ」ツ?古・ツ?ィテ」ツ?ヲテ・ツ?津」ツつ古」ツ?ヲテ」ツつ凝」ツ?ョテ」ツ?ァ0

  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j){
      cin >> prob[i][j];
    }
  }
  
  for(int bit = 0; bit < (1<<n); ++bit){
    for(int i = 0; i < m; ++i){
      for(int j = 0; j < n; ++j){
	if(bit>>j & 1){
	  double t = 0, p = 1.0;
	  for(int k = i; k < m; ++k){
	    t += p*(1.0 - prob[j][k])*dp[bit-(1<<j)][k];
	    p *= prob[j][k];
	  }
	  t += p;
	  dp[bit][i] = max(dp[bit][i],t);
	}
      }
    }
  }

  double ans = dp[(1<<n)-1][0];
  printf("%.12f\n",ans);
  return 0;
}

Measured memory_bytes: 11360
fun main(args:Array<String>){
    val charset = Charsets.UTF_8
    val n = readLine()!!.toInt()
    var s = readLine()
    var ba = s?.toByteArray()!!
    var a = Array<Int>(10*10*10*10) {0}
    var b = Array<Char>(10*10*10*10) {'0'}

    for(i in ba.indices){
        var temp = ba[i].toInt() - 65
        temp = (temp + n) % 26
        a[i] = temp + 65
        b[i] =a[i].toChar()
        print(b[i])
    }
}

Measured memory_bytes: 33928
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define int long long

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

ll l, r;
int Bitr[60], Bitl[60];

int UNI(int L, int R, int L2, int R2){
	int LL = max(L, L2), RR = min(R, R2);
	if (RR < LL) return 0;
	return (RR - LL + 1);
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> l >> r;
	if (r == l) return cout << 1, 0;
	for (int i = 0; i < 60; i++){
		if (l & (1ll << i)) Bitl[i] = 1;
		if (r & (1ll << i)) Bitr[i] = 1;
	}
	int mx;
	for (int i = 59; i >= 0; i--) if (Bitr[i] != Bitl[i]){
		mx = i;
		break;
	}
	l = 0;
	for (int i = 0; i < mx; i++){
		if (Bitl[i]) l ^= (1ll << i);
	}
	//cout << mx << '\n';
	ll ans = (1ll << mx) - 1 - l + 1;
	int L, R;
	L = (1ll << mx) + l, R = (1ll << (mx + 1)) - 1;
	int L2 = (1ll << mx);
	int R2;
	int ki = -1;
	for (int j = mx - 1; j >= 0; j--){
		if (Bitr[j]){
			ki = j;
			break;
		}
	} 
	if (ki == -1) R2 = (1ll << mx);
	else R2 = (1ll << mx) + (1ll << (ki + 1)) - 1;
	//cout << L2 << ' ' << R2 << ' ' << L << ' ' << R << '\n';
	ans += (R2 - L2 + 1) + (R - L + 1) - UNI(L, R, L2, R2);
	cout << ans;

	return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    ll N,M;
    ll A[10010],B,C;

    ll S[100010];

    ll ans=0;

int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N)cin>>A[i];
    sort(A,A+N);
    cout<<A[N-1]-A[0]<<endl;
    //cout<<A<<endl<<B;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define inf 0x7fffffff
#define llinf 0x7fffffffffffffffll
using namespace std;
int main()
{
	int i,j,k,n,m,x,y,a[10];
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	sort(a,a+3);
	printf("%d",a[2]*10+a[1]+a[0]);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define MAXN 40			// 単語数の最大値
#define LEN 10				// 単語の長さの最大値
int n;									// 単語数
int length[MAXN];			// 単語の長さを格納する配列
char word[LEN];				// 単語を読み込む配列

int check(int);

int main(void)
{
	int i;
	while(1){
		scanf("%d\n",&n);				// 単語数nを入力
		if(n==0) break;						// 単語数n=0なら終了
		
		for(i=0; i<n; i++){
			scanf("%s\n", word);		// 単語を読み込む
			length[i] = strlen(word);	// その長さを格納
		}
		
		for(i=0; i<n; i++){
			if(check(i)){						
				printf("%d\n", i+1);		//構成できたらその単語の位置を出力
				break;
			}
		}
	}
}

int check(int i)
{
	int rest;	
	
	rest = 5;							// 最初の区切りの長さは５
	while(rest > 0){
		rest -= length[i++];		// 必要な文字数から単語の文字数を引く
		if(rest < 0) return 0;		// 負になったらwhile文抜ける
	}
	rest = 7;							//２番目の区切りの長さは７
	while(rest > 0){
		rest -= length[i++];		// 必要な文字数から単語の文字数を引く
		if(rest < 0) return 0;		// 負になったらwhile文抜ける
	}
	rest = 5;							//３番目の区切りの長さは５
	while(rest > 0){
		rest -= length[i++];		// 必要な文字数から単語の文字数を引く
		if(rest < 0) return 0;		// 負になったらwhile文抜ける
	}
	rest = 7;							//４番目の区切りの長さは７
	while(rest > 0){
		rest -= length[i++];		// 必要な文字数から単語の文字数を引く
		if(rest < 0) return 0;		// 負になったらwhile文抜ける
	}
	rest = 7;							//５番目の区切りの長さは７
	while(rest > 0){
		rest -= length[i++];		// 必要な文字数から単語の文字数を引く
		if(rest < 0) return 0;		// 負になったらwhile文抜ける
	}
	return 1;
}


Measured memory_bytes: 2028
#include <iostream>

using namespace std;

int main(){
  int x[3000] = {};
  int y[3000] = {};
  for(int i=0;i<3000;i++){
    cin >> x[i] >> y[i];
    if(x[i] == 0 && y[i] == 0){
      break;
    }
  }
  for(int i=0;i<3000;i++){
    if(x[i] == 0 && y[i] == 0){
      break;
    }
    if(x[i] > y[i]){
      cout << y[i] << " " << x[i] << endl;
    }else{
      cout << x[i] << " " << y[i] << endl;
    }
  }
  return 0;
}

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

int main(){
  int ans;
  string w, s;

  cin >> w;

  ans = 0;
  while (1) {
    cin >> s;
    if (s == "END_OF_TEXT") {
      break;
    }
    transform(s.begin(), s.end(), s.begin(), ::tolower);
    if (w == s) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3164
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<list>
#include<algorithm>
#include <ctype.h>
#include<deque>
using namespace std;
using ll = long long int;

string s;
int main(void) {
	cin >> s;
	int n = s.size();
	int number = stoi(s);
	int ret = 0;
	int tmp = 10;
	for (int i = 1; i < n; i += 2) {
		ret += tmp - 1 - tmp / 10 + 1;
		tmp *= 100;
	}
	if(n%2==1)
		ret += number - tmp / 10 + 1;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

res = 0
for aa in range(a + 1):
  for bb in range(b + 1):
    for cc in range(c + 1):
      if aa * 500 + bb * 100 + cc * 50 == x:
        res += 1
print(res)


Measured memory_bytes: 2940