akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

class TreeNode
{
public:
	TreeNode(int key) : key(key), pLeftChild(0), pRightChild(0) {}

public:
	int key;
	TreeNode* pLeftChild;
	TreeNode* pRightChild;
};

class BST
{
public:
	bool Insert(int key)
	{
		{
			if (!m_pRoot)
			{
				m_pRoot = new TreeNode(key);
				return true;
			}
			else
				return Insert(m_pRoot, key);
		}
	}

	void PreOrder()
	{
		PreOrder(m_pRoot);
	}

	void InOrder()
	{
		InOrder(m_pRoot);
	}

private:
	bool Insert(TreeNode* currentNode, int key)
	{
		if (key == currentNode->key) return false;
		else if (key < currentNode->key)
		{
			if (currentNode->pLeftChild) return Insert(currentNode->pLeftChild, key);
			else
			{
				currentNode->pLeftChild = new TreeNode(key);
				return true;
			}
		}
		else
		{
			if (currentNode->pRightChild) return Insert(currentNode->pRightChild, key);
			else
			{
				currentNode->pRightChild = new TreeNode(key);
				return true;
			}
		}
	}

	void PreOrder(TreeNode* currentNode)
	{
		if (!currentNode) return;

		cout << " " << currentNode->key;
		PreOrder(currentNode->pLeftChild);
		PreOrder(currentNode->pRightChild);
	}

	void InOrder(TreeNode* currentNode)
	{
		if (!currentNode) return;

		InOrder(currentNode->pLeftChild);
		cout << " " << currentNode->key;
		InOrder(currentNode->pRightChild);
	}

private:
	TreeNode* m_pRoot = 0;
};

int main()
{
	BST tree;
	int n; cin >> n;
	string oper;
	int key;
	for (int i = 0; i < n; ++i)
	{
		cin >> oper;
		if (0 == oper.compare("insert"))
		{
			cin >> key;
			tree.Insert(key);
		}
		else
		{
			tree.InOrder();
			cout << endl;
			tree.PreOrder();
			cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 18816
// D - Widespread
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define rp(i,n) for(int i=0;i<(n);++i)
#define roundup(a,b) (((a)+(b)-1)/(b))

int main(){
	int N,A,B; cin>>N>>A>>B;
	vector<int> H(N); rp(i, N) cin>>H[i];
	int ans = INT_MAX;
	LL ab = A - B;//additional damage
	int L = 0, R = 1e9;
	while(L <= R){
		int t = (L + R)/2;//mid
		LL tb = (LL)t * B;
		LL s = 0;
		rp(i, N){
			LL h = H[i] - tb;
			if(h > 0) s += roundup(h, ab);
		}
		if(t >= s){
			R = t - 1;//mid-1
			ans = t;
		}
		else L = t + 1;//mid+1
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define PI 2*acos(0)
#define INF 1e17
#define mx 2*1000000+5
using namespace std;
const ll int p=1e9+7;
ll int f[mx],inf[mx];
ll int k,n,i,j,sum,temp;
string s;
ll int mod(ll int a,ll int b) {
  ll int m = a % b;
  if (m < 0) {
        m = (b < 0) ? m - b : m + b;
  }
  return m;
}
ll int bigmod(ll int a,ll int b,ll int M)
{
    if(b==0) return mod(1,M);
    ll int x=bigmod(a,b/2,M);
    x=mod(x*x,M);
    if(b%2==1)  x=mod(a*x,M);
    return x;
}
ll int com(ll int n,ll int r)
{
    if(n<0 || r<0 ) return 0;
    if(n<r) return 0;
    ll int a=mod(f[n]*inf[r],p);
    a=mod(a*inf[n-r],p);
    return a;
}
void solve()
{
    f[0]=1;
    for(ll i=1;i<mx;i++){
        f[i]=i*f[i-1];
        f[i]=mod(f[i],p);
    }
    inf[mx-1]=bigmod(f[mx-1],p-2,p);
    for(ll i=mx-2;i>=0;i--){
        inf[i]=mod(inf[i+1]*(i+1),p);
    }
    sum=0;
    for(ll i=n;i<=n+k;i++){
        temp=mod(com(n+k,i)*bigmod(25,n+k-i,p),p);
        sum=mod(sum+temp,p);
    }
    cout<<sum;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>k;
    cin>>s;
    n=s.size();
    solve();
    return 0;
}


Measured memory_bytes: 35612
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	s := next()
	n := len(s)

	for l, r := 0, n-1; l < n && 0 <= r && l < r; {
		if s[l] == 'x' {
			l++
			continue
		}
		if s[r] == 'x' {
			r--
			continue
		}
		if s[l] != s[r] {
			puts(-1)
			return
		}
		l++
		r--
	}

	ans := 0
	for l, r := 0, n-1; l < n && 0 <= r && l < r; {
		if s[l] == s[r] {
			l++
			r--
			continue
		}
		if s[l] == 'x' {
			ans++
			l++
		} else if s[r] == 'x' {
			ans++
			r--
		}
	}
	puts(ans)
}


Measured memory_bytes: 896
#include <iostream>

using namespace std;

int main()
{
    int L, N;
    cin >> L >> N;
    cout << N << endl;
    for (int i = 0; i < N; i++) {
        int x, w;
        cin >> x >> w;
        cout << -x << " " << w << endl;
    }
    return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
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;}

ll gcd(ll x, ll y) {
  if(x > y)
    return gcd(y, x);
  else if(x == 0)
    return y;
  else
    return gcd(y % x, x);
}
ll modpow(ll a, ll N) {
  ll ans = 1;
  ll tmp = a;
  while(N > 0) {
    if(N % 2 == 1) (ans *= tmp) %= mod;
    (tmp *= tmp) %= mod;
    N /= 2;
  }
  return ans;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(n), B(n);
  map<pair<ll, ll>, ll> mp;
  ll zero=0;
  rep(i, n) {
    cin >> A[i] >> B[i];
    if(A[i] == 0 && B[i] == 0) {
      zero++;
    } else if(A[i] == 0) {
      mp[{0, 1}]++;
    } else if(B[i] == 0) {
      mp[{1, 0}]++;
    } else {
      ll g = gcd(abs(A[i]), abs(B[i]));
      A[i] /= g; B[i] /= g;
      if(A[i] < 0) {
        mp[{-A[i], -B[i]}]++;
      } else {
        mp[{A[i], B[i]}]++;
      }
    }
  }
  set<pair<ll, ll>> done;
  ll ans = 1;
  for(auto ele: mp) {
    ll a = ele.first.first;
    ll b = ele.first.second;
    if(!done.count({a, b})) {
      if(b > 0) {
        ll tmp = (modpow(2, ele.second) + modpow(2, mp[{b, -a}]) - 1) % mod;
        (ans *= tmp) %= mod;
        done.insert({a, b});
        done.insert({b, -a});
      } else {
        ll tmp = (modpow(2, ele.second) + modpow(2, mp[{-b, a}]) - 1) % mod;
        (ans *= tmp) %= mod;
        done.insert({a, b});
        done.insert({-b, a});
      }
    }
  }
  (ans += zero) %= mod;
  cout << (ans+mod-1)%mod << endk;
  return 0;
}


Measured memory_bytes: 56160
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    if ((A1+A2+A3) >= 22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	x := []string{"KIHBR", "AKIHBR", "KIHABR", "KIHBAR", "KIHBRA",
		"AKIHABR", "AKIHBAR", "AKIHBRA", "KIHABAR", "KIHABRA", "KIHBARA",
		"AKIHABAR", "AKIHABRA", "AKIHBARA", "KIHABARA", "AKIHABARA"}
	for _, v := range x {
		if s == v {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}


Measured memory_bytes: 1832
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <iomanip>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

ll BASE_NUM = 1000000007;

int main()
{
    // 整数の入力
    ll N, K;
    cin >> N;
    vector<ll> leaf_nodes(N + 1);
    vector<ll> min_root_nodes(N + 1);
    vector<ll> max_root_nodes(N + 1);
    for (int i = 0; i <= N; i++)
    {
        cin >> leaf_nodes[i];
    }
    if (N == 0){
        if (leaf_nodes[0] == 1){
            cout << 1 << endl;
        }else{
            cout << -1 << endl;
        }
        return 0;
    }
    min_root_nodes[N] = 0;
    max_root_nodes[N] = 0;
    for (int i = N - 1; i >= 0; i--)
    {
        min_root_nodes[i] = (min_root_nodes[i + 1] + leaf_nodes[i + 1] + 1) / 2;
        max_root_nodes[i] = max_root_nodes[i + 1] + leaf_nodes[i + 1];
    }

    ll nodes_count = 0;
    ll current_root = 0;
    bool can_make = true;
    for (int i = 0; i <= N; i++)
    {
        if (i == 0)
        {
            if (leaf_nodes[0] > 0)
            {
                can_make = false;
                break;
            }
            current_root = 1;
            nodes_count += 1;
        }
        else
        {
            if (current_root * 2 < min_root_nodes[i])
            {
                can_make = false;
                break;
            }
            current_root = min(max_root_nodes[i], 2 * current_root - leaf_nodes[i]);
            nodes_count += current_root + leaf_nodes[i];
        }
        // cout << current_root << " " << leaf_nodes[i] << endl;
    }
    if (can_make)
    {
        cout << nodes_count << endl;
    }
    else
    {

        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 5632
//23
#include<iostream>

using namespace std;

int w,h;

void ff(int (*g)[101],int c,int y,int x){
  if(1<=y&&y<=h&&1<=x&&x<=w&&g[y][x]==c){
    g[y][x]=-1;
    int d[]={0,1,0,-1,0};
    for(int i=0;i<4;i++){
      ff(g,c,y+d[i],x+d[i+1]);
    }
  }
}

int main(){
  for(;cin>>w>>h,w|h;){
    int g[101][101]={{}};
    int sx,sy,gx,gy;
    cin>>sx>>sy>>gx>>gy;
    int n;
    cin>>n;
    while(n--){
      int c,d,x,y;
      cin>>c>>d>>x>>y;
      for(int i=0;i<2+2*d;i++){
	for(int j=0;j<4-2*d;j++){
	  g[i+y][j+x]=c;
	}
      }
    }
    ff(g,g[sy][sx],sy,sx);
    cout<<((g[gy][gx]==-1)?"OK":"NG")<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
($N,$A,$B)=glob<>;
@h=sort{$b-$a}<>;
$A-=$B;
($l,$r)=(1,1e9);
while($r-$l>1){
	$m=$l+$r>>1;
	$c=0;
	for$h(@h){
		$t=$h-$B*$m;
		last if$t<=0;
		$c+=~-$t/$A+1|0;
	}
	$c<=$m?($r=$m):($l=$m);
}
$m=$l+$r>>1;
$c=0;
for$h(@h){
	$t=$h-$B*$m;
	last if$t<=0;
	$c+=~-$t/$A+1|0;
}
print$m+($c>$m),$/


Measured memory_bytes: 23548
#include<stdio.h>
int main(void){
	int x, y;
	while(1){
	scanf("%d %d", &x, &y);
	if(x == 0 && y == 0)
		break;
	else if(x < y){
	printf("%d %d\n", x, y);
	}
	else{
	printf("%d %d\n", y, x);
	}
	}
	return 0;
}


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    int n; cin >> n;
    int idx(1);
    int kill(0);
    
    vector<int> brick(n);
    
    for (int i = 0; i < n; ++i)
        cin >> brick[i];
        
    for (int j = 0; j < n; ++j)
    {
        if (idx == brick[j])
        {
            ++idx;
        }
        else
        {
            ++kill;
        }
    }
    
    if (kill > n - 1)
        cout << -1;
    else
        cout << kill;
}

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

typedef long long LL;
const int N = 100010;

struct Node {
	LL l, r, b, h;
	inline bool operator < (const Node &w) const {
		return h > w.h;
	}
}node[N];

LL X, D, sum[N];
int n;

inline LL cal(LL a, LL i) {
	if(a <= node[i].b) {
		return a * node[i].l;
	}
	return node[i].b * node[i].l + (a - node[i].b) * node[i].r;
}

inline bool check(LL k) {
	LL ans = 0, r = k % X, t = k / X;
	if(t >= n) {
		return sum[n];
	}
//	printf("r = %lld t = %lld \n", r, t);
	for(int i = 1; i <= n; i++) {
		if(i <= t) ans = std::max(ans, cal(r, i) + sum[t + 1] - node[i].h);
		else {
			ans = std::max(ans, cal(r, i) + sum[t]);
		}
	}
	//printf("k = %lld ans = %lld D = %lld \n", k, ans, D);
	return ans >= D;
}

int main() {
	
	scanf("%d%lld", &n, &X);
	for(int i = 1; i <= n; i++) {
		scanf("%lld%lld%lld", &node[i].b, &node[i].l, &node[i].r);
		node[i].h = node[i].b * node[i].l + (X - node[i].b) * node[i].r;
		D += node[i].b * node[i].l;
	}
	std::sort(node + 1, node + n + 1);
	for(int i = 1; i <= n; i++) {
		sum[i] = sum[i - 1] + node[i].h;
	}
	LL l = 0, r = 4e18;
	while(l < r) {
		LL mid = (l + r) >> 1;
		if(check(mid)) {
			r = mid;
		}
		else {
			l = mid + 1;
		}
	}
	printf("%lld\n", r);
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long int ll;

int N, x;
vector<int> a;
ll ans;

int main(void) {
	cin >> N >> x;
	a.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> a[i];

	ans = 0;
	if (a[0] > x) {
		ans = a[0] - x;
		a[0] = x;
	}

	for (int i = 1; i < N; ++i) {
		int y = a[i] + a[i - 1];
		if (y > x) {
			ans += (y - x);
			a[i] = max(a[i] - (y - x), 0);
		}
	}
	
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 640
#include <cmath>
#include <iostream>
#include <iterator>
#include <queue>
#include <vector>

using namespace std;

queue<vector<unsigned long long> > que;

void insert_plus(string str) {
  vector<unsigned long long> v0(1, str[0]-'0'+0);
  que.push(v0); 
  for (int i = 1; i < str.length(); i++) {
    int app = str[i]-'0'+0;
    for (int j = 0; j < pow(2, i-1); j++) {
      vector<unsigned long long> v = que.front();
      que.pop();
      vector<unsigned long long> v_t1, v_t2;
      copy(v.begin(), v.end(), back_inserter(v_t1));
      copy(v.begin(), v.end(), back_inserter(v_t2));

      unsigned long long t = v_t1[v_t1.size()-1];
      v_t1[v_t1.size()-1] = t*10+app;

      v_t2.push_back(0-'+');
      v_t2.push_back(app);

      que.push(v_t1);
      que.push(v_t2);
    }
  }
  return;
}

vector<unsigned long long> ans;
void calc_ans() {
  while (!que.empty()) {
    vector<unsigned long long> eq = que.front();
    que.pop();
    unsigned long long a = 0;
    for (int i = 0; i < eq.size(); i++) {
      if (eq[i] != 0-'+') {
	a += eq[i];
      }
    }
    ans.push_back(a);
  }
  return;
}

int main(int argc, char* argv[]) {
  string S;
  cin >> S;

  insert_plus(S);
  calc_ans();

  unsigned long long total = 0;
  for (unsigned long long i = 0; i < ans.size(); i++) {
    total += ans[i];
  }

  cout << total << endl;
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
using namespace std;
long double ans;
int n;
int main(){
	cin>>n;
	int f=(n+1)/2;
	ans=((long double)(f)/(long double)(n));
	cout<<ans;
	re 0;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(auto &I:a){cin>>I;}
    string s;
    ll w=0;
    stack<ll> S;
    for(int i=0;i<n;i++){
        while(w<a[i]){w++; s.push_back('('); S.push(w);}
        if(S.empty() || S.top()!=a[i]){cout<<":("<<endl; return 0;}
        s.push_back(')');
        S.pop();
    }
    if(!S.empty()){cout<<":("<<endl; return 0;}
    cout<<s<<endl;
    
    
    
    
    
    return 0;
}



Measured memory_bytes: 4240
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}


int main(){// 全探索：全列挙 4　パ研杯2019 C - カラオケ　これが解ければ全探索に慣れたと思って良いです。
	ll A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	
	ll ans = 100100100100100;
	int larger_num = max(X, Y);
	for(int i=0;i<=larger_num * 2; i++){
		//if( (X - i/2) < 0 || (Y - i/2) < 0) continue;
		ll money = i * C;//ABピザをi枚買う
		if( (X - i/2) > 0) money += ( X - i/2 ) * A;
		if( (Y - i/2) > 0) money += ( Y - i/2 ) * B;
		ans = min(ans, money);
		//if(money == 100000000)cout << " A: " << (X-i/2) << " B: " << (Y-i/2) << " C: " << i << endl;
	}
	cout << ans << endl;
	
	//以下のやり方だと，AもBも必要最小限の枚数になるが，値段が最小とは限らない
	// ll min_num = min(X, Y);//AとBをそれぞれmin_num枚買うか,Cを2*min_num枚買うか 
	// ll money = min( (A + B)*min_num, 2*C*min_num);
	// ll left_num = max(X, Y) - min_num;
	// if(X > Y) money += A * left_num;
	// else money += B * left_num;
	// cout << money << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long

void solve() {
	int n; string s;
	cin >> n >> s;
	int i = 0;
	if(s.size() <= n) {
		cout << s << endl;
	}
	else{
		for(int i=0; i<n; i++) {
			cout << s[i];
		}
		cout << "...";
	}
}

int main(){
	FAST(); 
	int t; 
	t = 1; 
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <unordered_set>

using namespace std;

unordered_set<int> vec[200003];

int main() {

    ios::sync_with_stdio(false);

    int n,m;
    cin >> n >> m;

    int a,b;

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

        cin >> a >> b;
        vec[a].insert(b);
        vec[b].insert(a);

    }

    for(unordered_set<int>::iterator it = vec[1].begin(); it != vec[1].end(); it++) {

        if(vec[*it].find(n) != vec[*it].end()) {

            cout << "POSSIBLE";
            return 0;

        }

    }

    cout << "IMPOSSIBLE";

    return 0;
}


Measured memory_bytes: 31944
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

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

    int x;
    cin >> x;
    cout << x / 3600 << ":";
    x %= 3600;
    cout << x / 60 << ":";
    x %= 60;
    cout << x << endl;

}

Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define F(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define FD(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define pii pair<int,int>
#define reset(x,y) memset(x, y,sizeof(x))
#define MIN(x,y) if (x > (y)) x = (y)
#define MAX(x,y) if (x < (y)) x = (y)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define EL putchar('\n');
#define mod 1000000007
#define oo 300
int read()
{
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
void write(int x)
{
    if (x > 9) write(x / 10);
    putchar(x % 10 + '0');
}
int n;
int a[oo],mina=1e6;
int f[100005],k;
void ReadInPut()
{
    n=read();
    k=read();
    F(i,1,n){a[i]=read();MIN(mina,a[i]);}
    if(n==1)
    {
        if((k/a[1])%2)cout<<"First";
        else cout<<"Second";
        exit(0);
    }
}
void Solve()
{
    F(i,mina,k)
    {
        int ok=0;
        F(j,1,n)
        {
            if(i<a[j])continue;
            ok=1-f[i-a[j]];
            if(ok)break;
        }
        f[i]=ok;
    }
    if(f[k])cout<<"First";
    else cout<<"Second";
}
main()
{
//    freopen("t.INP","r",stdin);
  //  freopen(".OUT","w",stdout);
    int sotest=1;
    //cin>>sotest;
    for(int i=1;i<=sotest;i++)
    {
        ReadInPut();
        Solve();
    }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
const int queue_max_size = 100000;
template<class T>
class Queue{
  private:
    int head;
    int tail;
    T Q[queue_max_size];
  public:
    Queue(){
      head = tail = 0;
    }
    bool isEmpty(){
      return head == tail;
    }
    bool isFull(){
      return head == (tail + 1) % queue_max_size;
    }
    void push(T x){
      if(isFull()){
        cout << "Error Full" <<endl;
        assert(!isFull());
      }
      Q[tail] = x;
      tail = (tail + 1) % queue_max_size;
    }
    T front(){
      if(isEmpty()){
        cout << "Error Empty" <<endl;
        assert(!isEmpty());
      }
      return Q[head];
    }
    void pop(){
      if(isEmpty()){
        cout << "Error Empty" <<endl;
        assert(!isEmpty());
      }
      head = (head + 1) % queue_max_size;
    }
};
//-----------------------------------------
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n, q;
  cin >> n >> q;
  int time = 0;
  Queue<pair<string, int>> que;
  for(int i=0;i<n;i++){
    string s;
    int t;
    cin >> s >> t;
    que.push(MP(s,t));
  }

  while(!que.isEmpty()){
    pair<string,int> tmp;
    tmp = que.front();
    que.pop();

    if(tmp.second>q){
      tmp.second -= q;
      que.push(tmp);
      time += q;
    }
    else{
      time += tmp.second;
      cout << tmp.first <<" " << time <<endl;
    }
  }
    
  return 0;
}



Measured memory_bytes: 7020
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		WriteLine(GetInt() == GetInt() ? "Yes" : "No");
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 11092
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[][] gridA = new int[h][w];
		int[][] gridB = new int[h][w];
		for(int i = 0; i < h; i++){
		    for(int j = 0; j < w; j++){
		        gridA[i][j] = sc.nextInt();
		    }
		}
		for(int i = 0; i < h; i++){
		    for(int j = 0; j < w; j++){
		        gridB[i][j] = sc.nextInt();
		    }
		}
		int[][] gridAbs = new int[h][w];
		for(int i = 0; i < h; i++){
		    for(int j = 0; j < w; j++){
		        gridAbs[i][j] = abs(gridA[i][j] - gridB[i][j]);
		    }
		}
		
		// 計算
		int result = 0;
		boolean[][][] dp = new boolean[h][w][100*160];
		dp[0][0][gridAbs[0][0]] = true;
		for(int i = 0; i < h; i++){
		    for(int j = 0; j < w; j++){
		        for(int k = 0; k < 100*160; k++){
		            if(dp[i][j][k]){
		                if(i < h-1) dp[i+1][j][k + gridAbs[i+1][j]] = true;
		                if(i < h-1) dp[i+1][j][abs(k - gridAbs[i+1][j])] = true;
		                if(j < w-1) dp[i][j+1][k + gridAbs[i][j+1]] = true;
		                if(j < w-1) dp[i][j+1][abs(k - gridAbs[i][j+1])] = true;
		            }
		        }
		    }
		}
		for(int k = 0; k < 100*160; k++){
		    if(dp[h-1][w-1][k]){
		        result = k;
		        break;
		    }
		}
		
		// 出力
		System.out.println(result);
	}
}


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

int main(){
  int l,r,d;
  cin >> l >> r >> d;
  int ans = 0;
  for(int i = l; i <= r; i++){
    
    if(i % d == 0){
      ans ++;
    }
  }
  cout << ans  << endl;
}

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

int main(){
  int n, s;
  s = 0;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  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++){
        if(a[i] + a[j] > a[k])
          s++;
        else
          break;
      }
    }
  }
  cout << s << endl;
}

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

using namespace std;

int main(void){
	int n, T;

	cin >> n >> T;

	vector<int> t(n+1);

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

	t[n] = 2e9;


	long long int sum = 0;


	for (int i = 0; i < n; i++){
		if (t[i+1] - t[i] > T){
			sum += T;
		}
		else {
			sum += t[i+1] - t[i];
		}
	}


	cout << sum << endl;
}

Measured memory_bytes: 1024
#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;
template<typename T> using VP = vector<pair<T, T>>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }
#pragma endregion

signed main()
{
    char a;
    cin >> a;

    if (a >= 'a' && a <= 'z') col('a');
    else col('A');

    return 0;
}


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N=in();
    int sum;sum=0;
    int m;
    REP1(i,N){
        sum+=i;
        if(sum>N){
            m=i-1;
            sum-=i;
            break;
        }
        if(sum==N){
            REP1(j,i)print(j);
            return 0;
        }
    }
    //debug(sum);
    //debug(m);
    REP1(i,m){
        if(i<=(m-(N-sum))){
            print(i);
        }else{
            cout<<i+1<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
    
        char[] s = new char[S.length()];
        char[] t = new char[T.length()];
        int[] ans = new int[S.length() - T.length() + 1];
        int num = 0;
    
        for(int i = 0;i < S.length(); i++){        
           s[i] = S.charAt(i);
        }
        
        for(int i = 0;i < T.length(); i++){        
           t[i] = T.charAt(i);
        }
        
        int h;
        
        for(int i = 0; i < S.length() - T.length() + 1; i++){
            h = i;
            num = 0;
            for(int n = 0 ; n < T.length(); n++){        
                if(s[h]==t[n]){
                }else{
                num++;
                }
                h++;
            }
            ans[i] = num;
        }
        
        int min      = ans[0];
        for (int index = 1; index < ans.length; index ++) {
            min = Math.min(min, ans[index]);
        }
        
        System.out.println(min);
    }
}

Measured memory_bytes: 27312
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A = A[::-1]
B = B[::-1]

ans = 0
for a, b in zip(A, B):
    a += ans
    if a % b != 0: 
        m = b - (a % b) 
        ans += m
print(ans)

Measured memory_bytes: 11836
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
	long long int X,Y,s=0;
	cin>>X>>Y;
	for(int i=0;i<10000;i++){
		X=X*2;
		if(X>Y){
			break;
		}
		s++;
	}
	cout<<s+1<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

#define MAX_V 200000

typedef pair<long long int, long long int> P;
long long int INF = 1e18;



int main(){
	
	queue<string> que;
	
	map<string, int> m;
	
	string fs = "";
	
	for(int i = 0; i < 9; i++){
		string s;
		cin >> s;
		fs += s;
	}
	
	que.push(fs);
	
	for(int loop = 0; loop < 1000; loop++){
		if(que.empty()){
			break;
		}
		int sz = que.size();
		for(int num = 0; num < sz; num++){
			string str = que.front();
			que.pop();
			if(m.find(str) != m.end()){
				continue;
			}
			m[str] = loop;
			for(int i = 0; i < 9; i++){
				if(str[i] == '0'){
					if(i >= 3){
						swap(str[i], str[i - 3]);
						que.push(str);
						swap(str[i], str[i - 3]);
					}
					if(i < 6){
						swap(str[i], str[i + 3]);
						que.push(str);
						swap(str[i], str[i + 3]);
					}
					if(i % 3 > 0){
						swap(str[i], str[i - 1]);
						que.push(str);
						swap(str[i], str[i - 1]);
					}
					if(i % 3 < 2){
						swap(str[i], str[i + 1]);
						que.push(str);
						swap(str[i], str[i + 1]);
					}
				}
			}
		}
	}
	
	cout << m["123456780"] << endl;
	
	return 0;
}


Measured memory_bytes: 24320
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
int read()
{
	char c=getchar();
	int res=0;
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') res=(res<<1)+(res<<3)+(c^48),c=getchar();
	return res;
}
int n,mv[200005],h[200005],cnt,a[200005],sizes[200005],num[200005],ans[200005];
struct Edge
{
	int to,next;
}w[400005];
void add(int x,int y)
{
	w[++cnt]=(Edge){y,h[x]};
	h[x]=cnt;
}
void dfs2(int x,int fa,int v)
{
	num[x]=1;
	for(int i=h[x];i;i=w[i].next)
	{
		int to=w[i].to;
		if(to==fa||to>=v) continue;
		dfs2(to,x,v);
		num[x]+=num[to];
	}
}
void dfs(int x,int fa)
{
	mv[x]=max(mv[fa],x);
	sizes[x]=1;
	for(int i=h[x];i;i=w[i].next)
	{
		int to=w[i].to;
		if(to==fa) continue;
		dfs(to,x);
		a[x]+=a[to];sizes[x]+=sizes[to];
	}
	if(mv[x]==x) dfs2(x,fa,mv[fa]),a[x]=-sizes[x];
	if(mv[fa]==fa) a[x]+=sizes[x];
}
void dfs3(int x,int fa)
{
	if(fa)
	{
		if(mv[x]==x) ans[x]+=num[x];
		else if(mv[fa]==fa) ans[x]-=num[x],ans[x]+=a[x];
		ans[x]+=ans[fa];
	}
	for(int i=h[x];i;i=w[i].next)
	{
		int to=w[i].to;
		if(to==fa) continue;
		dfs3(to,x);
	}
}
int main()
{
	n=read();
	for(int i=1;i<n;i++)
	{
		int x=read(),y=read();
		add(x,y),add(y,x);
	}
	dfs(1,0);
	dfs3(1,0);
	for(int i=2;i<=n;i++) printf("%d ",ans[i]);
}

Measured memory_bytes: 26296
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a<b && b<c)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }



    return 0;
}

Measured memory_bytes: 3092
N,K = map(int,input().split())
P = list(map(int,input().split()))

summ = sum(P[0:K])
maxi = summ
idx = 0
ans = []
for i in range(N-K):
    summ = summ - P[i] + P[K+i]
    if summ > maxi:
        maxi = summ
        idx = i+1
for j in range(K):
    ans.append((P[idx+j]+1)/2)
print(sum(ans))

Measured memory_bytes: 24548
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
      
N, M = map(int, input().split())
XYZs = [list(map(lambda x: int(x)-1, input().split())) for _ in range(M)]

uf = UnionFind(N)

for XYZ in XYZs:
    uf.union(XYZ[0], XYZ[1])

print(uf.group_count())

Measured memory_bytes: 96680
# coding: utf-8
# Your code here!

import sys

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

    # divisors.sort()
    return divisors

N, X = map(int, input().rstrip().split(' '))
x = sorted(list(map(int, input().rstrip().split(' '))) + [X])

difs = []
for i in range(len(x)-1):
    difs.append(x[i + 1] - x[i])
  
min_dif = min(difs)
divisors = sorted(make_divisors(min_dif))[::-1]

for divisor in divisors:
    flag = False
    for dif in difs:
        if dif % divisor != 0:
            flag = True
            break
    if flag == False:
        print(divisor)
        break


Measured memory_bytes: 14480
// By Atul Rathore
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double x = 6.0 * m;
	double y = (double)h * 30.0 + (double)(m / 2.0);
	double we = abs(x - y);
	we /= 180.0;
	we *= 3.14159265358979323846264;
	double z = pow(a, 2) + pow(b, 2) - 2.0 * a * b * cos(we);
	double r = sqrt(z);
	cout << fixed << setprecision(15) << r;


}


Measured memory_bytes: 4308
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<vector<int>> vvi;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define umap unordered_map


int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	string s, t; cin >> s >> t;
	int m = isize(s), n = isize(t);
	vvi dp = vvi(m, vi(n, INF));
	dp[0][0] = s[0] == t[0] ? 1 : 0;
	for(int r = 1; r < m; r++){
		dp[r][0] = max(dp[r-1][0], s[r] == t[0] ? 1 : 0);
	}
	for(int c = 1; c < n; c++){
		dp[0][c] = max(dp[0][c-1], s[0] == t[c] ? 1 : 0);
	}
	for(int r = 1; r < m; r++){
		for(int c = 1; c < n; c++){
			dp[r][c] = max(dp[r-1][c], dp[r][c-1]);
			if (s[r] == t[c]){
				dp[r][c] = max(dp[r][c], 1 + dp[r-1][c-1]);
			}
		}
	}
	deque<char> ans = deque<char>();
	int r = m-1, c = n-1;
	while(r >= 0 and c >= 0){
		if(s[r] == t[c]){
			ans.push_front(s[r]);
			r--; c--;
		}else{
			int U = r > 0 ? dp[r-1][c] : NINF;
			int L = c > 0 ? dp[r][c-1] : NINF;
			if (U >= L){
				r--;
			}else{
				c--;
			}
		}
	}
	for (const char& cr : ans){
		cout << cr;
	}
}

Measured memory_bytes: 38576
def main():
    n = int(input())
    maxCakes = n // 4
    maxDonuts = n // 7
    res = 'No'
    for c in range(maxCakes+1):
        for d in range(maxDonuts+1):
            if 4*c + 7*d == n:
                res = 'Yes'
    print(res)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll H, W, N, sr, sc;
    cin >> H >> W >> N >> sr >> sc;
    string S, T;
    cin >> S >> T;

    map<char, ll> tak, aok;
    
    ll U = sr;
    ll D = H - sr + 1;
    ll L = sc;
    ll R = W - sc + 1;
    
    string ans = "YES";
    rep(i, 0, N){
        tak[S[i]]++;
        if(tak['U'] - aok['D'] >= U) ans = "NO";
        if(tak['D'] - aok['U'] >= D) ans = "NO";
        if(tak['L'] - aok['R'] >= L) ans = "NO";
        if(tak['R'] - aok['L'] >= R) ans = "NO";
        if(T[i] == 'U' && aok['U'] + 1 < U + tak['D']) aok[T[i]]++;
        if(T[i] == 'D' && aok['D'] + 1 < D + tak['U']) aok[T[i]]++;
        if(T[i] == 'L' && aok['L'] + 1 < L + tak['R']) aok[T[i]]++;
        if(T[i] == 'R' && aok['R'] + 1 < R + tak['L']) aok[T[i]]++;
        if(ans == "NO") break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 900
// abc158_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string S;
    cin >> S;

    int Q;
    cin >> Q;

    deque<char> ans;
    REP(i, S.size()) ans.emplace_back(S[i]);

    bool dir = true;
    REP(i, Q){
        int t; cin >> t;
        if (t == 1) {
            dir = not dir;
        } else {
            int f; char c;
            cin >> f >> c;

            if (dir == (f == 1)){
                ans.emplace_front(c);
            } else {
                ans.emplace_back(c);
            }
        }
    }

    if (not dir){
        reverse(ALL(ans));
    }

    string ans_s;
    for (auto c: ans) ans_s += c;

    print(ans_s);


    return 0;
}


Measured memory_bytes: 1368
import java.util.* ; 

 class Main {
     static long dp[][] = new long[101][100001] ; 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in) ;
        int n = sc.nextInt() ; 
        int w = sc.nextInt() ; 
        long wt[] = new long[n] ; 
        long val[] = new long[n] ; 
        for(int i=0 ; i<n ; i++){
            wt[i] = sc.nextLong() ; 
            val[i] = sc.nextLong() ; 
        }
        for(int i=0 ; i<=n ; i++){
            for(int j=0 ; j<=w ; j++){
                dp[i][j] = -1 ; 
            }
        }
        System.out.println(knapSack(val, wt, n, w));

    }

    static long knapSack(long val[],long wt[],int n, int w){
        if(n==0 || w==0){
            return dp[n][w]=0 ; 
        }
        if(dp[n][w]!=-1){
            return dp[n][w] ; 
        }

        else if(wt[n-1]>w){
           return dp[n][w]=knapSack(val, wt, n-1, w) ; 
        } 
        else{
            return dp[n][w] =  Math.max(val[n - 1] + knapSack(val, wt, n - 1, w - (int)wt[n - 1]), knapSack(val, wt, n - 1, w));
        }
    }
}


Measured memory_bytes: 139740
//--------------------------------------------------template----------------------------------------//
//c
#include <stdio.h>
#include <time.h>
#include <math.h>
//c++
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <complex>
#include <cmath>
//c++11
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
//#define sort(v,n) sort(v,v+n)
//#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.rbegin(),v.rend())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n;

int main() {
	cin >> n;
	ll now = 100000;
	for (int i = 0; i < n; i++) {
		now = now + now*0.05;
		if (now % 1000 != 0) {
			now /= 1000;
			now++;
			now *= 1000;
		}
	}
	cout << now << endl;
	return 0;
}

Measured memory_bytes: 3076
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
#include<string>
#include <cmath>

using namespace std;

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


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

    int a,b,c,d;
    cin >> a >> b >> c >> d;

    if(abs(a-c) <= d || abs(a-b) <= d && abs(b - c) <= d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}





Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();

        int[] charCounts = new int[256];
        foreach (char c in s)
        {
            int index = c - 'a';
            charCounts[index] += 1;
        }

        ulong pairs = 0;
        foreach (int x in charCounts)
        {
            if (x > 1)
            {
                pairs += (ulong)x * (ulong)(x - 1) / 2;
                Console.Error.WriteLine("Pairs is now {0} after x = {1}", pairs, x);
            }
        }

        ulong max = (ulong)s.Length * (ulong)(s.Length - 1) / 2;
        ulong answer = max - pairs + 1;

        Console.Error.WriteLine("max: {0}, pairs: {1}", max, pairs);

        Console.WriteLine(answer);
        Console.ReadLine();
    }
}



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

int main()
{
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i++)
    {
        for (int j = i + 1; j < S.size(); j++)
        {
            if (S[i] == S[j])
            {
                cout << "no" << endl;
                return 0;
            }
        }
    }
    cout << "yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  string s;
  cin >> s;
  vector<vector<LL>> dp(s.size()+1,vector<LL>(13));
  dp[0][0] = 1;
  REP(i,s.size()) REP(j,13) {
    dp[i][j] %= p;
    if(s[i] == '?') REP(k,10) dp[i+1][(j*10+k)%13] += dp[i][j];
    else dp[i+1][(j*10+s[i]-'0')%13] += dp[i][j];
  }
  cout << dp[s.size()][5]%p << endl;
  return 0;
}


Measured memory_bytes: 13696