akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	//数値の入力
		int h = sc.nextInt();
      	int n = sc.nextInt();
      	//配列
      	List<Integer> list = new ArrayList<>();
        for(int i = 0; i < n; i++){
        	list.add(sc.nextInt());
        }
      	//1回ずつ必殺技を使いHPを減らす
      	for(int i=0; i<n; i++) {
      	h -= list.get(i);
        }
      if(h <= 0) {
        System.out.println("Yes");       
      }else{
        System.out.println("No");    
      }
     }
}

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

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    for (int i = 0; i < k; i++)
    {
        if (a >= b)
        {
            b *= 2;
        }
        else
        {
            c *= 2;
        }
    }
    if (a < b && b < c && a < c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

typedef long long int ll;
ll dp[3009][3009];
char str[3009][3009];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s,t;
	cin>>s;
	
	cin>>t;
	
	ll l1,l2;
	l1=s.length();
	l2=t.length();
	ll i,j;
	
	for(i=0;i<=max(l1,l2);i++)
	{
		dp[0][i]=0;
		dp[i][0]=0;
	}
	for(i=1;i<=l1;i++)
	{
		for(j=1;j<=l2;j++)
		{
			if(s[i-1]==t[j-1])
			{
			dp[i][j]=1+dp[i-1][j-1];str[i][j]=s[i-1];
			}
			else
			{
			if(dp[i-1][j]>dp[i][j-1])
			{
				dp[i][j]=dp[i-1][j];
				str[i][j]=str[i-1][j];
			}
			else
			{
				dp[i][j]=dp[i][j-1];
				str[i][j]=str[i][j-1];
			}
			}
			//cout<<dp[i][j]<<" ";
		}
		//cout<<endl;
	}
	i=l1;j=l2;
	vector <char> vec;
	while(i>0 && j>0)
	{
		if(dp[i][j]==dp[i-1][j])
		{
			i=i-1;
		}
		else if(dp[i][j]==dp[i][j-1])
		{
			j=j-1;
		}
		else if(dp[i][j]==1+dp[i-1][j-1])// && s[i-1]==t[j-1])
		{	
			vec.push_back(str[i][j]);		
			i=i-1;j=j-1;
			
		}
		
		
	}
	reverse(vec.begin(),vec.end());
	//cout<<vec.size()<<" ";
	for(auto it:vec)
	{
		cout<<it;
	}
}


Measured memory_bytes: 79616
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int M, D;
    cin >> M >> D;
    int ans = 0;
    for (int m = 1; m <= M; ++m) {
        for (int d = 1; d <= D; ++d) {
            if (d >= 10) {
                int d1 = d % 10;
                int d10 = d / 10;
                if (d1 >= 2 && d10 >= 2 && d1 * d10 == m) ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3664
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	int a = N % 1000;
	if(a == 0){
		cout << 0 << endl;
	}else{
		cout << 1000-a << endl;
	}
	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;

int main(void) {
    Int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c) {
        cout << 1 << endl;
    } else if (a == b || b == c || c == a) {
        cout << 2 << endl;
    } else {
        cout << 3 << endl;
    }
    return 0;
}


Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.*;
public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        String s = reader.readLine();
        
        String arr[]=s.split(" ");
        
        int a = Integer.valueOf(arr[0]);
        int b = Integer.valueOf(arr[1]);
        
        System.out.println(Math.max(Math.max(a+b,a-b),a*b));
        
        
    }

}





Measured memory_bytes: 20564
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val n = in.readLine().toLong

    var min = Integer.MAX_VALUE
    for (i <- 1 to Math.sqrt(n).toInt) {
      if (n % i == 0) {
        min = Math.min(min, Math.max(Math.log10(n / i).toInt, Math.log10(i).toInt) + 1)
      }
    }

    out.println(min)

    out.flush()
  }
}


Measured memory_bytes: 25380
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
typedef pair<long long, long long> P;
bool IsPrime(long long N) {
    for (long long i = 2; i * i <= N; i++) {
        if (N % i == 0) return false;
    }
    return true;
}
vector<P> prime_factorization (long long N) {
    vector<P> A;
    long long tmp = N;
    for (long long i = 2; i * i <= N; i++) {
        if (N % i == 0 && IsPrime(i)) {
            A.push_back(make_pair(i, 0));
            while (tmp % i == 0) {
                A.back().second++;
                tmp /= i;
            }
        }
    }
    if (tmp != 1) A.push_back(make_pair(tmp, 1));
    return A;
}

int main() {
    long long N; cin >> N;
    vector<P>A = prime_factorization(N);
    long long ans = 0;
    for (long long i = 0; i < A.size(); i++) {
        long long j = 1;
        while (A.at(i).second >= j) {
            ans++;
            A.at(i).second -= j;
            j++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3576
import numpy as np
def s():
    return raw_input()
def li():
    return map(int,raw_input().split())

st = []
X = list(s())
N = len(X)
X.reverse()
st.append(X[-1])
X.pop()
#for i in range(len(X)-2):
for i in range(N-1):
    st.append(X[-1])
    X.pop()
    if len(st) >= 2:
        if st[-1] == 'T' and st[-2] == 'S':
            st.pop()
            st.pop()
print len(st)



Measured memory_bytes: 20064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


// int factrial(int n){
//   if(n == 0) return 1;
//   return n*factrial(n-1);
// }

// int divisor(int a){
//   int cnt = 0;
//   for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
//   return cnt;
// }

// int comb(int n, int k){
//   return fact(n) / (fact(n-k)*fact(k));
// }

int answer(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


int main(){
  int a[3];
  rep(i,3) cin >> a[i];
  sort(a,a+3);
  cout << a[2] - a[0] << endl;;
}
  





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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> adj_list(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        adj_list[a].push_back(b);
        adj_list[b].push_back(a);
    }
    if (m % 2 == 1) {
        cout << -1 << endl;
        return 0;
    }
    vector<int> dfs_num(n, -1);
    vector<int> edge_count(n, 0);
    vector<pair<int, int>> result;
    int num_visited = 0;
    function<void (int)> dfs = [&](int i) {
        dfs_num[i] = num_visited++;
        int count = 0;
        for (int j : adj_list[i]) {
            if (dfs_num[j] == -1) {
                dfs(j);
                count += edge_count[j] + 1;
                if (edge_count[j] % 2 == 0) {
                    result.push_back(make_pair(i, j));
                } else {
                    result.push_back(make_pair(j, i));
                }
            } else if (dfs_num[j] > dfs_num[i]) {
                result.push_back(make_pair(i, j));
                ++count;
            }
        }
        edge_count[i] = count;
    };
    dfs(0);
    for (auto edge : result) {
        cout << edge.first+1 << " " << edge.second+1 << "\n";
    }
    return 0;
}


Measured memory_bytes: 21108
#include <stdio.h>

int main(void){
	
	int a;
	int b;
	int ans1;
	int ans2;
	
	scanf("%d %d",&a,&b);
	
	ans1 = 2 * (a + b);
	ans2 = a * b;
	printf("%d %d\n",ans2,ans1);
	
	
	return 0;
	
}

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

int main()
{
  long long int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0;i < n;i++)
  {
    cin >> a[i];
  }
  reverse(a.begin(), a.end());
  for(int i = 0;i < n;i++)
  {
    cout << a[i];
    if(i != n-1) cout << " ";
  }
  cout << endl;
  return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const ll LINF = (ll)INF * INF;
const int MOD = 1000000007;

vector<int> G[MAX];
int A[MAX];
int ans[MAX];

void dfs(int v, int p, vector<ll> &dp) {
    auto itr = lower_bound(dp.begin(), dp.end(), A[v]);
    ll pre = *itr;
    *itr = A[v];
    int res = lower_bound(dp.begin(), dp.end(), LINF) - dp.begin() - 1;
    ans[v] = res;
    for (int u : G[v]) {
        if (u == p) continue;
        dfs(u, v, dp);
    }
    *itr = pre;
}

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

    rep(i, N) cin >> A[i];

    rep(i, N-1) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }

    vector<ll> dp(N+1, LINF);
    dp[0] = 0;
    dfs(0, -1, dp);

    rep(i, N) cout << ans[i] << endl;
}

Measured memory_bytes: 31680
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin >> n;
    for (int i = 0; i * 4 <= n; i++) {
    	if ((n - 4 * i) % 7 == 0) {
    		cout << "Yes" << endl;
    		return 0;
    	}
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)

int extgcd(int a,int b,int &x,int &y){
	int g=a;
	x=1,y=0;
	if(b!=0){
		g=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}
	return g;
}
 
// 逆元
int mod_inverse(int a,int m){
	int x, y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}
 
// 階乗
std::vector<int>fact;
void mod_fact(int n, int m){
	fact.resize(n+1);
	fact[0]=1;
	for(int i=1;i<=n;i++){
		fact[i]=fact[i-1]*i%m;
	}
}
 
// nCk mod p
int mod_nCr(int n, int k, int m){
	if(n<k)return 0;
	return fact[n]*mod_inverse(fact[k]*fact[n-k]%m,m)%m;
}

int mod_pow(int b,int e,int m){
    if(e==0){
        return 1;
    }else{
        int sum = mod_pow(b,e/2,m);
        if(e%2==0){
            return (sum*sum)%m;
        }else{
            return (((sum*sum)%m)*b)%m;
        }
    }
}

int H,W,A,B;
int factm[200010];
int ans=0;

int moving(int x1,int y1,int x2,int y2){
	return mod_nCr(x2-x1+y2-y1,x2-x1,MOD);
}

signed main(){
	cin>>H>>W>>A>>B;
	mod_fact(200010,MOD);
	int ans=0;
	for(int i=B;i<W;i++){
		int dim=1;
		dim=moving(0,0,H-A-1,i);
		dim%=MOD;
		dim*=moving(H-A,i,H-1,W-1);
		dim%MOD;
		ans+=dim;
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(1, n-1):
  p1, p2, p3 = p[i-1], p[i], p[i+1]
  if p1 < p2 < p3 or p3 < p2 < p1:
    count += 1
print(count)

Measured memory_bytes: 9100
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if ( a-b > c ) {
			System.out.println(0);
		}else {
			System.out.println(c+b-a);			
		}
		
		sc.close();
	}

}

Measured memory_bytes: 21716
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt(), D = in.nextInt() * 2 + 1;
        System.out.println(N / D + (N % D == 0 ? 0 : 1));
    }
}

Measured memory_bytes: 21844
#import sys
from heapq import heapify, heappushpop
from heapq import _heapify_max as heapify_max, _siftup_max


def heappushpop_max(heap, item):
    if heap and heap[0] > item:
        item, heap[0] = heap[0], item
        _siftup_max(heap, 0)
    return item


# fin = sys.stdin.readline
N, *a_list = map(int, open(0).read().split())

left_pq = a_list[:N]
right_pq = a_list[2 * N:]
heapify(left_pq)
heapify_max(right_pq)

left_sum = [sum(left_pq)]
right_sum = [sum(right_pq)]
for k in range(N, 2 * N):
    left_item = a_list[k]
    right_item = a_list[-k - 1]
    left_sum.append(left_sum[-1] - heappushpop(left_pq, left_item) + left_item)
    right_sum.append(right_sum[-1] - heappushpop_max(right_pq, right_item) + right_item)

max_sum = max(map(sum, zip(left_sum, [-item for item in right_sum[::-1]])))
print(max_sum)


Measured memory_bytes: 40164
#define FNAME ""

#ifdef LOCAL
    #define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

#define hash padjf9srpi
#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forn(i, n) for (int i = 0; i < (n); i++)
#define fornr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define forab(i, a, b) for (int i = (a); i < (b); i++)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
 
#ifdef _WIN32
    #define I64 "%I64d"
#else
    #define I64 "%lld"
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;                                                                                                                                                                                      
typedef vector <int> vi;

template <class T> T sqr(const T &a) {return a * a;}

char s[100];


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

#ifdef LOCAL
    freopen(FNAME".in", "r", stdin);
    freopen(FNAME".out", "w", stdout);
#endif

    scanf("%s", s);
    int n = strlen(s);
    if (n >= 4 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
        puts("Yes");
    }else puts("No");
}
    




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n;
  cin >> n;
  
  ll profit = -LLONG_MAX, buy;
  cin >> buy;
  rep(i, n - 1) {
    ll r;
    cin >> r;
    
    if (r - buy > profit) {
      profit = r - buy;
    }

    buy = min(buy, r);
  }

  cout << profit << endl; 
}



Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
int main() {
  int n,m; cin>>n>>m;
  vector<vector<int>> g(n);
  vector<int> d(n, -1);
  for (int i = 0; i < m; i++) {
    int a,b; cin >>a>>b; a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  queue<int> q;
  q.push(0);
  while (1){
    if(q.empty()) break;
    int qf=q.front();q.pop();
    for(auto i:g[qf]){
      if(d[i]!=-1) continue;
      q.push(i);
      d[i]=qf;
    }
  }
  cout << "Yes" << endl;
  for (int i = 1; i < n; i++) {
    cout << d[i] + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 10200
#include <iostream>
#include <vector>
using namespace std;
#define NUM 100000
int main( void )
{
	vector <bool> is_prime( NUM+1, false );
	is_prime[2] = true;
	for ( int i = 3; i < NUM; i += 2 )
	{
		is_prime[i] = true;
	}
	for ( int i = 3; i < NUM; i += 2 )
	{
		if ( is_prime[i] )
		{
			for ( int j = i+i; j < NUM; j += i )
			{
				is_prime[j] = false;
			}
		}
	}

	int n;
	while ( cin >> n )
	{
		for ( int i = n-1; i >= 2; i-- )
		{
			if ( is_prime[i] )
			{
				cout << i << " ";
				break;
			}
		}

		for ( int i = n+1; i <= NUM; i++ )
		{
			if ( is_prime[i] )
			{
				cout << i << endl;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define pi pair<int,int>
#define mp make_pair
//#define int long long
#define endl '\n'
 
using namespace std;
int n,k,l;
 
int idrd[(int)2.1e5],idral[(int)2.1e5];
 
void initialize()
{
    for(int i = 1;i <= n;++i)
        idrd[i] = i,idral[i]=i;
}
 
int rootroad(int x)
{
    while(idrd[x] != x)
    {
        idrd[x] = idrd[idrd[x]];
        x = idrd[x];
    }
    return x;
}
 
int rootrail(int x)
{
    while(idral[x] != x)
    {
        idral[x] = idral[idral[x]];
        x = idral[x];
    }
    return x;
}
 
 
void unionrd(int x, int y)
{
    int p = rootroad(x);
    int q = rootroad(y);
    idrd[p] = idrd[q];
}
 
void unionrail(int x, int y)
{
    int p = rootrail(x);
    int q = rootrail(y);
    idral[p] = idral[q];
}
vector< pair<pi,int> > s;
 
int ans[200005];
 
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>n>>k>>l;
    int x,y;
    initialize();
    for(int i=0;i<k;++i)
    {
        cin>>x>>y;
 
        unionrd(x,y);
    }
    for(int i=0;i<l;++i)
    {
        cin>>x>>y;
 
 
        unionrail(x,y);
    }
    for(int i=1;i<=n;++i)
    {
        pair<pi,int> xp= mp(mp(rootrail(i),rootroad(i)) , i);
        s.push_back(xp);
    }
   sort(s.begin(),s.end());
    for(int i=1;i<=n;++i)
    {
        pi xp= mp(rootrail(i),rootroad(i));
 
        // a1=distance(s.begin(),s.lower_bound(mp(xp,0)));
        auto a1=lower_bound(s.begin(),s.end(),mp(xp,0));
        //int a2=distance(s.begin(),s.upper_bound(mp(xp,312345)));
       auto a2=upper_bound(s.begin(),s.end(),mp(xp,312345));        
//cout<<i<<" "<<a1<<" "<<a2<<endl;
        cout<<a2-a1<<" ";
    }
    return 0;
}

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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using P = pair<int,int>;
//Write From this Line

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	rep(i, N)cin>>A[i];
	// 前の数字と同じかソレ以下しか作れない。
	if(A[0] != 0) {
		cout << -1 << endl; return 0;
	}
	For(i,1,N){
		if(A[i-1] == A[i] || A[i-1] + 1 == A[i] || A[i-1] > A[i]){
		}// ok
		else {
			cout << -1 << endl;
			return 0;
		}
	}
	ll ans = 0;
	for(int i = N-1; i >= 0; i--){
		if(i == N-1) ans += A[i];
		else {
			if(A[i] == A[i+1]) ans += A[i];
			else {
				if(A[i] > A[i+1]) ans += A[i];
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h,w): return [[i for j in range(w)] for k in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
input = sys.stdin.readline

N,L,T = MI()
for_l = []
rev_l = []
final = []
for i in range(N):
    if i==0:
        x0,w0 = MI()
        x,w = x0,w0
    else:
        x,w = MI()
    if w==1:
        for_l += [x]
        final += [(x+T)%L]
    else:
        rev_l += [x]
        final += [(x-T)%L]

final.sort()
opposite_l = rev_l if w0==1 else for_l
opp_num = len(opposite_l)
cicle = (2*T)//L
res = (2*T)%L
cnt = 0 #i=1のアリが衝突する回数
cnt += opp_num*cicle
if res!=0 and res!=1:
    xr = (x0 + res -1)%L if w0==1 else x0
    xl = x0 if w0==1 else (x0-res+1)%L
    for i in opposite_l:
        if xl<=xr and xl<=i<=xr:
            cnt += 1
        if xl>xr and (i>=xl or i<=xr):
            cnt += 1
c = (cnt)%N if w0==1 else (-cnt)%N #x0+Tにくるアリの番号
if w0==1:
    c_idx = final.index((x0+T)%L)
else:
    c_idx_l = [i for i,v in enumerate(final) if v==(x0-T)%L]
    c_idx = c_idx_l[-1]
ans = [-1 for i in range(N)]
ans[c] = final[c_idx]
for i in range(1,N):
    ans[(c+i)%N] = final[(c_idx+i)%N]
[print(x) for x in ans]


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const ll MOD=1e9+7;

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

int main(){
    string s, t; cin >> s >> t;
    int ans=INF;
    for(int i=0; i+t.size()-1<s.size(); i++){
        int cnt=0;
        for(int j=0; j<t.size(); j++){
            if(s[i+j] != t[j]) cnt++;
        }
        chmin(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdlib>
#include <utility>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>

#define INF (1e9)
#define rep(i, n) for (int i = 0; i < (int)n; i++)

using namespace std;

int main() {
    int n; cin >> n;
    float ans = 0;
    if (n % 2 == 0) ans = 0.5;
    else ans = (float)(n / 2 + 1) / n;
    cout << ans << endl;
}


Measured memory_bytes: 256
class Calc:
    def __init__(self, max_value, mod):
        """combination(max_value, all)"""
        fact = [-1] * (max_value + 1)
        fact[0] = 1
        fact[1] = 1
        for x in range(2, max_value + 1):
            fact[x] = x * fact[x - 1] % mod

        invs = [1] * (max_value + 1)
        invs[max_value] = pow(fact[max_value], mod - 2, mod)
        for x in range(max_value - 1, 0, -1):
            invs[x] = invs[x + 1] * (x + 1) % mod

        self.fact = fact
        self.invs = invs
        self.mod = mod

    def combination(self, n, r):
        if n - r < r:
            return self.combination(n, n - r)
        if r < 0:
            return 0
        if r == 0:
            return 1
        if r == 1:
            return n
        return self.fact[n] * self.invs[r] * self.invs[n - r] % self.mod


def main():
    MOD = 10 ** 9 + 7
    H, W, A, B = map(int, input().split())

    calc = Calc(max_value=H + W, mod=MOD)

    ans = 0
    for x in range(B, W):
        v = calc.combination(n=(H - A - 1) + x, r=x)
        u = calc.combination(n=(A - 1) + (W - 1 - x), r=A - 1)
        # (H-1)-(H-A)+(W-1)-x
        ans = (ans + v * u) % MOD
    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 18804
N,K = map(int,input().split())
S = input()
if S[K-1] == 'A':
    s = 'a'
if S[K-1] == 'B':
    s = 'b'
if S[K-1] == 'C':
    s = 'c'


print(S[:K-1]+s+S[K:])

Measured memory_bytes: 2940
#include<iostream>

using namespace std;

int p[20000];
int ar[20000];

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> p[i];
		ar[p[i] - 1] = i;
	}
	int a[20000], b[20000];
	for (int i = 1; i <= N; i++) {
		a[i - 1] = 25000 * i;
		b[i - 1] = 25000 * (N + 1 - i);
		b[i - 1] += ar[i - 1];
	}
	for (int i = 0; i < N; i++)cout << a[i] << " ";
	cout << endl;
	for (int i = 0; i < N; i++)cout << b[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<cmath>
#define int long long
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
int a[114514];
signed main(){
	int m,n;
	cin>>m>>n;	
	int sum=0;
	int ans=0;	
	rep(0,i,n)cin>>a[i];
	if(m==2){
		rep(0,i,n){
			if((i%2==0&&a[i]==1)||(i%2==1&&a[i]==2))sum++;
			else ans++;
		}
		c(n-max(sum,ans));
		return 0;
	}			
	rep(0,i,n){
		if(a[i]==a[i+1])sum++;
		else{
			ans+=((sum+1)/2);
			sum=0;
		}
	}
	c(ans)
}				


Measured memory_bytes: 3876
// Sum of gcd of Tuples (Easy)
#include <algorithm>
#include <complex>
#include <string>
#include <deque>
#include <iostream>
#include <set>
#include <stack>
#include <string>
#include <queue>
#include <utility>
#include <vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int gcd(int p, int q){
    if(p % q == 0) return q;
    return gcd(q, p%q);
}

int main() {
    int K;
    cin >> K;
    int sum = 0;
    for(int i = 1; i <= K; i++){
        for (int j = 1; j <= K; j++){
            for (int k = 1; k <= K; k++) {
                int tmp = gcd(j, k);
                sum += gcd(i, tmp);
            }
        }
    }

    cout << sum << endl;

    


    return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int a[] = new int[n];
		int b[] = new int[n];
		int c[] = new int[n];

		for(int j = 0;j < n;j++) {
			a[j] = sc.nextInt();
		}

		for(int j = 0;j < n;j++) {
			b[j] = sc.nextInt();
		}

		for(int j = 0;j < n - 1;j++) {
			c[j] = sc.nextInt();
		}

		int result = 0;
		int beforeEat = -1;
		for(int x : a) {
			result += b[x - 1];

			if((beforeEat + 1) == x) {
				result += c[x - 2];
			}
			beforeEat = x;
		}

		System.out.println(result);
	}
}

Measured memory_bytes: 23892
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var a, b, c, d int
	fmt.Fscan(r, &a)
	fmt.Fscan(r, &b)
	fmt.Fscan(r, &c)
	fmt.Fscan(r, &d)

	flg := true
	for a > 0 && c > 0 {
		if flg {
			c -= b
		} else {
			a -= d
		}

		flg = !flg
	}

	if a <= 0 {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// mod combination
func modpow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n = n / 2
	}
	return res
}

func modcomb(n, a, mod int) int {
	x := 1
	y := 1
	for i := 0; i < a; i++ {
		x = x * (n - i)
		x %= mod
		y = y * (i + 1)
		y %= mod
	}
	return x * modpow(y, mod-2, mod) % mod
}

func modfactorial(n, mod int) int {
	result := 1
	for i := 1; i <= n; i++ {
		result = (result * i) % mod
	}
	return result
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func reverseString(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

// Queue ...
type Queue []int

// pop ...
func (q *Queue) empty() bool {
	return len(*q) == 0
}

// push ...
func (q *Queue) push(i int) {
	*q = append(*q, i)
}

// pop ...
func (q *Queue) pop() (int, bool) {
	if q.empty() {
		return 0, false
	} else {
		res := (*q)[0]
		*q = (*q)[1:]
		return res, true
	}
}

// Stack ...
type Stack []int

// pop ...
func (s *Stack) empty() bool {
	return len(*s) == 0
}

// push ...
func (s *Stack) push(i int) {
	*s = append(*s, i)
}

// pop ...
func (s *Stack) pop() (int, bool) {
	if s.empty() {
		return 0, false
	} else {
		index := len(*s) - 1
		res := (*s)[index]
		*s = (*s)[:index]
		return res, true
	}
}


Measured memory_bytes: 1824
#include <iostream>
#include <algorithm>

using namespace std;

int n, x, y, l, r;

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    cin >> n >> x >> y;
    for (int i = 0; i < n; i++) {
        l = r;
        cin >> r;
    }
    cout << max((n > 1) * abs(l - r), abs(r - y)) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;


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

	int a, b;
	cin >> a >> b;

	if(b % a == 0)
		cout << a + b << '\n';
	else
		cout << b - a << '\n';

	return 0;
}


/*

*/

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  string n;
  cin>>n;
  for(auto c:n){
    if(c=='1')cout<<9;
    else if(c=='9')cout<<1;
    else cout<<c;
  }
  cout<<endl;
  return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}
double EPS = 1e-10;
double add(double a, double b){
  if(abs(a+b) < EPS* (abs(a) + abs(b))) return 0;
  return a+b;
}

struct P{
  double x,y;
  P(){}
  P(double _x,double _y):x(_x),y(_y){}
  P operator + (P p){
    return P(add(x,p.x) ,add(y,p.y));
  }
  P operator - (P p){
    return P(add(x,-p.x) ,add(y,-p.y));
  }
  P operator * (double d){
    return P(x * d,y * d);
  }
  friend ostream& operator<<(ostream& os,const P& p){
    os << "("<<p.x <<","<<p.y<<")";
    return os;
  }
  double norm(){
    return sqrt(x*x + y*y);
  }
  double dot(P p){
    return add(x * p.x,y*p.y);
  }
  double det(P p){
    return add(x*p.y,-y*p.x);
  }
  double dist2(P p){
    return ((*this-p).x * (*this-p).x) + ((*this-p).y * (*this-p).y);
  }
  P GetCenter(P &p){
    return P((*this+p).x/2,(*this+p).y/2);
  }
  double GetSlope(P &p){
    P tmp = *this - p;
    return tmp.y/tmp.x;
  }
};
bool on_seg(P p1,P p2,P q){
  return (p1-q).det(p2-q) == 0 && (p1-q).dot(p2-q) <= 0;
}
P intersection(P p1, P p2, P q1,P q2){
  return p1 + (p2-p1) * ((q2 - q1).det(q1-p1) / (q2 - q1).det(p2-p1)) ;
}

int check(P p1,P p2,P p3){
  P a = p2-p1,b = p3 - p1;
  if(a.det(b) > EPS) return 1;
  else if(a.det(b) < -EPS) return -1;
  return 0;
}
bool solve(double a,double b,double c,double d,double e,double f,double xp,double yp){
  P p1 = P(a,b),p2 = P(c,d),p3 = P(e,f),p4 = P(xp,yp);
  int A = check(p1,p2,p4);
  int B = check(p2,p3,p4);
  int C = check(p3,p1,p4);
  if(A == B && B == C && (B == 1 || B == -1)){
    return true;
  }
  return false;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  double a,b,c,d,e,f,xk,yk,xs,ys;
  rep(i,n){
    cin >> a >> b >> c >> d >> e >> f >> xk >> yk >> xs >> ys;
    if(solve(a,b,c,d,e,f,xk,yk) == solve(a,b,c,d,e,f,xs,ys)){
      cout << "NG"<<endl;
    }
    else{
      cout << "OK"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ri register int
const int N=500005,M=998244353;
int n,u,v,head[200005],Next[400005],adj[400005],k,dp[200005],ans;
void Push(int u,int v)
{
	Next[++k]=head[u];
	head[u]=k;
	adj[k]=v;
}
void dfs(int i,int fa)
{
	int j,mx=0,mxx=0;
	for(j=head[i];j!=0;j=Next[j])
 		if(adj[j]!=fa)
 		{
		 	dfs(adj[j],i);
		 	if(mx<dp[adj[j]]+1)
 			{
 				mxx=max(mxx,mx);
			 	mx=dp[adj[j]]+1;
			}
			else
				mxx=max(mxx,dp[adj[j]]+1);
 		}
 	ans=max(ans,mx+mxx);
 	dp[i]=mx; 
}
int main()
{
	scanf("%d",&n);
	for(ri i=1;i<n;++i)
	{
		scanf("%d %d",&u,&v);
		Push(u,v);
		Push(v,u);
	}
	dfs(1,0);
	++ans;
	if(ans%3==2)
		cout<<"Second";
	else
		cout<<"First";
}


Measured memory_bytes: 16896
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	public static void main(String[]__){
		char[]in=s.next().toCharArray();
		long buf=0,sum=0;
		for(int b=0;b<1<<(in.length-1);b++) {
			buf=in[0]-'0';
			for(int i=1;i<in.length;i++) {
				if((b&(1<<(i-1)))>0) {
					sum+=buf;
					buf=in[i]-'0';
				}else{
					buf*=10;
					buf+=in[i]-'0';
				}
			}
			sum+=buf;
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 23636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		String a = br.readLine();
		String b = "CODEFESTIVAL2016";
		int l = a.length();
		int cnt = 0;
		for(int i = 0; i < l; i++){
			char c1 = a.charAt(i);
			char c2 = b.charAt(i);
			if(c1!=c2)cnt++;
		}
		sb.append(cnt);
		System.out.println(sb);
	}
}

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

using namespace std;
int main() {
  int kuku[81];
  int num = 0;
  for (int i = 1; i < 10; i++) {
    for (int j = 1; j < 10; j++) {
      kuku[num] = i * j;
      num++;
    }
  }
  int n;
  cin >> n;
  bool isCan = false;
  for (int i = 0; i <= num; i++) {
    if (kuku[i] == n) isCan = true;
  }

  cout << (isCan ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
x, y, a, b ,c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
q.sort()
nums = p[-x:] + q[-y:] + r
nums.sort()
print(sum(nums[-(x+y):]))

Measured memory_bytes: 22720
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    string s;
    cin >> s;
    if(s.find("N") != string::npos && s.find("S") == string::npos) puts("No");
    else if(s.find("S") != string::npos && s.find("N") == string::npos) puts("No");
    else if(s.find("W") != string::npos && s.find("E") == string::npos) puts("No");
    else if(s.find("E") != string::npos && s.find("W") == string::npos) puts("No");
    else puts("Yes");
    
    return 0;
}

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

int main(){

    string s, t; cin >> s >> t;
    int n = s.size(), m = t.size();

    vector< vector<int> > dp;
    dp.assign(n+1, vector<int>(m+1,0));

    for(int i=1; i<=n; i++)
    for(int j=1; j<=m; j++){
        if(s[i-1] == t[j-1])
            dp[i][j] = 1 + dp[i-1][j-1];
        else
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    }

    string ans = "";
    while(n && m){
        if(s[n-1] == t[m-1])
            ans += s[n-1], n--, m--;
        else if(dp[n-1][m] > dp[n][m-1])
            n--;
        else m--;
    }reverse(ans.begin(), ans.end());
    cout << ans << "\n";

    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const int INF=1<<29;

int main(){
	int n,m; cin>>n>>m;
	int a[1000],c[1000]={};
	rep(i,m){
		int b; cin>>a[i]>>b;
		rep(j,b){
			int t; cin>>t;
			c[i]|=1<<(t-1);
		}
	}

	int dp[1<<12];
	rep(S,1<<n) dp[S]=INF;
	dp[0]=0;
	rep(i,m){
		for(int S=(1<<n)-1;S>=0;S--){
			dp[S|c[i]]=min(dp[S|c[i]],dp[S]+a[i]);
		}
	}
	if(dp[(1<<n)-1]<INF) cout<<dp[(1<<n)-1]<<endl; else cout<<-1<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e18+18;
const ll MAX = 100005;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;


int main(){
    int N;
    cin>>N;
    map<string, int> M;
    int MAXIM=0;
    vector<string> S(N);
    for(int i=0; i<N; i++){
       cin>>S[i];
        M[S[i]] ++;
        MAXIM=max(MAXIM, M[S[i]]);
    }
    set<string> St;
    for(int i=0; i<N; i++){
        if(M[S[i]]==MAXIM){
            St.insert(S[i]);
        }
    }
    int Sz=St.size();
    for(int i=0; i<Sz; i++){
        auto itr = St.begin();
      	cout<<*itr<<endl;
      	St.erase(itr);
    }

}

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

int main() {
  int a,b,c,d; cin >> a >> b >> c >> d;
  while(1){
    c = c - b;
    if(c <= 0) {
      cout << "Yes";
      break;
    }
    a = a - d;
    if(a <= 0) {
      cout << "No";
      break;
    }
  }
}


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

using ll = long long;
using namespace std;

int weight[101], value[101], n, w, sum_value;
array<ll, 100001> dp1, dp2;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

#ifdef LOCAL_DEFINE
	freopen("in.txt", "r", stdin);
#endif

	cin >> n >> w;
	for (int i = 0; i < n; ++i)
	{
		cin >> weight[i] >> value[i];
		sum_value += value[i];
	}

	dp1.fill(1e18);
	dp2.fill(1e18);
	dp1[0] = dp2[0] = 0;

	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j <= sum_value - value[i]; ++j)
		{
			dp1[j + value[i]] = min(dp1[j + value[i]], dp2[j] + weight[i]);
		}
		dp2 = dp1;
	}

	int ans = 0;
	for (int i = 0; i <= sum_value; ++i)
	{
		if (dp1[i] <= w)
			ans = i;
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 1792
def calcPattern(N, Y):
    for i in range(0, N+1):
        for j in range(0, N+1-i):
            if i == ((Y - 1000*N - 4000*j) / 9000):
                if (N-i-j) >= 0: return (str(i) + " " + str(j) + " " +str(N-i-j))
    return ("-1 -1 -1")
 
n,y = map(int, input().split())
print(calcPattern(n,y))

Measured memory_bytes: 9192
import java.util.Scanner;

public class Main{

    public static void main(String[] args){

Scanner sc= new Scanner(System.in);

int intN = sc.nextInt();

int i = 0;

int x = 0;

for (i = 1; i <= intN; i++) {

    if (i % 3 == 0) {

        System.out.print(" " + i);

    } else if (i % 10 == 3) {

        System.out.print(" " + i);

    } else if (i / 1000 == 3) {

        System.out.print(" " + i);

    } else if ((x = i % 1000) / 100 == 3) {

        System.out.print(" " + i);

    } else if ((x = x % 100) / 10 == 3) {

        System.out.print(" " + i);

    }

}

System.out.println();

    }

}

Measured memory_bytes: 28684
N = int(input())

def fz(n):
    if n % 3 == 0:
        return 0
    elif n % 5 == 0:
        return 0
    else:
        return n

def fzsum(n):
    return sum([fz(i + 1) for i in range(n)])

print(fzsum(N))


Measured memory_bytes: 33752
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<string>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for (int i=a; i<=b; i++)
#define per(i,a,b) for (int i=a; i>=b; i--)
using namespace std;
typedef long long LL;
   
inline int read() {
	int x=0,f=1; char ch=getchar();
	while (!(ch>='0'&&ch<='9')) {if (ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') {x=x*10+(ch-'0'); ch=getchar();}
	return x*f;
}

const int N = 500005;
const double eps = 1e-8;

int n,head=0,tail=0;
double L,q[N][2];
                                                                
int main() {
	
	#ifndef ONLINE_JUDGE
	//	freopen("data.in","r",stdin);
	//	freopen("data.out","w",stdout);
	#endif
	
	n=read(); L=read();
	double S=0,V=0;
	rep(i,1,n) {
		int t=read(),v=read();
		V+=v; S+=(double)t*v;
		while (V>L&&head<tail) {
			if (V-L>=q[head][0]) {
				V-=q[head][0]; S-=q[head][0]*q[head][1];
				head++;
			} else {
				q[head][0]-=V-L; S-=(V-L)*q[head][1]; V=L;
				break;
			}
		}
		q[tail][0]=v; q[tail++][1]=t;
		printf("%lf\n",S/L);
		while (tail-head>=2) {
			if (q[tail-1][1]>q[tail-2][1]) break;
			q[tail-2][1]=(q[tail-2][0]*q[tail-2][1]+q[tail-1][0]*q[tail-1][1])/(q[tail-2][0]+q[tail-1][0]);
			q[tail-2][0]+=q[tail-1][0];
			tail--;
		}
	}
	
	return 0;
}

Measured memory_bytes: 16384
#include"iostream"
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
#include<list>
#include<map>
#include<algorithm>
#include<string>
#include <queue> 
#include <sstream>
#include <fstream>
#include<cmath>
#define LL long long
using namespace std;
#define INF 1000000000

vector<string> v;



LL N,M,x[100000],xx[100000],ans;

int main() {
  
	cin>>N>>M;
	
	for(int i=0;i<M;i++){
		cin>>x[i];
	}
	if(N>M){
		cout<<0<<endl;
		return 0;
	}
	sort(x,x+M);
	for(int i=0;i<M-1;i++){
		xx[i]=x[i+1]-x[i];
	}

	sort(xx,xx+(M-1));

	for(int i=M-2;i>(M-2)-(N-1);i--){
		ans+=xx[i];
	}

	cout<<(x[M-1]-x[0])-ans<<endl;

	return 0;
}

Measured memory_bytes: 1792
n=int(input())
a=[[[0 for l in range(10)] for j in range(3)] for k in range(4)]
for i in range(n):
    b,f,r,v=map(int,input().split())
    a[b-1][f-1][r-1]+=v
for j in range(4):
    for k in range(3):
        for l in range(10):
            print(' '+str(a[j][k][l]), end='')
        print()
    if(j!=3):
        print('####################')


Measured memory_bytes: 5624
# 2019/05/24
# AtCoder Beginner Contest 071 - B

# Input
s = input()

cl = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

ans = None
for i in range(len(cl)):
    exflg = False
    for j in range(len(s)):
        if s[j] == cl[i]:
            exflg = True
            break
    if exflg == False:
        ans = cl[i]
        break

# Output
print(ans)


Measured memory_bytes: 3188
import sys
from collections import deque
from collections import  Counter
import statistics
import math
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

s = input()
ans = 0
for i in range(4):
    if s[i] == "-":
        ans -= 1
    else:
        ans += 1
print(ans)


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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30
#define MOD 1000000007 // 1e9+7

bool graph[8][8];

int main()
{
  int N, M;
  cin >> N >> M;
  rep(i,M){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    graph[a][b] = true;
    graph[b][a] = true;
  }

  int ret = 0;
  vi p(N);
  rep(i,N) p[i] = i;
  do{
    if( p[0] != 0 ) continue;
    bool flag = true;
    rep(i,N-1){
      if( !graph[p[i]][p[i+1]] ){
        flag = false;
      }
    }
    if( flag )
      ret++;
  } while(next_permutation(p.begin(), p.end()));

  cout << ret << endl;

	return 0;
}



Measured memory_bytes: 256