akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

#define NUM 2147483647

int N;
int* table;

void init(int first_N){
	while(N < first_N)N *= 2;
}

void update(int loc,int value){
	loc += N-1;

	table[loc] = value;

	if(N == 1)return;

	int parent = (loc-1)/2;

	while(true){
		table[parent] = min(table[2*parent+1],table[2*parent+2]);

		if(parent == 0)break;
		else{
			parent = (parent-1)/2;
		}
	}
}

int query(int search_left,int search_right,int node_id,int node_left,int node_right){

	if(search_right < node_left || search_left > node_right)return NUM;

	if(search_left <= node_left && search_right >= node_right){
		return table[node_id];
	}

	int left_min = query(search_left,search_right,2*node_id+1,node_left,(node_left+node_right)/2);
	int right_min = query(search_left,search_right,2*node_id+2,(node_left+node_right)/2+1,node_right);

	return min(left_min,right_min);
}


int main(){

	int first_N,Q,command,left,right;
	table = new int[1000000];
	N = 1;

	scanf("%d %d",&first_N,&Q);

	init(first_N);

	for(int i = 0; i <= 2*N-2; i++)table[i] = NUM;

	for(int i = 0; i < Q; i++){
		scanf("%d %d %d",&command,&left,&right);

		if(command == 0){
			update(left,right);
		}else{
			printf("%d\n",query(left,right,0,0,N-1));
		}
	}

	return 0;
}


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

int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  if(L > R){
    cout << "Left" << endl;
  }
  else if (R > L){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
class Main {
  
  
  
  public static int maxsearch(int g[]){
    
    int max=-100;
    
    for(int i=0; i<g.length; i++){
      if(max<g[i]){
        max = g[i];
        }
      }
        
      return max;
      
  }
      
      
      
   public static int minsearch(int g[]){
    
    int min=100;
    
    for(int i=0; i<g.length; i++){
      if(min>g[i]){
        min = g[i];
        }
        
       }
      return min;
      
  }
      
  
  public static void main (String[] args)  {
    
    
    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int M = sc.nextInt();
    int X = sc.nextInt();
    int Y = sc.nextInt();
    
    int x []= new int[N];
    int y []= new int[M];
    
    String ans = "War";
    
    for(int i=0; i<N; i++){
      x[i]= sc.nextInt();
      }
      
    for(int i=0; i<M; i++){
      y[i]= sc.nextInt();
      }
      
      
      int xf = 0;
      int yf=0;
      
      if(X<Y){
        xf = maxsearch(x);
        yf = minsearch(y);
           if(xf<yf && xf<Y && yf >X){
          ans = "No War";
            }
          }
    
    
    
    System.out.println(ans);



  }
}

Measured memory_bytes: 23124
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

point = -1
temp_diff = float('inf')
for i, h in enumerate(H):
  temp = T - h * 0.006
  if abs(A - temp) < temp_diff:
    point = i+1
    temp_diff = abs(A - temp)
print(point)

Measured memory_bytes: 3064
#include<iostream>
#include<map>

int main(void){
    int n;
    long long k;
    std::cin >> n >> k;

    std::map<int, long long> mp;

    for(int i = 0; i < n; i++){
        int a, b;
        std::cin >> a >> b;
        mp[a] += b;
    }

    long long count = 0;

    for(auto p: mp){
        int key = p.first;
        long long value = p.second;
        count += value;
        if(count >= k){
            std::cout << key << std::endl;
            return 0;
        }
    }
    
}

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

int main()
 {
	int a,b;

    cin >> a >> b;
    
    if(a*b%2 == 0)
     {
     	cout << "Even" <<endl;
     }
    else
    {
    	cout << "Odd" << endl;
    }
 }

Measured memory_bytes: 256
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

/*
AtCoder s Contest
 */

char s[101],t[101],u[101];
int main(){
  cin >> s >> t >> u;
  cout << s[0] << t[0] << u[0] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

#define N_MAX n+1

int main() {
	
	int x;
	cin >> x;
	
	double i,j,su;
	int ans=1;
	for(i=1;i<x;++i){
	    for(j=2;j<x;++j){
	        su = pow(i,j);
	        if(su>ans&&su<=x)ans=su;
	    }
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define ff first
#define ss second

const int MAX_LENGTH = 3005;

int len1, len2, dptable[MAX_LENGTH][MAX_LENGTH], i, j;
string A;
string B;

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	
	cin >> A >> B;
	len1 = A.length() + 1;
	len2 = B.length() + 1;

	memset(dptable, 0, sizeof(dptable));

	for (i = 1; i < len1; i++) {
		for (j = 1; j < len2; j++) {
			if (A[i - 1] == B[j - 1]) {
				dptable[i][j] = dptable[i - 1][j - 1] + 1;
			}
			else {
				dptable[i][j] = max(dptable[i - 1][j], dptable[i][j - 1]);
			}
		}
	}

	string answer = "";

	i = len1 - 1;
	j = len2 - 1;
	while (i > 0 && j > 0) {
		if (dptable[i][j] > max(dptable[i - 1][j], dptable[i][j - 1])) {
			answer = A[i - 1] + answer;
			i--;
			j--;
		}
		else if (dptable[i - 1][j] > dptable[i][j - 1]) {
			i--;
		}
		else {
			j--;
		}
	}

	cout << answer << endl;
	return 0;
}	

Measured memory_bytes: 35584
#include <stdio.h>
#include <math.h>

int main (void) {
    double N, K = 0;
    scanf("%lf %lf", &N, &K);

    for (double i=0; i<1000; i++) {
        if((N - pow(K, i)) < 0) {
            printf("%d\n", (int)i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 128
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

ll solve() {
    string S;
    ll K;
    cin >> S >> K;
    for(ll i = 0; i < 26; i++) if(S == string(S.size(), 'a' + i)) return S.size() * K / 2;

    auto calc = [&](ll left, ll right) {
        char pre = S[left];
        ll cnt = 1;
        ll ret = 0;
        for(ll i = left + 1; i < right; i++) {
            if(pre == S[i]) {
                cnt++;
            } else {
                DEBUG(make_tuple(left, right, cnt));
                ret += cnt / 2;
                pre = S[i];
                cnt = 1;
            }
        }
        DEBUG(ret+cnt/2);
        return ret + cnt / 2;
    };

    if(S[0] == S.back()) {
        ll lidx = S.size() - 1, ridx = S.size();
        ll joint = 0;
        string T = S + S;
        while(0 < lidx) {
            if(T[lidx - 1] == S.back()) lidx--;
            else break;
        }
        while(ridx < T.size()) {
            if(T[ridx] == S.back()) ridx++;
            else break;
        }
        joint = (ridx - lidx) / 2;
        ridx -= S.size();

        ll ans = 0;
        DEBUG(joint);

        ans += calc(0, lidx);
        ans += joint * (K - 1);
        ans += calc(ridx, lidx) * (K - 2);
        ans += calc(ridx, S.size());
        return ans;
    } else {
        return calc(0, S.size()) * K;
    }
}

int main() {
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n,t;
  cin>>n>>t;
  vector<vecint> dp(n+1, vecint(t+3001, 0));
  vector<tuple<int,int>> vt;
  for(int i:irange(0,n)) {
    int a,b;
    cin>>a>>b;
    vt.emplace_back(a,b);
  }
  boost::sort(vt);
  for(int i:irange(0,n)) {
    int a,b;
    tie(a,b) = vt[i];
    for(int j:irange(0,t+3001)) {
      dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
      if (j < t) {
        dp[i+1][j+a] = max(dp[i+1][j+a], dp[i][j] + b);
      }
    }
  }
  cout<<*boost::max_element(dp[n])<<endl;
  return 0;
}


Measured memory_bytes: 74160
def check(y,x):
	if 0<=y<=11 and 0<=x<=11:
		return True
	return False
	
def dfs(y,x):
	if g[y][x]=="0":return 0
	g[y][x]="0"
	for i in xrange(4):
		nexty=y+dy[i]
		nextx=x+dx[i]
		if  not check(nexty,nextx):continue
		if visited[nexty][nextx]==0 and g[nexty][nextx]=="1":
			visited[nexty][nextx]=1
			dfs(nexty,nextx)
	return 1
	
dx=(1,0,-1,0)
dy=(0,1,0,-1)
while 1:
	try:
		g=[[] for _ in xrange(12)]
		for i in xrange(12):
			for j in raw_input():
				g[i].append(j)
		cnt=0
		visited=[[0]*12 for _ in xrange(12)]
		for i in xrange(12):
			for j in xrange(12):
				cnt+=dfs(i,j)
		print(cnt)
		raw_input()
	except:
		break

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

int main(){
  
  int a;
  cin >> a;
  vector<int> b(a);
  for(int i=0;i<a;i++){
    cin >> b.at(i);
  }
  
  sort( b.begin(),b.end() );
  
  cout << b.at(a-1) - b.at(0) << endl;
  
}


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

using namespace std;

typedef long long ll;

const int maxn=2e5+10;

int k;
int a[maxn];



int main()
{
	int n,k;
	cin>>n>>k;
	for( int i=1;i<=n;i++ ) cin>>a[i];
	for( int i=k+1;i<=n;i++ )
	{
		if( a[i]<=a[i-k] ) puts("No");
		else puts("Yes");
	}
} 

Measured memory_bytes: 4408
import java.util.*;
import static java.lang.Math.*;

class Main {
    final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        int l = sc.nextInt();
        int r = sc.nextInt();
        int d = sc.nextInt();
        
        int ans = 0;
        for (int i = l; i <= r; i++) {
            if (i % d == 0) ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35700
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll k,a,b;
  cin>>k;
  cin>>a>>b;
  bool flag=false;
  for(ll i=a;i<=b;i++)
  {
    if(i%k==0)
    {cout<<"OK";flag=true;break;}
  }
  if(flag==false)
    cout<<"NG";
  return 0;
}
  


Measured memory_bytes: 3636
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)

	N, Y := getInt(), getInt()
	for i := 0; i <= N; i++ {
		for j := 0; j <= N; j++ {
			k := N - i - j
			if k < 0 {
				continue
			}
			if i*10000+j*5000+k*1000 == Y {
				out(i, j, k)
				return
			}
		}
	}
	out(-1, -1, -1)
}


Measured memory_bytes: 640
#include <stdio.h>

int check[1000010];
int main()
{
	int a;
	scanf("%d",&a);
	int d = 7%a;
	
	for(int i=1;;i++)
	{
		if(d==0)
		{
			printf("%d",i);
			return 0;
		}
		check[d] = 1;
		d*=10;
		d+=7;
		d%=a;
		if(check[d]==1)
		{
			printf("-1");
			return 0;
		}
	}
}

Measured memory_bytes: 5568
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>

using namespace std;

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

template<typename T>
ostream& operator << (ostream& os, const vector<T>& v) {
    for (auto& x : v) {
        os << x << " ";
    }
    os << "\n";
    return os;
}

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

#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;
    vector<int64_t> a(n);
    cin >> a;
    vector<vector<int64_t>> dp(n, vector<int64_t>(2, 0));
    dp[0][1] = 0;
    dp[0][0] = a[0] / 2;

    for (int i = 1; i < n; ++i) {
        dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]) + a[i] / 2;
        if (a[i] > 0) {

            if (a[i - 1] % 2 == 1) {
                dp[i][1] = dp[i - 1][0] + 1 + (a[i] - 1) / 2;
            } else if (a[i - 1] > 0) {
                dp[i][1] = max(dp[i - 1][0] + (a[i] - 1) / 2,
                        dp[i - 1][1] + 1 + (a[i] - 1) / 2);
            }
        }
    }
    cout << max(dp[n - 1][0], dp[n - 1][1]);
}


Measured memory_bytes: 9444
/*COMPETITIVE PROGRAMMING C++ TEMPLATE */

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <iostream>
#include <stack>
#include <queue>
#include <climits>
#include <iomanip>

#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << "\n"
#define MOD 1000000007

const long double PI = 3.141592653589793236L;

typedef long long int ll;
typedef long double ld;

using namespace std;

void solve()
{
    string s;
    cin >> s;

    int n = s.size();

    if(s[n - 1] == 's')
    {
        s += "es";
    }
    else {
        s += "s";
    }

    cout << s << "\n";
    
}

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

    int T = 1;
    //cin >> T;
    
    while (T--)
    {
        solve();
    }
    
    return 0;
}







Measured memory_bytes: 3664
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define double long double
const long long mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
struct edge { int to,cost; };

int rwa[300005];
signed main(){
	int n; cin >> n;
	string s; cin >> s;
	rep(i, n) {
		if (s[i] == 'W')rwa[i + 1]++;
	}
	rep(i, n)rwa[i + 1] += rwa[i];
	int ans = 1145141919;
	rep(i, n) {
		int l = rwa[i];
		int r =n-i-1-( rwa[n] - rwa[i + 1]);
		ans = min(ans, l + r);
	}
	cout << ans << endl;
}

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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    string s;
    cin >> s;
    i64 n = s.size();
    i64 k;
    cin >> k;

    vector<i64> v;
    i64 suc = 1;
    s.push_back('.');
    for (i64 i = 0; i < n; i++) {
        if (s[i] == s[i + 1]) {
            suc++;
        } else {
            v.emplace_back(suc);
            suc = 1;
        }
    }
    s.pop_back();

    if (v.size() == 1) {
        cout << n * k / 2 << endl;
        return;
    }

    i64 ans = 0;
    for (i64 i = 1; i < (i64) v.size() - 1; i++) ans += v[i] / 2 * k;
    if (s.front() == s.back()) {
        ans += (v.front() + v.back()) / 2 * (k - 1);
        ans += v.front() / 2 + v.back() / 2;
    } else {
        ans += (v.front() / 2 + v.back() / 2) * k;
    }

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 256
#include <stdio.h>
    int max(int A, int B)
{
     if (A+B>A*B&&A+B>A-B)
              return A+B;
    else if(A-B>A+B&&A-B>A*B)
              return A-B;
  else if(A*B>A+B&&A*B>A-B)
            return A*B;
}

int main(void)
{ int num1, num2, ans;
scanf("%d", &num1);
scanf("%d", &num2);
ans=max(num1, num2);
printf("%d\n",ans);
return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;

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

int main()
{
  ll N;
  string s;

  cin >> N;

  cin >> s;
  cin >> s;

  ll sum;
  ll previous=0;
  rep(i,s.length())
  {
    if(s[i] == s[i+1])
    {
      if(previous == 0)
        sum=6;
      if(previous == 1)
        sum*=3;
      if(previous == 2)
        sum*=2;
      i++;
      previous = 1;
    }
    else
    {
      if(previous==0)
        sum = 3;
      if(previous==2)
        sum *= 2;
      previous=2;
    }
  }


  cout << sum%1000000007LL << endl;

  return 0;
}

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

using namespace std;
int main()
{
    string s;
    cin >> s;
    int len=s.size(), i;
    for(i=0;i<len-2;i++)
    {
        if(s[i]==s[i+1]) printf("%d %d\n",i+1, i+2), exit(0);
        if(s[i]==s[i+2]) printf("%d %d\n",i+1, i+3), exit(0);
    }
    s[len-1]==s[len-2]?printf("%d %d\n",len-1, len):printf("-1 -1\n");
    return 0;
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main()
{
    int i,j;
    for(i=1;i<=9;i++){
				for(j=1;j<=9;j++){
								
															
													
        cout<<i<<"x"<<j<<"="<<i*j<<endl;
				
												
						

								
}
}
     
				return 0;

}


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

using ll = long long;
using ld = long double;

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    
    
    if (a+b > c+d) {
        cout << "Left" << endl;
    }
    else if (a+b==c+d)
    {
        cout << "Balanced" << endl;
    }
    else
    {
        cout << "Right" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
long long dp[100010];
long long h[100010];
int dx[4] = {0, -1, 0, 1};
int dy[4] = {1, 0, -1, 0};


int main()
{
    int h, w; cin >> h >> w;
    vector<string> S;
    string s;
    rep(i, h)
    {
        cin >> s;
        S.push_back(s);
    }
  
    bool can;
  	int flag = 1;
    rep(i, h)
    {
        rep(j, w)
        {
            if (S[i][j] == '#')
            {
                bool can = false;
                rep(k, 4)
                {
                    int x = j + dx[k];
                    int y = i + dy[k];
                    if (x < 0 || x >= w) continue;
                    if (y < 0 || y >= h) continue;
                    if (S[y][x] == '#')
                    {
                        can = true;
                    }
                }
              	if (!can) flag = 0;
            }
            else continue;
        }
    }

    // int flag = 1;
    // rep(i, h) if (!can[i]) flag = 0;
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int sx = sc.nextInt();
		int sy = sc.nextInt();
		int tx = sc.nextInt();
		int ty = sc.nextInt();

		System.out.print("D");
		for (int j = 0; j < tx - sx + 1; j++)
			System.out.print("R");
		for (int j = 0; j < ty - sy + 1; j++)
			System.out.print("U");
		System.out.print("L");

		System.out.print("U");
		for (int j = 0; j < tx - sx + 1; j++)
			System.out.print("L");
		for (int j = 0; j < ty - sy + 1; j++)
			System.out.print("D");
		System.out.print("R");

		for (int j = 0; j < tx - sx; j++)
			System.out.print("R");
		for (int j = 0; j < ty - sy; j++)
			System.out.print("U");

		for (int j = 0; j < tx - sx; j++)
			System.out.print("L");
		for (int j = 0; j < ty - sy; j++)
			System.out.print("D");

	}

}


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

int main(){
while(1){
int n;
cin>>n;
if(n==0)break;
vector<int> sum(n+1,0);
for(int i=1;i<=n;i++){
	int a;
	cin>>a;
	sum[i]=sum[i-1]+a;
}
int ans=sum[1];
for(int i=0;i<=n;i++){
	for(int j=i+1;j<=n;j++){
	ans=max(ans,sum[j]-sum[i]);
	}
}
cout<<ans<<endl;
}

return 0;
}



Measured memory_bytes: 3112
#include <iostream>
using namespace std;
int main(void){
    int a,ans,max=-1,b[100];
    cin>>a;
    for(int i=1;i<=a;i++)b[i]=0;
    for(int i=1;i<=a;i++){
        for(int j=2;;j*=2){
            if(i%j==0)b[i]=b[i]+1;
            else break;
        }
        if(b[i]>max){
            max=b[i];
            ans=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8 = { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 },
			{ 1, 1 } };
	static int[][] directions4 = { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 } };
	static int ans;
	static int tmpAns;
	static int[] dep;
	static int[] arr;
	static int depIdx;
	static int arrIdx;
	static int n;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (true) {

			n = sc.nextInt();

			if (n == 0) {
				break;
			}

			dep = new int[n];
			arr = new int[n];

			String tmpInput = null;
			String timeStr = null;
			for (int i = 0; i < n; i++) {
				tmpInput = sc.next();
				timeStr = tmpInput.substring(0, 2);
				timeStr += tmpInput.substring(3, 5) + tmpInput.substring(6, 8);
				dep[i] = Integer.valueOf(timeStr);

				tmpInput = sc.next();
				timeStr = tmpInput.substring(0, 2);
				timeStr += tmpInput.substring(3, 5) + tmpInput.substring(6, 8);
				arr[i] = Integer.valueOf(timeStr);
			}

			tmpAns = 0;
			ans = 0;
			depIdx = 0;
			arrIdx = 0;

			Arrays.sort(dep);
			Arrays.sort(arr);

			for (int i = 0; i < 235959; i++) {
				depCount(i);
				arrCount(i);
				if (tmpAns > ans) {
					ans = tmpAns;
				}
			}
			System.out.println(ans);
		}

	}

	static void depCount(int i) {
		if (depIdx < n && dep[depIdx] == i) {
			tmpAns++;
			depIdx++;
			depCount(i);

		}
	}

	static void arrCount(int i) {
		if (arrIdx < n && arr[arrIdx] == i) {
			tmpAns--;
			arrIdx++;
			arrCount(i);

		}
	}

	// BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for (int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	// //二分探索
	// k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray) {
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while (upperBorder - lowerBorder > 1) {
			mid = (upperBorder + lowerBorder) / 2;
			if (orderedArray[mid] <= num) {
				lowerBorder = mid;
			} else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	// 二分探索
	// k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList) {
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while (upperBorder - lowerBorder > 1) {
			mid = (upperBorder + lowerBorder) / 2;
			if (orderedList.get(mid) <= num) {
				lowerBorder = mid;
			} else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	// aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	public static long gcd(long a, long b) {
		return b == 0 ? a : gcd(b, a % b);
	}
}



Measured memory_bytes: 72996
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int SA[100005];
int TA[100005];


int main(){
  string S, T;
  cin >> S;
  cin >> T;

  if(S[0] == 'A') SA[0] = 1;
  REP(i,1,S.size()){
    SA[i] = SA[i-1] + (S[i]=='A');
  }
  if(T[0] == 'A') TA[0] = 1;
  REP(i,1,T.size()){
    TA[i] = TA[i-1] + (T[i]=='A');
  }
  map<pair<int,int>,char> memo;
  memo[make_pair(0,0)]='-';
  memo[make_pair(0,1)]='B';
  memo[make_pair(0,2)]='A';
  memo[make_pair(1,0)]='A';
  memo[make_pair(1,1)]='-';
  memo[make_pair(1,2)]='B';
  memo[make_pair(2,0)]='B';
  memo[make_pair(2,1)]='A';
  memo[make_pair(2,2)]='-';

  
  int Q;
  cin >> Q;
  rep(q,Q){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int cA = SA[b-1]-(a-2<0?0:SA[a-2]);
    int cB = b-a+1-cA;
    int cC = TA[d-1]-(c-2<0?0:TA[c-2]);
    int cD = d-c+1-cC;

    cA %= 3;
    cB %= 3;
    cC %= 3;
    cD %= 3;
    if(memo[make_pair(cA,cB)] == memo[make_pair(cC,cD)]){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
  
  return 0;
}



Measured memory_bytes: 1664
var main = function(input){
input = input.split('\n');
var N = input[0];
var array = input[1].split(' ').map(x=>parseInt(x));
var count = 0;
for(var i=0;i<N;i++){
  while(array[i]%2 === 0){
    array[i]=array[i]*0.5;
    count++;
  }
}
  console.log(count);
    return 0;
}
main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 21832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
int main(void)
{
    int n;
    cin >> n;

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

    sort(s.begin(),s.end());
    int c=1;



    for(int i=1;i<n;i++){
        if(s[i] != s[i-1]){
            c++;
        }
    }
    cout<< c <<endl;

    return 0;
}


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

int main()
{
  vector<ll> a(3);
  rep(i, 3) cin >> a[i];

  if (a[0]%2==0 || a[1]%2==0 || a[2]%2==0) {
    cout << 0 << endl;
    return 0;
  }

  sort(a.rbegin(),a.rend());
  cout << a[1]*a[2] << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=305,mod=1e9+7;
inline void add(int &a,int b){a+=b;if(a>=mod)a-=mod;}
int dp[N][N][N],n,m,ans;
vector<int>l[N],x[N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		l[b].push_back(a);
		x[b].push_back(c);
	}
	dp[0][0][0]=1;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			for(int k=0;k<=n;k++)
			{
				int r=max(max(i,j),k);
				int &f=dp[i][j][k];
				for(int z=0;z<l[r].size();z++)
				{
					int s=(i>=l[r][z])+(j>=l[r][z])+(k>=l[r][z]);
					if(s!=x[r][z])
						f=0;
				}
				add(dp[r+1][j][k],f);
				add(dp[i][r+1][k],f);
				add(dp[i][j][r+1],f);
				if(r==n)
					add(ans,f);
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 113604
h,w =map(int,input().split())
s=[input() for i in range(h)]

def bomb(x,y):
    if s[y][x]=='#':
        return '#'
    else:
        c=0
        for i in range(-1,2):
            for j in range(-1,2):
                if not (i==0 and j==0):
                    if 0<=x+i<=w-1 and 0<=y+j<=h-1:
                        if s[y+j][x+i]=='#':
                            c+=1
        return str(c)

for i in range(h):
    l=[]
    for j in range(w):
        l.append(bomb(j,i))
    print(''.join(l))


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

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

		Scanner sc = new Scanner(System.in);

		long x = sc.nextLong();
		long k = sc.nextLong();
		long d = sc.nextLong();

		long ans;
		x = Math.abs(x);

		if (x / d >= k) {
			ans = x - k * d;
		} else {
			long tmp = x % d;
			long remain = k - x / d;

			if (remain % 2 == 0) {
				ans = tmp;
			} else {
				ans = Math.abs(tmp - d);
			}

		}

		System.out.println(ans);

		sc.close();
	}

}


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

MOD = 998_244_353

D = [[0 for _ in range(S+1)] for _ in range(N+1)]
D[0][0] = 1
for i in range(1, N+1):
  for j in range(0, S+1):
    D[i][j] = 2 * D[i-1][j] % MOD
    if j >= A[i-1]:
      D[i][j] += D[i-1][j-A[i-1]]
      D[i][j] %= MOD
  #print(D[i])
    
print(D[N][S])

Measured memory_bytes: 153116
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define rep(i,n) for(long long  i = 0; i < n; i++)
#define rep2(i,a,n) for(long long  i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

using namespace std;

int main() 
{
    ll n,w; cin >> n >> w;

    if((w >= 2) && (n >= 2)) {
        cout << (w-2)*(n-2) << endl;
    } else if (w == 1 && n == 1) {
        cout << 1; 
    } else if (w == 1) { 
        cout << n-2;
    } else if (n == 1) {
        cout << w-2;
    } else {
        cout << 0;
    }

    return 0;
}
    



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

#define int long long
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;

template <class T = ll> T in() { T x; cin >> x; return (x); }

vector<int> A[100005];
int color[100005];
bool Odd = false;
int num = 1;

void odd(int pos) {
	for (auto x : A[pos]) {
		if (color[x] == -1) {
			color[x] = (color[pos] + 1) % 2;
			if (color[x] == 0) num++;
			odd(x);
		} else if (color[x] == color[pos]) {
			Odd = true;
		}
	}
	return;
}

signed main() {
	int n,m;
	cin >> n >> m;
	REP (i,m) {
		int x = in()-1,y = in()-1;
		A[x].push_back(y);
		A[y].push_back(x);
	}
	REP (i,100005) {
		color[i] = -1;
	}

	color[0] = 0;
	odd(0);

	int ans = 0;
	if (Odd) {
		ans = n * (n - 1) / 2 - m;
	} else {
		ans = (n - num) * num - m;
	}
	cout << ans << endl;
}

Measured memory_bytes: 7680
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using static System.Math;


class P
{
    static void Main()
    {
        int[] nk = Console.ReadLine().Split().Select(int.Parse).ToArray();  
        if(((nk[0] + 1) / 2) >= nk[1])
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 13396
n, m = map(int, input().split())
lr = [[int(i) for i in input().split()] for _ in range(m)]
mi, ma = 1, n
for l, r in lr:
    mi, ma = max(mi, l), min(ma, r)
if mi <= ma:
    print(ma - mi + 1)
else:
    print(0)

Measured memory_bytes: 21156
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int x = scan.nextInt();
		int[] m = new int[n];
		for (int i = 0; i < n; i++) {
			m[i] = scan.nextInt();
		}
		int min = 2000;
		for (int i = 0; i < n; i++) {
			if (m[i] < min) {
				min = m[i];
			}
		}
		int num = 0;
		for (int i = 0; i < n; i++) {
			x -= m[i];
		}
		num += n;
		while (x-min >= 0) {
			x -= min;
			num++;
		}
		System.out.println(num);
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <numeric>

#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define big ((ll)(1e9) + 7)

int main()
{
  ll n,m;
  cin >> n >> m;
  vector<ll> a(m);
  vector<ll> b(m);
  for (int i = 0; i < m; i++)
  {
    cin >> a[i] >> b[i];
  }

  vector< vector<ll> > G(n);
  bool flag = false;
  for (int i = 0; i < m; i++)   //グラフの作成
  {
    if(a[i] == 1 || b[i] == 1) flag = 1;
    G[a[i] - 1].push_back(b[i]-1);
    G[b[i] - 1].push_back(a[i] - 1);
  }

  if(!flag)
  {
    cout << "No" << endl;
    return 0;
  }

  std::vector<ll> v(n);
  std::vector<ll> seen(n, 0);
  queue<ll> q;
  q.push(0);
  while (!q.empty())    //幅優先探索のアルゴリズム
  {
    ll num = q.front();
    seen[num] = 1;
    q.pop();
    for (ll i = 0; i < G[num].size(); i++)
    {
      ll see = G[num].at(i);
      if (seen[see] == 0)
      {
        q.push(see);
        seen[see] = 1;
        v[see] = num + 1;
      }
    }
  }
  cout << "Yes" << endl;
  for (ll i = 1; i < n; i++)
  {
    cout << v[i] << endl;
  }
}


Measured memory_bytes: 16696
#include<iostream>
#include<queue>
#include<utility>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
typedef pair<int,int> pi;

const int inf=1<<28;
const int MX=1000000;

int tri[1000],ntri;
int dp[MX],dpOdd[MX];

int main(){
	
	ntri=0;
	for(;;ntri++)
	{
		tri[ntri]=ntri*(ntri+1)*(ntri+2)/6;
		if(tri[ntri]>=MX)break;
	}
	
	rep(i,MX)dp[i]=dpOdd[i]=inf;
	dp[0]=dpOdd[0]=0;
	int mx=0;
	rep(i,5)rep(j,mx+1)
	{
		rep(k,ntri)
		{
			if(j+tri[k]>=MX)break;
			if(tri[k]%2==1)dpOdd[j+tri[k]]=min(dpOdd[j+tri[k]],dpOdd[j]+1);
			dp[j+tri[k]]=min(dp[j+tri[k]],dp[j]+1);
			mx=max(mx,j+tri[k]);
			mx=min(mx,MX-1);
		}
	}
	
	int n;
	while(cin>>n,n)cout<<dp[n]<<" "<<dpOdd[n]<<endl;
	
	return 0;
}

Measured memory_bytes: 8568
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n,m;
int main(){
	cin >> n >> m;
	cout <<(n - 1) * (m - 1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#define ll long long

using namespace std;

int main(){

   int N,K;
   string S;
   cin >> N >> K >> S;
   char keep = S[0];

    int cnt = 0;
    for(int i = 1;i < S.size();i++){

       if(keep == 'R' && S[i] == 'L'){
           cnt++;
        }

        keep = S[i];

   }

   int ans;

    if(cnt < K){
        cout << N-1 << endl;
    }
    else if(cnt == K && S[0] == S[N-1]){
        cout << N-1 << endl; 
    }
    else if(cnt == K && S[0] != S[N-1]){
        cout << N - 2 << endl;
    }
    else{

        ans = N - 2 * (cnt - K);

        if(S[0] == 'L'){
            ans--;
        }
        if(S[N-1] == 'R'){
            ans --;
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 512
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 9223372036854775807
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll> a,pair<ll,ll> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se>b.se;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //------------------------------
    ll n;cin>>n;
    V<ll>a(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    sort(all(a));
    ll ans=a[n-1];
    ll cnt=2;
    ll now =n-2;
    for(ll i=n-3;i>=0;i--){
        if(cnt){
            cnt--;
            ans+=a[now];
        }
        else{
            cnt=1;
            now--;
            ans+=a[now];
        }
    }
    cout<<ans<<endl;
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //------------------------------- 
    return 0;
}
//----------------------------------------------------------------------






































Measured memory_bytes: 4780
//文字を(選ぶ,選ばない)する。選べる条件は「今何文字目を見ているか, 今までに選んだ文字数」の2つにしか依存しない。
//よってこの2つのパラメータを使った表を作って数え上げることができそうに思える。で、実際やってみるとできる。
#include <iostream>
#include <string>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int mod = 1000000007;
string t;
string b;
int dp[1001][1001];

signed main() {
	int i, j;
	
	cin >> t >> b;
	rep(i, t.length() + 1) rep(j, b.length() + 1) dp[i][j] = 0;
	dp[0][0] = 1;
	
	rep(i, t.length()) {
		rep(j, b.length() + 1) {
			if (j < b.length() && t[i] == b[j]) {
				dp[i + 1][j + 1] += dp[i][j];
				dp[i + 1][j + 1] %= mod;
			}
			dp[i + 1][j] += dp[i][j];
			dp[i + 1][j] %= mod;
		}
	}
	cout << dp[t.length()][b.length()] << endl;
	return 0;
}


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

int main(){
  int n, b, f, r, v;
  int live[4][3][10] = {};
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> b >> f >> r >> v;
    live[b-1][f-1][r-1] += v;
  }
  for( int i = 0; i < 4; i++){
    for( int j = 0; j < 3; j++){
      for( int k = 0; k < 10; k++){
        cout << " " << live[i][j][k] ;
      }
      cout << endl;
    }
    if(i-3) cout << "####################" << endl;
  }
  return 0;
}
 


Measured memory_bytes: 3092
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>//////////////////////////////////////////
#define deb(...)/////////////////////////////////////////////////
#define DBP(...)/////////////////////////////////////////////////
#ifdef LOC///////////////////////////////////////////////////////
#include"debuglib.h"/////////////////////////////////////////////
#endif///////////////////////////////////////////////////////////
#define x first//////////////////////////////////////////////////
#define y second/////////////////////////////////////////////////
#define pb push_back/////////////////////////////////////////////
#define sz(x)int((x).size())/////////////////////////////////////
#define each(a,x)for(auto&a:(x))/////////////////////////////////
#define all(x)(x).begin(),(x).end()//////////////////////////////
#define rep(i,b,e)for(int i=(b);i<(e);i++)///////////////////////
using namespace std;using ll=long long;using Pii=pair<int,int>;//
using Vi=vector<int>;void run();int main(){cin.sync_with_stdio///
(0);cin.tie(0);cout<<fixed<<setprecision(18);run();return 0;}////
//-------------------------------------------------------------//

struct Vert {
	Vi E;
	int dist{-1};
};

vector<Vert> G;

void dfs(int i, int p, int d) {
	G[i].dist = d;
	each(e, G[i].E) if (e != p) dfs(e, i, d+1);
}

void run() {
	int n; cin >> n;
	G.resize(n);

	rep(i, 1, n) {
		int a, b; cin >> a >> b;
		G[a-1].E.pb(b-1);
		G[b-1].E.pb(a-1);
	}

	dfs(0, -1, 0);

	Pii best = {-1, -1};
	rep(i, 0, n) best = max(best, make_pair(G[i].dist, i));

	dfs(best.y, -1, 0);

	int d = 0;
	each(v, G) d = max(d, v.dist);

	vector<bool> dp = {1, 0};
	while (sz(dp) <= d) dp.pb(!dp[sz(dp)-1] || !dp[sz(dp)-2]);
	cout << (dp[d] ? "First\n" : "Second\n");
}


Measured memory_bytes: 22144
// Isaunoya
#include<bits/stdc++.h>
using namespace std ;
using LL = long long ;
using uint = unsigned int ;
#define int long long
#define fir first
#define sec second
#define pb push_back
#define mp(x , y) make_pair(x , y)
template < typename T > inline void read(T & x) { x = 0 ; int f = 1 ; register char c = getchar() ;
  for( ; ! isdigit(c) ; c = getchar()) if(c == '-') f = -1 ;
  for( ; isdigit(c) ; c = getchar()) x = (x << 1) + (x << 3) + (c & 15) ;
  x *= f ;
}
template < typename T > inline void print(T x) {
  if(! x) { putchar('0') ; return ; }
  static int st[105] ;
  if(x < 0) putchar('-') , x = -x ;
  int tp = 0 ;
  while(x) st[++ tp] = x % 10 , x /= 10 ;
  while(tp) putchar(st[tp --] + '0') ;
}
template < typename T > inline void print(T x , char c) { print(x) ; putchar(c) ; }
template < typename T , typename ...Args > inline void read(T & x , Args & ...args) { read(x) ; read(args...) ; }
template < typename T > inline void sort( vector < T > & v) { sort(v.begin() , v.end()) ; return ; }
template < typename T > inline void unique( vector < T > & v) { sort(v) ; v.erase(unique(v.begin() , v.end()) , v.end()) ; }
template < typename T > inline void cmax(T & x , T y) { if(x < y) x = y ; return ; }
template < typename T > inline void cmin(T & x , T y) { if(x > y) x = y ; return ; }
const int Mod = LLONG_MAX ;
inline int QP(int x , int y) { int ans = 1 ;
  for( ; y ; y >>= 1 , x = (x * x) % Mod)
    if(y & 1) ans = (ans * x) % Mod ;
  return ans ;
}
template < typename T > inline T gcd(T x , T y) { if(y == 0) return x ; return gcd(y , x % y) ; }
template < typename T > inline T lcm(T x , T y) { return x * y / gcd(x , y) ; }
template < typename T > inline void mul(T & x , T y) { x = 1LL * x * y ; if(x >= Mod) x %= Mod ; }
template < typename T > inline void add(T & x , T y) { if((x += y) >= Mod) x -= Mod ; }
template < typename T > inline void sub(T & x , T y) { if((x -= y) < 0) x += Mod ; }

int n , k ;
const int N = 2e5 + 10 ;
int a[N] , b[N] ;
int sum[N] ;
inline bool chk(int mid) {
  int cnt = 0 ;
  for(register int i = 1 ; i <= n ; i ++)
    if(sum[i] > mid) cnt += (sum[i] - mid + b[i] - 1) / b[i] ;
  return cnt <= k ;
}
signed main() {
  read(n) ; read(k) ;
  for(register int i = 1 ; i <= n ; i ++)
    read(a[i]) ;
  for(register int i = 1 ; i <= n ; i ++)
    read(b[i]) ;
  sort(a + 1 , a + n + 1) ;
  sort(b + 1 , b + n + 1 , greater <int>()) ;
  for(register int i = 1 ; i <= n ; i ++)
    sum[i] = a[i] * b[i] ;
  // for(register int i = 1 ; i <= n ; i ++) print(sum[i] , '\n') ;
  int l = 0 , r = LLONG_MAX ; int ans = 0 ;
  while(l <= r) {
    int mid = l + r >> 1 ;
    if(chk(mid)) r = mid - 1 , ans = mid ;
    else l = mid + 1 ;
  } print(ans , '\n') ;
  return 0 ;
}


Measured memory_bytes: 4992
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	String a = sc.next().substring(0,1).toUpperCase();
	String b = sc.next().substring(0,1).toUpperCase();
	String c = sc.next().substring(0,1).toUpperCase();
    System.out.println(a+b+c);
  }
}

Measured memory_bytes: 21844
/*
 _____ ____ _____   ___   ___  __  ___  
|_   _/ __ \_   _| |__ \ / _ \/_ |/ _ \ 
  | || |  | || |      ) | | | || | (_) |
  | || |  | || |     / /| | | || |\__, |
 _| || |__| || |_   / /_| |_| || |  / / 
|_____\____/_____| |____|\___/ |_| /_/   
*/
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define per(i, a, b) for (long long i = (a); i > (b); i--)
#define a(x) (x.begin(), x.end())
#define ar(x) (x.rbegin(), x.rend())
#define pb push_back
#define Pb() pop_back()
#define ll long long int
#define ull unsigned long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sc scanf
#define scin(x) sc("%d", &(x))
#define scln(x) sc("%lld", &(x))
#define pf prllf
#define ms(a, b) memset(a, b, sizeof(a))
#define mp make_pair
#define db double
#define EPS 10E-10
#define ff first
#define ss second
#define sqr(x) (x) * (x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define DBG pf("HI\n")
#define MOD 1000000007
#define CIN                       \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define RUN_CASE(t, T) for (__typeof(t) t = 1; t <= T; t++)
#define CASE(t) prllf("Case %d: ", t)
#define CASEL(t) prllf("Case %d:\n", t)
#define intlimit 2147483647
#define longlimit 9223372036854775807
#define infinity (1 << 28)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a) * (b) / gcd(a, b))
#define PI 2 * acos(0.0)
using namespace std;
int main()
{
    CIN;
    int n;
    cin >> n;
    vector<queue<int>> v(n);
    rep(i,0,n)
    rep(j,0,n-1){
    int zg;
    cin >> zg;
    v[i].push(zg);
    }
    int coco = 0;
    while(1){
        set<int>s;
        rep(i,0,n){
            if(v[i].empty())continue;
            int b = v[i].front()-1;
            if(v[b].front()==i+1&&!s.count(i)&&!s.count(b)){
                v[i].pop();
                v[b].pop();
                s.insert(i);
                s.insert(b);
            }
        }
        coco++;
        int sos = 0;
        rep(i,0,n){
            if(!v[i].empty()){
                sos++;
            }
            //cout << last[i] << " ";
        }
        //cout << endl;
        if(!sos)
        break;
        if(s.size()==0){
            cout << -1;
            return 0;
        }
        if(coco>100000){
            cout << 500*999;
            return 0;
        }
    }
    cout << coco;
}

Measured memory_bytes: 4736