akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
    // H is monster health, N is how many moves Raccoon can make
int H;
    cin >> H;
  	if(H>81){
      cout << "No" << endl;
    }
  	else if(H<=10){
      cout << "Yes" << endl;
    }
  	else if(H==12){
      cout << "Yes" << endl;
    }
  	else if(H==14){
      cout << "Yes" << endl;
    }
  	else if(H==15){
      cout << "Yes" << endl;
    }
  	else if(H==16){
      cout << "Yes" << endl;
    }
  	else if(H==18){
      cout << "Yes" << endl;
    }
  	else if(H==20){
      cout << "Yes" << endl;
    }
  	else if(H==21){
      cout << "Yes" << endl;
    }
  	else if(H==24){
      cout << "Yes" << endl;
    }
  	else if(H==25){
      cout << "Yes" << endl;
    }
  	else if(H==27){
      cout << "Yes" << endl;
    }
  	else if(H==28){
      cout << "Yes" << endl;
    }
  	else if(H==30){
      cout << "Yes" << endl;
    }
  	else if(H==32){
      cout << "Yes" << endl;
    }
  	else if(H==35){
      cout << "Yes" << endl;
    }
  	else if(H==36){
      cout << "Yes" << endl;
    }
  	else if(H==40){
      cout << "Yes" << endl;
    }
  	else if(H==42){
      cout << "Yes" << endl;
    }
  	else if(H==45){
      cout << "Yes" << endl;
    }
  	else if(H==48){
      cout << "Yes" << endl;
    }
  	else if(H==49){
      cout << "Yes" << endl;
    }
  	else if(H==54){
      cout << "Yes" << endl;
    }
  	else if(H==56){
      cout << "Yes" << endl;
    }
  	else if(H==63){
      cout << "Yes" << endl;
    }
  	else if(H==64){
      cout << "Yes" << endl;
    }
  	else if(H==72){
      cout << "Yes" << endl;
    }
  	else if(H==81){
      cout << "Yes" << endl;
    }
  	else{
      cout << "No" << endl;
    }
    
}



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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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


ll a;
string b;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>a>>b;
    
    int bb=0;

    if(b[0]=='0'){
        bb = (b[2]-'0')*10 + (b[3]-'0');
    }else{
        bb = (b[0]-'0')*100 + (b[2]-'0')*10 + (b[3]-'0');
    }

    //DEBUG(bb);

    ll ans = (a*bb)/100;
    
    cout << ans << endl;
    return 0;
}

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

int gcd(int a,int b){
  int r, tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
 
int main(void){
  int n;cin >> n;
  int a[n];int b[n];int c[n];
  rep{
    cin >> a[i];
  }
  int m = a[0];
  rep{
    m = gcd(m,a[i]);
    b[i] = m;
    //cout << m << endl;
  }
  int e = a[n-1];
  for(int i = n-1;i>0;i--){
    e = gcd(e,a[i]);
    c[i] = e;
    //cout << e << endl;
  }
  int ma = 0;
  rep{
    int o;
    if(i == 0){
      o = c[i+1];
    }else if(i == n-1){
      o = b[i-1];
    }else{
      o = gcd(b[i-1],c[i+1]);
    }
    ma = max(ma,o);
    //cout << o << endl;
  }
  cout << ma << endl;
}

Measured memory_bytes: 1408
#include <set>
#include <iostream>
using namespace std;
typedef pair< int, pair<int,int> > cube;
#define x first
#define y second.first
#define z second.second

int main(){
	int n,h,a,b;
	string s;
	while(cin >> n >> h && (n||h) ){
		set<cube> data;
		
		for(int i=0;i<h;i++){
			cin >> s >> a >> b;
			for(int i=1;i<=n;i++){
				cube t;
				if(s=="xy"){
					t.x = a;
					t.y = b;
					t.z = i;
				}else if(s=="xz"){
					t.x = a;
					t.y = i;
					t.z = b;
				}else if(s=="yz"){
					t.x = i;
					t.y = a;
					t.z = b;
				}
				data.insert(t);
			}
		}
		cout << n*n*n-data.size() << endl;
	}
}

Measured memory_bytes: 2488
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    vl v(3);
    rep(i, 3) cin >> v[i];
    sort(all(v));
    int k;
    cin >> k;
    rep(i, k) v[2] *= 2LL;
    cout << v[0] + v[1] + v[2] << endl;
    return 0;
}

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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {
var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long K = inputArray[0];
			long X = inputArray[1];


			//答えの出力
			var ans = K*500 >= X ? "Yes":"No";
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}

Measured memory_bytes: 28192
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  string S;
  cin >> S;
  bool black, white;
  if (S[0] == 'B') {
    black = true;
    white = false;
  } else {
    black = false;
    white = true;
  }

  int cnt = 0;
  for (auto v : S) {
    if (black) {
      if (v == 'B') continue;
      cnt++;
      white = true;
      black = false;
    } else {
      if (v == 'W') continue;
      cnt++;
      black = true;
      white = false;
    }
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3696
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#define rep(i, a, b) for (int(i) = (a); i < (b); i++)
using namespace std;

using ll = long long;

const int INF = 100000000;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;

ll pow_mod(ll x, ll y, ll mod)
{
	ll ans=1;
	for(;y>0;y>>=1){
		if(y&1)(ans*=x)%=mod;
		(x*=x)%=mod;
	}
	return ans;
}

ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}

struct Maxflow{
	struct Edge{int to,cap,rev;};

	using Edges = vector<Edge>;
	using Graph = vector<Edges>;

	Graph g;
	vector<int> used;
	const int INF = 1e8;
	const int MAX_V;

	Maxflow(int V):g(V),used(V,0),MAX_V(V){}

	void add_edge(int from,int to,int cap){
		g[from].push_back(Edge{to,cap,(int)g[to].size()});
		g[to].push_back(Edge{from,0,(int)g[from].size()-1});
	}

	int dfs(int v,int t,int f){
		if(v==t)return f;
		used[v]=true;
		for(int i=0;i<g[v].size();i++){
			Edge &e = g[v][i];
			if(!used[e.to]&&e.cap>0){
				int d =dfs(e.to,t,min(f,e.cap));
				if(d>0){
					e.cap -=d;
					g[e.to][e.rev].cap+=d;
					return d;
				}	
			}
		}

		return 0;
	}

	int max_flow(int s,int t){
		int flow = 0;
		for(;;){
			rep(i,0,MAX_V)used[i]=false;
			int f=dfs(s,t,INF);
			if(f==0)return flow;
			flow+=f;
		}
	}
};

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!
	while(1){
		int m,n;
		cin>>m>>n;
		if(m==0&&n==0)break;
		vector<int> bcards(m),rcards(n);
		Maxflow a(m+n+2);
		rep(i,0,m)cin>>bcards[i];
		rep(i,0,n)cin>>rcards[i];
		rep(i,0,m)a.add_edge(0,i+1,1);
		rep(i,0,n)a.add_edge(m+i+1,m+n+1,1);
		rep(i,0,m){
			rep(j,0,n){
				if(gcd(bcards[i],rcards[j])!=1){
					a.add_edge(i+1,m+j+1,1);
				}
			}
		}
		int ans=a.max_flow(0,m+n+1);
		cout<<ans<<"\n";
	}
	return 0;
}


Measured memory_bytes: 7396
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

// rep(i, 100) { cout << i << endl; } => 0 1 2 ... 99
#define rep(i, n) for(int i = 0, i##_len = (n); i < (int)n; i++)

// std::sort(all(v));
#define all(x) (x).begin(), (x).end()

// long long int
using ll = long long;

// utility to cast return value of size function to int
#define SZ(x) ((int)(x).size())

// VS defines "_DEBUG" macro when debug configuration.
#if _DEBUG
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define dump(x)
#define debug(x)
#endif

// update max
template<class T>bool chmax(T & prov, const T & cur)
{
	if (cur > prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

// update min
template<class T>bool chmin(T & prov, const T & cur)
{
	if (cur < prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

int main()
{
	string S;
	cin >> S;
	if (S == "ABC")
	{
		cout << "ARC" << endl;
	}
	else
	{
		cout << "ABC" << endl;
	}
	return 0;
}


Measured memory_bytes: 3592
import cmath

param = list(map(int,input().split()))

A = param[0]
B = param[1]
h = param[2]
m = param[3]

v = (A*pow(cmath.e, (cmath.pi*m/30)*1j) - B*pow(cmath.e, (cmath.pi*h/6 + cmath.pi*m/360)*1j))

print(abs(v))


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

int main(){
    string a,b,c;
    cin>>a>>b>>c;

    if(a.at(a.size()-1)==b.at(0) && b.at(b.size()-1)==c.at(0))cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    int a[4][3][10];
    Fill(a, 0);
    int n;
    cin>>n;
    for(int i=0; i<n; ++i){
        int b,c,d,e;
        cin>>b>>c>>d>>e;
        a[b-1][c-1][d-1]+=e;
    }
    for(int i=0; i<4; ++i){
        for(int j=0; j<3; ++j){
            for(int k=0; k<10; k++){
                cout<<" "<<a[i][j][k];
            }
            cout<<endl;
        }
        if(i<3)cout<<"####################"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3100
n=parse(readline())
m=Array{Any,2}(n,3)
for i=1:n
  a,b=split(readline())
  m[i,1]=i
  m[i,2]=a
  m[i,3]=parse(Int,b)
end
print(join(sortrows(m, by=x->(x[2],-x[3]))[:,1],"\n"))

Measured memory_bytes: 123792
def main():
    N, M = map(int, input().split())
    lr = [
        list(map(int, input().split()))
        for _ in range(M)
    ]

    ans = f(N, M, lr)
    #ans = WA2(N, M, lr)
    #ans = TLE(N, M, lr)
    print(ans)


def WA(N, M, lr):
    import numpy as np
    a = np.zeros(N, dtype=int)
    for L, R in lr:
        a[L-1:R] += 1
    ans = (a == M).sum()
    return ans


def f(N, M, lr):
    l_max = max(L for L, _ in lr)
    r_min = min(R for _, R in lr)

    ans = r_min - l_max + 1
    ans = max(ans, 0)
    return ans


def TLE(N, M, lr):
    ans = 0
    for i in range(1, N+1):
        g = 0
        for L, R in lr:
            if L <= i <= R:
                g += 1
        if g == M:
            ans += 1

    return ans


if __name__ == '__main__':
    main()


Measured memory_bytes: 27396
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main(){
	fast;
	int n,val,ans=0;
	bool end=true;
	cin>>n;
	vector<int> v1,v2;
	string s1,s2;
	for(int i=0;i<n;i++)
	{
		cin>>val;
		v1.push_back(val);
		s1+=val;
	}
	for(int i=0;i<n;i++)
	{
		cin>>val;
		v2.push_back(val);
		s2+=val;
	}
	while(1)
	{
		if(v1==v2)
		{
			cout<<ans;
			return 0;
		}
		if(s1<s2)
		next_permutation(v1.begin(),v1.end());
		else
		next_permutation(v2.begin(),v2.end());		
		ans++;
	}
	return 0;
}



Measured memory_bytes: 3576
use std::io::{stdin, Read};
use std::str::FromStr;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let a: i64 = read().unwrap();
    let b: i64 = read().unwrap();
    let c: i64 = read().unwrap();
    let mut arr = vec![a, b, c];
    arr.sort();
    if arr == [5, 5, 7] {
        println!("YES");
    } else {
        println!("NO");
    }
}


Measured memory_bytes: 2096
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long L[] = new long[n];

        //Liを格納していく
        for(int i = 0; i < n; i++){
            L[i] = sc.nextInt();
        }

        int cnt = 0;

        for(int i = 0; i < n - 2; i++){
            for(int j = i + 1; j < n - 1; j++){
                for(int k = j + 1; k < n; k++){
                    long a = L[i];
                    long b = L[j];
                    long c = L[k];
                    if(a != b && b != c && c != a){
                        if(a + b > c && b + c > a && c + a > b){
                            cnt += 1;
                        }
                    }
                }
            }
        }

        System.out.println(cnt);
    }
}


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

bool kaibun(int n){
  	int a[5];
  	for(int i=0;i<5;i++){
    	a[i]=n%10;
      	n=n/10;
    }
  	if(a[0]==a[4] && a[1]==a[3]){
    	return true;
    }else{
    	return false;
    }
}

int main(){
	int a,b,cnt;cin>>a>>b;
  	for(int i=a;i<=b;i++){
  		if(kaibun(i)) cnt++;
    }
  cout<<cnt<<endl;
}    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) (flag)?1:0
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<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){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

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

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

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

// Usual Template End ================================================

// Template End ======================================================

constexpr int MOD=1e9+7;

int main(void){
  int A,B,C,D; cin>>A>>B>>C>>D;
  cout<<max(A*B,C*D)<<endl;
}













Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define db double
#define lowbit(p) (p&(-p))
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define A first
#define B second
using namespace std;
void read(int &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void read(ll &x){
	x=0; char c=getchar(); int p=1;
	for (;c<48;c=getchar())if (c=='-')p=-1;
	for (;c>47;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	x*=p;
}
void Min(int &x,int y){
	if (x>y)x=y;
}
void Max(int &x,int y){
	if (x<y)x=y;
}
void Min(ll &x,ll y){
	if (x>y)x=y;
}
void Max(ll &x,ll y){
	if (x<y)x=y;
}
#define M 100005
ll sum,res;
int a[M],n;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
//	freopen("1.in","r",stdin);
	read(n);
	int i;
	for (i=1;i<=n;i++){
		read(a[i]);
		sum+=abs(a[i]-a[i-1]);
	}
	sum+=abs(a[i]-a[i-1]);
	for (i=1;i<=n;i++){
		res=sum-abs(a[i+1]-a[i])-abs(a[i]-a[i-1])+abs(a[i+1]-a[i-1]);
		printf("%lld\n",res);
	}
	return 0;
}

Measured memory_bytes: 1664
package main

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

type Bridge struct {
	a int
	b int
}

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

	nIslands := scanInt(sc)
	nBridges := scanInt(sc)

	bridges := make([]Bridge, nBridges)

	for i := 0; i < nBridges; i++ {
		a, b := scanInt(sc), scanInt(sc)
		bridges[i] = Bridge{a, b}
	}

	// 島ごとに自分が所属するグループ (木) の代表を保持する。
	islands := make([]int, nIslands+1)

	// 各グループのランクを保持する。効率的にグループをマージしていくのに必要。
	ranks := make([]int, nIslands+1)

	// 各グループの島の数を保持する。行き来できる島のペア数を数えるのに必要。
	members := make([]int64, nIslands+1)

	// 初期状態はすべての島が独立したグループであり、メンバー数は1。
	for i := 1; i <= nIslands; i++ {
		islands[i] = i
		members[i] = 1
	}

	// connectedPairs[i]: i番目の橋まで崩落した時の、行き来できる島のペア数。
	// i==0 なら橋が1つも崩落していない状態のペア数。
	connectedPairs := make([]int64, nBridges+1)

	// 橋の崩落を逆からたどり、全ての島が孤立した状態から始める。
	// 1つずつ橋をつなげていき、行き来できるようになる島の数を数えていく。
	for i := nBridges - 1; i >= 0; i-- {
		bridge := bridges[i]

		ra := findRoot(islands, bridge.a)
		rb := findRoot(islands, bridge.b)

		// 既に同じグループの島同士がつながってもペア数は変わらない。
		if ra == rb {
			connectedPairs[i] = connectedPairs[i+1]
			continue
		}

		var main, sub int
		if ranks[ra] > ranks[rb] {
			main = ra
			sub = rb
		} else {
			main = rb
			sub = ra
		}

		islands[sub] = main
		if ranks[main] == ranks[sub] {
			ranks[main] += 1
		}

		// グループを結合すると、それぞれのメンバー同士の組み合わせ分ペア数が増える。
		// (https://www.youtube.com/watch?v=zV3Ul2pA2Fw)
		newConnectedPairs := members[main] * members[sub]
		connectedPairs[i] = connectedPairs[i+1] + newConnectedPairs
		members[main] += members[sub]
	}

	maxPairs := connectedPairs[0]
	w := bufio.NewWriter(os.Stdout)
	for i := 1; i <= nBridges; i++ {
		fmt.Fprintln(w, maxPairs-connectedPairs[i])
	}
	w.Flush()
}

func findRoot(islands []int, x int) int {
	if islands[x] == x {
		return x
	}
	root := findRoot(islands, islands[x])
	islands[x] = root
	return root
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
const ll mod = 998244353;
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}

void solve(){

  int  n,m;
  cin>>n>>m;
  int a[n+1];
  rep(i,1,n+1) cin>>a[i];
  vector<int> dp(3010,0);
  dp[0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = m; j >= 0; j--){
      // 2. put to T,but do not put to U
      // 3. do not put to both U and T
			dp[j] = dp[j]*2%mod;
      // 1. put to both U and T
			if (j-a[i] >= 0) dp[j] = (dp[j]+dp[j-a[i]])%mod;
		}
	}
	printf("%lld\n", dp[m]);

}
int main(){
    optimizeIO();
    {
      solve();
    }
}


Measured memory_bytes: 3768
n = int(input())
a = list(map(int,input().split()))
ans = 10**9  # テキトーに大きな値入れておく
for i in range(n):
    count = 0
    while a[i] % 2 == 0:
      a[i] //= 2
      count += 1
    ans = min(ans, count)

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<sstream>

using namespace std;
using ll = long long;

const int INF = 1001001001;
const int MOD = 1000000007;


int main(){
    int n, m;cin >> n >> m;
    vector<int> h(n);
    for (int i = 0;i < n;i++){
        cin >> h[i];
    }
    vector<int> a(m), b(m);
    vector<vector<int>> e(n);
    for (int i = 0;i < m;i++){
        cin >> a[i] >> b[i];
        e[a[i]-1].push_back(b[i]-1);
        e[b[i]-1].push_back(a[i]-1);
    }
    int cnt = 0;
    for (int i = 0;i < n;i++){
        bool f = true;
        for (int j = 0;j < e[i].size();j++){
            if (h[i] <= h[e[i][j]]){
                f = false;
            }
        }
        if (f){
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    string a, b, c;
    cin >> a >> b >> c;
    
    cout << a.at(0) << b.at(0) << c.at(0) << endl;
    
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    int len = s.length();
    int flag = 0;
    if(len % 2 != 0){
        flag = 1;
    }

    if(flag == 0){
        for(int i = 0; i < len; i += 2){
            if(s[i] != 'h' || s[i + 1] != 'i'){
                flag = 1;
                break;
            }
        }
    }

    if(flag == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
//m.emplace(x,0).fi->se++;

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll a;cin>>a;
  string s;cin>>s;
  if(a>=3200)cout<<s<<endl;
  else cout<<"red"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<string> s;
	s.resize(n);
	map<string, int> mp;
	for(int i = 0; i < n; ++i) {
		cin >> s[i];
		++mp[s[i]];
	}
	int mx = 0;
	vector<string> ans;
	for(int i = 0; i < n; ++i) {
		mx = max(mx, mp[s[i]]);
	}
	for(auto p : mp) {
		if(p.second == mx) {
			ans.emplace_back(p.first);
		}
	}
	sort(ans.begin(), ans.end());
	for(auto t : ans) {
		cout << t << '\n';
	}
	return 0;
}


Measured memory_bytes: 27120
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for _ in range(M)]

m = min(a) + min(b)

M = float('inf')
for x,y,c in xyc:
    x -= 1
    y -= 1
    tmp = a[x] + b[y] - c
    M = min(M,tmp)

if m>M:
    print(M)
else:
    print(m)

Measured memory_bytes: 38560
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;


//xを素因数分解する
//例えば60 = 5*3*2*2 であれば[(5,1),(3,1),(2,2)]を返す
vector<pair<LL,LL>> factorial(LL x){
	vector<pair<LL,LL>> ret;
	for(LL i=2;i*i<=x;i++){
		if(x%i==0){
			LL counter = 0;
			while(1){
				if(x%i!=0) break;
				x /= i;
				counter++;
			}
			ret.push_back(make_pair(i,counter));
		}
	}
	if(x!=1) ret.push_back(make_pair(x,1));
	return ret;
}

LL N;

LL ans = 1;

void solve(){
	//N!を素因数分解した結果をfに格納する
	//f[素数] = その素数がN!にいくつ含まれるか
	//という形で持っておく
	map<LL,LL> f;
	for(LL i=2;i<=N;i++){
		vector<pair<LL,LL>> one_of_f = factorial(i);
		for(int j=0;j<one_of_f.size();j++){
			f[one_of_f[j].first] = (f[one_of_f[j].first]+one_of_f[j].second)%mod;
		}
	}
	for(auto iter=f.begin();iter!=f.end();iter++){
		ans = (ans*(iter->second + 1))%mod;
	}
}

int main(){
    cin >> N;
 
    solve();

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

Measured memory_bytes: 256
using System;

namespace AtCoderABC133A
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;

            string[] s = Console.ReadLine().Split(' ');

            int N = int.Parse(s[0]);
            int A = int.Parse(s[1]);
            int B = int.Parse(s[2]);

            if (A * N < B)
                ans = A * N;
            else
                ans = B;

            Console.WriteLine(ans.ToString());
        }
    }

}


Measured memory_bytes: 13140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	static long n;

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		n = Long.parseLong(br.readLine());

		for (long i = 1;; i++) {
			long a = (long) Math.pow(2, i);

			if (n < a) {
				System.out.println((long) Math.pow(2, i) - 1);
				return;
			}
		}
	}
}


Measured memory_bytes: 23252
#include<stdio.h>
#include<math.h>
const int inf = 1000000000;
int main(void){
  int n;
  char x[105];
  
  scanf("%d", &n);
  for(int i=0;i<n;i++){
    scanf("%d",&x[i]);   
  }
    int l=x[0];
  int r=x[0];

  for(int i=0;i<n;i++){
    if(l>x[i]){
      l=x[i];
    }
    if(r<x[i]){
      r=x[i];
    }

  }

  int ans = inf;
  for(int i=l;i<=r;i++){
     int cost = 0;

    for(int j=0;j<n;j++) {
      cost +=(x[j]-i)*(x[j]-i);
    }
    if(ans>cost){
      ans = cost;
      //ans = MIN(ans,cost);
    }
    
  }

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

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

#define ll long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

const int N = 2e5;
ll a[N+1], b[N+1];
int main(){
	fastio
	ll n,m,k;
	cin >> n >> m >> k;
	
	for(int i = 0;i < n;i++){
		cin >> a[i+1];
		a[i+1] += a[i];
	}
	for(int i = 0;i < m;i++){
		cin >> b[i+1];
		b[i+1] += b[i];
	}
	ll ans = 0;
	for(ll i = 0, j = m;i <= n;i++){
		if(a[i] > k) break;
		while(a[i] + b[j] > k) j--;
		ans = max(i+j,ans);
	}
	cout << ans << "\n";
}	

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

#include <boost/range/adaptors.hpp>
#include <boost/range/combine.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    auto l = (h2 * 60 + m2) - (h1 * 60 + m1);

    cout << l - k << endl;
}

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

//INSERT ABOVE HERE
const int MAX = 2e6;
int ex[MAX]={};

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

  int n;
  cin>>n;
  vector<int> as(n);
  for(int i=0;i<n;i++) cin>>as[i];

  for(int a:as) ex[a]++;

  for(int i=1;i<MAX;i++){
    chmin(ex[i],2);
    for(int j=i+i;j<MAX;j+=i)
      ex[j]+=ex[i];
  }

  int ans=0;
  for(int a:as)
    if(ex[a]==1) ans++;
  cout<<ans<<newl;
  return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define fr(i,a,b) for(int i=a;i<=b;i++)
const int N=2e5+5;
int pos[30];
void func(int ps,int n)
{
	if(ps==0)
		return;
	int tot=pos[ps]-pos[ps-1];
	int one=tot/26;
	int temp=one;
	for(int i=1;i<=26;i++)
	{
		if(temp>=n)
		{
			cout<<char('a'+i-1);
			func(ps-1,n-(temp-one));
			return;
		}
		temp+=one;
	}
}

void solve()
{
	int temp=26;
	int prev=0;
	
	for(int i=1;i<=12;i++)
	{	
		pos[i]=prev+temp;
		prev+=temp;
		temp*=26;
	}
	int n;
	cin>>n;
	int len=0;
	for(int i=1;i<=12;i++)
	{
		if(pos[i]>=n)
		{
			len=i;
			break;
		}
	}
	n-=pos[len-1];
	func(len,n);
}

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

	int t=1;
	//cin>>t;
	while(t--)
		solve();

}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define mod 1000000007
#define N 1001

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, m;
	cin >> n >> m;
	int min1 = 1000000, max1 = 0, a, b;
	for (int i = 0; i < m; ++i)
	{
		cin >> a >> b;
		min1 = min(max(a, b), min1);
		max1 = max(max1, min(a,b));
	}

	// cout << max1 << " " << min1 << " ";
	if(max1 <= min1)
		cout << min1 - max1 + 1;
	else
		cout << 0;
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver1.8
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(14);
  string s;
  cin >> s;
  rep(i,0,8){
    s.pop_back();
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
import math
A,B,C,D,E,F = map(int, input().split())
water = A
suger = 0
for a in range(31):
    for b in range(31):
        subwater = A * a + B * b
        if subwater == 0:
                continue
        for c in range(1501):
            subsuger = C * c
            if subsuger <= subwater * E:
                if F - subwater * 100 - subsuger > 0:
                    subsuger += D * min((F - subwater * 100 - subsuger) // D, (subwater * E - subsuger) // D)
                if subsuger <= subwater * E and subwater * 100 + subsuger <= F and subsuger / (subwater * 100 + subsuger) > suger / (water * 100 + suger):
                    water = subwater
                    suger = subsuger
print("{} {}".format(water * 100 + suger, suger))

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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;

  int Ans = 0;
  rep(i, 0, A+1) {
    rep(j, 0, B+1) {
      rep(k, 0, C+1) {
        if ((500*i + 100*j + 50*k) == X) Ans++;
      }
    }
  }

  cout << Ans << endl;
}


Measured memory_bytes: 3608
package main

import (
  "fmt"
  "math"
)

func main() {
  var n int
  fmt.Scan(&n)
  t := make([]int, n)
  x := make([]float64, n)
  y := make([]float64, n)
  bt, bx, by := 0, 0.0, 0.0
  for i := 0; i < n; i++ {
    fmt.Scan(&t[i], &x[i], &y[i])
  }
  for i := 0; i < n; i++ {
    distance := int(math.Abs(x[i]-bx) + math.Abs(y[i]-by))
    betweenTime := t[i] - bt
    if t[i] < distance || distance%2 != betweenTime%2 {
      fmt.Println("No")
      return
    }
    bt, bx, by = t[i], x[i], y[i]
  }
  fmt.Println("Yes")
}

Measured memory_bytes: 5504
n = int(input())
lst = list(map(int,input().split(' ')))
q = int(input())
bc = [list(map(int,input().split(' '))) for _ in range(q)]

cnt = [0] * (10**5+1)
for l in lst:
    cnt[l] += 1

calc = sum(lst)
for d in bc:
    buf = cnt[d[0]]
    cnt[d[1]] += buf
    cnt[d[0]] = 0
    calc += buf * (d[1] - d[0])
    print(calc)

Measured memory_bytes: 32072
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int p[] = new int[n];
		for(int i = 0 ; i < n ; i++) {
			p[i] = sc.nextInt();
		}
		Arrays.sort(p);
		int sum = 0;
		for(int i = 0 ; i < k ; i++) {
			sum = sum + p[i];
		}
		System.out.println(sum);
	}
}



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

using namespace std;
using ll = long long;
const ll neg_max = pow(10, 9) * pow(10, 5) * -5;

ll solve(vector<ll> &va, int skip, array<vector<optional<ll>>, 3> &memo,
         int offset = 0) {
  if (offset >= va.size()) {
    if (va.size() % 2 == 0) {
      return 0;
    } else if (skip >= 2) {
      return neg_max;
    } else {
      return 0;
    }
  }

  if (!memo[skip][offset].has_value()) {
    if (skip > 0) {
      memo[skip][offset] = max(solve(va, skip, memo, offset + 2) + va[offset],
                               solve(va, skip - 1, memo, offset + 1));
    } else {
      memo[skip][offset] = solve(va, skip, memo, offset + 2) + va[offset];
    }
  }

  return memo[skip][offset].value();
}

int main(int argc, const char *argv[]) {
  int n;
  cin >> n;

  vector<ll> va(n);
  for (int i = 0; i < n; ++i) {
    cin >> va[i];
  }

  array<vector<optional<ll>>, 3> memo;
  fill(memo.begin(), memo.end(), vector<optional<ll>>(va.size() + 1));

  if (va.size() % 2 == 0) {
    cout << solve(va, 1, memo) << '\n';
  } else {
    cout << solve(va, 2, memo) << '\n';
  }

  return 0;
}

Measured memory_bytes: 21968
#include <iostream>
#include <map>  
#include <algorithm>
#include <string>
#include <utility>
#include <deque>
#include <vector>
#include <set>
#include <numeric>


bool dp_search(std::vector<int>& inst, int target, bool is_start) {
	
	int max_point = std::accumulate(inst.begin(), inst.end(), 0);

	if (std::abs(target) > max_point) return false;
	if (inst.size() <= 0) {
		if (target == 0) return true;
		else return false;
	}
	std::vector<std::vector<bool>> dp(inst.size(), (std::vector<bool>((max_point + 1)*2, false)));
	
	
	dp[0][max_point + inst[0]] = true;
	if (is_start == false) dp[0][max_point - inst[0]] = true;
	
	
	for (int i = 1; i < inst.size(); i++) {
		for (int j = -max_point; j <= max_point; j++) {
			if (max_point + j - inst[i] >= 0)
				dp[i][max_point + j] = dp[i][max_point + j] | dp[i - 1][max_point + j - inst[i]];
			if (max_point + j + inst[i] < (max_point + 1) * 2)
				dp[i][max_point + j] = dp[i][max_point + j] | dp[i - 1][max_point + j + inst[i]];
		}
	}
	return dp[inst.size() - 1][max_point + target];
}

int main() {
	std::string instruction;
	std::vector<int> X_inst, Y_inst;
	int x_target, y_target;
	std::cin >> instruction;
	std::cin >> x_target;
	std::cin >> y_target;

	int counter = 0;
	int is_x_direct = true;
	for (int i = 0; i < instruction.length(); i++) {
		if (instruction[i] == 'T') {
			//if (counter > 0) {
				if (is_x_direct) X_inst.push_back(counter);
				else Y_inst.push_back(counter);
			//}
			is_x_direct = !is_x_direct;
			counter = 0;
		}
		else {
			counter++;
		}	
	}
	//if (counter > 0) {
		if (is_x_direct) X_inst.push_back(counter);
		else Y_inst.push_back(counter);
	//}
	bool result = dp_search(X_inst, x_target, true) & dp_search(Y_inst, y_target, false);


	if (result) std::cout << "Yes" << std::endl;
	else std::cout << "No" << std::endl;
	return 0;

}

Measured memory_bytes: 2304
open Batteries
open Printf
let () =
  let n,k = Scanf.scanf "%d %d " (fun a b -> a,b) in
  let a_arr = Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  
  let rec aux i res =
    let res = (k-1) * i + 1 in
    if n <= res then i else
      aux (i+1) res
  in

  Printf.printf "%d\n" @@ aux 1 0


Measured memory_bytes: 5632
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList<String> W = new ArrayList<String>();

		for(int i=0; i<N; i++){
			String w = sc.next();
			if(i>0){
				if(W.contains(w)){
					System.out.println("No");
					return;
				}
				String str1 = w.substring(0,1);
				String str2 = W.get(i-1).substring(W.get(i-1).length()-1);
				if(!(str1.equals(str2))){
					System.out.println("No");
					return;
				}
			}
			W.add(w);
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 35672
import java.util.Scanner;

public class Main {
 public static void main(String[] args) {
	Scanner in = new Scanner(System.in)
	  .useDelimiter("[^0-9]+");
	int v = 0;
	while (in.hasNext()) {
	 v += in.nextInt();
	}
	System.out.println(v);

 }
}

Measured memory_bytes: 12000
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let mut ab = vec![vec![0; 2 * n]; 2 * n];
    for _ in 0..n {
        let (x, y) = (read::<usize>(), read::<usize>());
        ab[x][y] = 1;
    }

    let mut cd = (0..n)
        .map(|_| (read::<usize>(), read::<usize>()))
        .collect::<Vec<_>>();
    cd.sort();

    let mut ans = 0;
    for i in 0..n {
        let (x, y) = cd[i];
        'a: for yi in (0..y).rev() {
            for xi in (0..x).rev() {
                if ab[xi][yi] == 1 {
                    ans += 1;
                    ab[xi][yi] = 0;
                    break 'a;
                }
            }
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf = 10e17;
#define mod 1000000007
int findLowerBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{

    auto low = lower_bound(arr.begin(),
                           arr.end(), p);

    return low - arr.begin();
}
int findUpperBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{
    auto up = upper_bound(arr.begin(),
                          arr.end(), p);

    return up - arr.begin();
}
bool vis[200005];
vector<int> vec[100005];
int child[100005];
int div1[100005];
void dfs(int node)
{
    vis[node] = 1;
    for (int i = 0; i < vec[node].size(); i++)
    {
        if (!vis[vec[node][i]])
        {
            dfs(vec[node][i]);
            child[node] += child[vec[node][i]];
        }
    }
}
void belman(int n, int m, vector<pair<int, pair<int, int>>> vec, int dis[])
{
    for (int i = 0; i <= n + m - 1; i++)
    {
        for (int j = 0; j < vec.size(); j++)
        {
            int u = vec[j].second.first;
            int v = vec[j].second.second;
            int w = vec[j].first;

            if (dis[u] + w < dis[v])
            {
                dis[v] = dis[u] + w;
            }
        }
    }
}
int fun(int a, int b)
{
    if (a > b)
        return 0;
    if (a == b)
        return 1;
    else
    {
        return fun(a + 1, b) + fun(a, b - a);
    }
}
int32_t main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);
    string str;
    int n, l;
    cin >> n >> l;
    // n = str.length();
    vector<int> vec;
    int arr[l];

    for (int i = 0; i < l; i++)
    {
        cin >> arr[i];
        vis[arr[i]] = 1;
    }
    for (int i = 0; i < 10; i++)
        if (!vis[i])
            vec.push_back(i);
    sort(vec.begin(), vec.end());
    string str1;
    int count = 0;
    int i;
    for (i = n; i < 1000000; i++)
    {
        int p = i;
        while (i)
        {
            if (vis[i % 10])
                break;
            i /= 10;
        }
        if (i == 0)
        {
            cout << p << "\n";
            return 0;
        }
        i = p;
    }

    return 0;
}


Measured memory_bytes: 5948
"use strict";
function main(input) {
  const a = input[0];
  let ans = "";
  for(let i=0;i<a.length;i++){
    ans += "x";
  }
  
  console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

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

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

        public static void Solve()
        {
            var (H, N) = Scanner.Scan<int, int>();
            var A = Scanner.ScanEnumerable<int>().ToArray();
            var sum = A.Sum();
            Console.WriteLine(H <= sum ? "Yes" : "No");
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


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

int main()
{
        int A,B,C,D;
        cin >> A;
        cin >> B;
        cin >> C;
        cin >> D;

        int ans = 0;
        if(A<B){
                ans+=A;
        }else{
                ans+=B;
        }
        if(C<D){
                ans+=C;
        }else{
                ans+=D;
        }
        cout << ans;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  
  int n,i,j,max=-1,min=1000,sum;
  int subject[5];
  while(1){
    max=-1;
    min=1000;
    scanf("%d",&n);
    if(n==0){
      break;
    } 
    for(i=0;i<n;i++){
      sum=0;
      for(j=0;j<5;j++){
	
	scanf("%d",&subject[j]);
	sum+=subject[j];	
      }	
      if(sum>max){
	max = sum;
      }
      if(sum<min){
	min= sum;
      }   
    }
    printf("%d %d\n",max,min);  
  }
  return 0;  
}

Measured memory_bytes: 600
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
dic1 = {
    4:8,
    6:7,
    8:6,
    10:5,
    12:4,
    14:3,
    16:2,
    18:1,
}
for i in range(4,19,2):
    if i*100 <= n < (i+2)*100:
        print(dic1[i])

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

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

    int n;
    cin>>n;

    vector<pair<int,int>> a(n);

    for(int i=0;i<n;i++)
    {
        int ia;
        cin>>ia;

        a[i]=make_pair(ia,i+1);
    }

    sort(a.begin(),a.end());

    for(int i=0;i<n;i++)
    {
        cout<<a[i].second;
        if(i==n-1)break;
        cout<<" ";
    }

    return 0;
}


Measured memory_bytes: 3908
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
ll l[140]; 
int main() {
  int n;
  cin >> n;
  rep(i,n) cin >> l[i];
  sort(l,l+n);

  int ans = 0;
  rep(i,n-2) {
    for (int j = i+1; j < n-1; j++)
    {
      for (int k = j+1; k < n; k++)
      {
        if (l[i]==l[j] || l[j]==l[k]) continue;
        if (l[k]<l[i]+l[j]) ans++;
      }
      
    }
    
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636