akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> v(n);
    int ans = 0;

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

    for(int left = 0; left <= k; left++){
        for(int right = 0; right <= k; right++){
            if(right+left > min(n,k)) continue;
            int m = k-left-right;
            int can = 0;
            priority_queue<int,vector<int>,greater<int>> que;
            for(int i = 0; i < left; i++){
                que.push(v[i]);
                can += v[i];
            }
            for(int i = n-right; i < n; i++){
                que.push(v[i]);
                can += v[i];
            }
            for(int i = 0; i < m; i++){
                if(que.empty() || que.top() > 0) break;
                can -= que.top(); que.pop();
            }
            if(ans < can) ans = can;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//😄😄😄😄😄😄😄😄😄😄😄😄😄
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define For(i,a,b) for(int i=a;i<b;i++)
#define debug(x) cout<<"DEBUG------> "<<x<<endl
#define endl "\n"

int main() {
	int x, y; cin >> x >> y;
	if (y >= 2 * x && y <= 4 * x) {
		if (y % 2 == 0)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main (int argc,char **argv)
{
	int a,b,c;

	scanf("%d",&a);

	b = a / 10;
	c = a % 10;

	if ((b == 9) || (c == 9))
	{
		printf("Yes\n");
	}

	else 
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Pair implements Comparable {
    int p;
    int y;
    int shiIdx;

    Pair(int p, int y, int shiIdx) {
        this.p = p;
        this.y = y;
        this.shiIdx = shiIdx;
    }

    @Override
    public int compareTo(Object o) {
        Pair other = (Pair) o;
        return this.y - other.y;
    }
}


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();

        Pair[] pairs = new Pair[M];
        for (int i = 0; i < M; i++) {
            int p = sc.nextInt();
            int y = sc.nextInt();
            pairs[i] = new Pair(p, y, i);
        }

        Arrays.sort(pairs);

        int[] count = new int[N+1];
        String[] ids = new String[M];

        for (int i = 0; i < M; i++) {
            Pair pair = pairs[i];
            count[pair.p]++;
            int num = count[pair.p];

            // pair.pを6桁に変換 + numを6桁に変換 = id
            ids[pair.shiIdx] = String.format("%06d", pair.p) + String.format("%06d", num);
        }

        for (int i = 0; i < M; i++) {
            System.out.println(ids[i]);
        }
    }
}

Measured memory_bytes: 168072
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  while (true) {
    ll n;
    cin >> n;
    if (n == 0)
      break;

    for (ll i = 100000; i > 0; i--) {
      ll m = 2 * n - i * i + i;
      ll div = 2 * i;
      if (m % div == 0 && m / div > 0) {
        cout << m / div << " " << i << endl;
        break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll A,B;
  cin>>A>>B;
  ll ans=max(A+B,A-B);
  ans=max(ans,A*B);
  cout<<ans<<endl;
}

Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <functional>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <algorithm>

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	puts((n + 1) / 2 >= k ? "YES" : "NO");
    return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b>=c)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
def main():
    n, a, b, c, d = map(int, input().split())
    s = input()
    r = 'Yes'
    if ('##' in s[a-1:c]) or ('##' in s[b-1:d]):
        r = 'No'
    else:
        if (c>d) and not ('...' in s[b-2:d+1]):
            r = 'No'
    print(r)

main()

Measured memory_bytes: 3572
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Unsafe #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
-- import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import System.IO

main :: IO ()
main = do
  n <- read <$> getLine :: IO Int
  as <- IMS.fromListWith (+)  . map (,1::Int) .
        unfoldr (BS.readInt . BS.dropWhile (==' ')) <$>
          BS.getLine
  print $ query as 0

counterpart :: Int -> Int
counterpart larger = bit highestplus1 - larger
  where
    highestplus1 = finiteBitSize larger - countLeadingZeros larger

query :: IntMap Int -> Int -> Int
query !as !acc | IMS.null as = acc
query !as !acc
  | k == k' = query as' (acc + count1 `div` 2)
  | otherwise = query rest $ acc + min count1 count2
  where
    ((k, count1), as') = IMS.deleteFindMax as
    k' = counterpart k
    (cnt2, rest) = IMS.updateLookupWithKey
                   (\_ count2 -> if count1 <= count2
                                 then Just (count2 - count1)
                                 else Nothing)
                   k' as'
    count2 = fromMaybe 0 cnt2


Measured memory_bytes: 35964
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

ll dp[41][(1<<18)];

void add(ll &a,ll b){
    a=(a+b)%MOD;
}

int main(){
  int N,X,Y,Z;
  cin>>N>>X>>Y>>Z;

  int mask=(1<<(X+Y+Z+1))-1;
  int ng=0;
  ng|=(1<<(Z-1));
  ng|=(1<<(Z+Y-1));
  ng|=(1<<(Z+Y+X-1));

  dp[0][0]=1;
  for(int i=0;i<N;i++){
      for(int j=0;j<=mask;j++){
          for(int k=1;k<=10;k++){
              int ns=(j<<1)&mask;
              ns++;
              for(int l=1;l<k;l++) ns=(ns<<1)&mask;
              if((ns&ng)==ng) continue;

              add(dp[i+1][ns],dp[i][j]);
          }
      }
  }

  ll ans=1;
  for(int i=1;i<=N;i++) ans=ans*10%MOD;

  for(int j=0;j<=mask;j++){
      ans=(ans-dp[N][j])%MOD;
      add(ans,MOD);
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 82176
import Foundation
func toTuple<T>(_ args: [T]) -> (T, T, T) { (args[0], args[1], args[2]) }
func readInts() -> [Int] { readLine()!.split(separator: " ").map { Int($0)! } }

let (w, a, b) = toTuple(readInts())
let d = max(a, b) - (min(a, b) + w)
print(d < 0 ? 0 : d)

Measured memory_bytes: 13428
#include<bits/stdc++.h>
using namespace std;
int n,k,ans=1;
int main(int argc, char const *argv[])
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    ans+=(ans<k?ans:k);
    printf("%d\n",ans);
    return 0;
}

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

#define endl '\n'
#define LL long long
#define MP make_pair
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define FORR(i, a, b) for(int i = b - 1; i >= a; --i)
#define EB push_back
#define ST first
#define ND second
#define S size()
#define RS resize

using VI = vector<int>;
using VVI = vector<VI>;
using PI = pair<int, int>;
using VPI = vector<PI>;
using VVPI = vector<VPI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;

int main()
{ 
     int n, k;
     cin >> n >> k;;
     VI h(n), dp(n);
     REP(i, n)
     {
         cin >> h[i];
         dp[i] = 1000000001;
     }
     dp[0] = 0;
     FOR(i, 1, n)
     {
		 int j = i - 1;
		 while (j >= 0 && j >= i - k)
		 {
			 dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
			 j--;
		 }
	 }
     cout << dp[n - 1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int N_MAX = 1e5+10;
char str[N_MAX];

int main() {
	scanf("%s", str);
	int n = strlen(str);
	int ans=0;
	for(int i=1; i<n; i++) {
		if(str[i] != str[i-1])
			ans++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long A = long.Parse(str[0]);
		long B = long.Parse(str[1]);
		long ans = A-B;
		if(B==1){
			ans = 0;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
bool pcom(pair<ll,ll> a,pair<ll,ll> b){
  if(a.second!=b.second) return a.second<b.second;
  else a.first<b.first;
}

int main(){
  ll N,C,K,t=-1,m=INF,cnt=0;
  cin>>N>>C>>K;
  ll T[N];
  for(ll i=0;i<N;i++) cin>>T[i];
  sort(T,T+N);
  for(ll i=0;i<N;i++){
    if(T[i]<=t+K&&m+1<=C) m++;
    else{
      t=T[i];
      m=1;
      cnt++;
    }
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

const int INF = 1 << 30;

struct Edge {
    int to; int cap; int rev;
    Edge(int t, int c, int r) : to(t), cap(c), rev(r) {}
};

struct Flow {
    vector <vector<Edge>> G;
    vector<bool> used;
    Flow(int n) : G(n), used(n, false) {}
    void add_edge(int from, int to, int cap) {
        G[from].push_back(Edge(to, cap, G[to].size()));
        G[to].push_back(Edge(from, 0, G[from].size() - 1));
    }
    int dfs(int v, int t, int f) {
        if (v == t) return f;
        used[v] = true;
        for (int i = 0; i < G[v].size(); i++) {
            Edge &e = G[v][i];
            if (!used[e.to] && e.cap > 0) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
    int max_flow(int s, int t) {
        int flow = 0;
        while (1) {
            fill(used.begin(), used.end(), false);
            int f = dfs(s, t, INF);
            if (f == 0) return flow;
            flow += f;
        }
    }
};

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

    Flow fl(n*2+2);
    int a[n], b[n], c[n], d[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        fl.add_edge(n*2, i, 1);
    }
    for (int i = 0; i < n; i++) {
        cin >> c[i] >> d[i];
        fl.add_edge(n+i, n*2+1, 1);
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (a[i] < c[j] && b[i] < d[j]) {
                fl.add_edge(i, n+j, 1);
            }
        }
    }

    cout << fl.max_flow(n*2, n*2+1) << "\n";
    return 0;
}

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

struct init_ { init_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } init_;

template<class C> using iodef_rng_t = typename enable_if<decltype(declval<C>().begin(), true_type{})::value && !is_same<C, string>::value>::type;
template<class C, class = iodef_rng_t<C>> istream& operator>>(istream& in, C& c) { for (auto& v : c) { in >> v; } return in; }
template<class C, class = iodef_rng_t<C>> ostream& operator<<(ostream& out, const C& c) { int i = 0; for (const auto& v : c) { if (i++) { out << ' '; } out << v; } return out; }
template<size_t N, class T, class R> using when_last = typename enable_if<N == tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N, class T, class R> using when_init = typename enable_if<N != tuple_size<remove_reference_t<T>>::value - 1, R>::type;
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_last<N, T, istream&> { return in >> get<N>(t); }
template<size_t N = 0, class T> auto operator>>(istream& in, T&& t) -> when_init<N, T, istream&> { return operator>><N + 1>(in >> get<N>(t), forward<T>(t)); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_last<N, T, ostream&> { return out << get<N>(t); }
template<size_t N = 0, class T> auto operator<<(ostream& out, const T& t) -> when_init<N, T, ostream&> { return operator<<<N + 1>(out << get<N>(t) << ' ', t); }

#ifdef LOCAL
template<class T> void trace_(const char* s, const T& v) { cerr << s << "=" << v; }
template<class T, class... Ts> void trace_(const char* s, const T& v, const Ts&... vs) { for (; *s != ','; ++s) { cerr << *s; } cerr << "=" << v << ","; trace_(++s, vs...); }
#define TRACE(...) (cerr << "\033[2m\033[33m", trace_(#__VA_ARGS__, __VA_ARGS__), cerr << "\033[0m\n")
#else
#define TRACE(...)
#endif

int main() {
    int n; int64_t k;
    cin >> n >> k;
    vector<int> a(n);
    cin >> a;
    for (int& ai : a) ai--;
    vector<int> d(n, -1);
    int v = 0;
    d[v] = 0;
    int last;
    while (true) {
        if (d[a[v]] == -1) {
            d[a[v]] = d[v] + 1;
            v = a[v];
        } else {
            last = v;
            break;
        }
    }
    TRACE(k);
    if (k > d[last]) {
        k = d[a[last]] + (k - d[a[last]]) % (d[last] - d[a[last]] + 1);
    }
    TRACE(k);
    v = 0;
    for (int i = 0; i < k; i++) {
        v = a[v];
    }
    cout << v + 1 << '\n';
}


Measured memory_bytes: 4792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,s,n) for(int i = s; i < (int)(n); i++)

int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,0,n) cin >> a[i];
  ll sum = a[0],xum = a[0],ans = 0;
  int r = 0;
  rep(l,0,n){
    while(r < n && sum == xum){
      r++;
      sum += a[r];
      xum ^= a[r];
    }
    ans += r-l;
    if(l == r) r++;
    sum -= a[l];
    xum ^= a[l];
  }
  cout << ans << endl;
}

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

double ds(double x1,double y1,double x2,double y2){
  return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

int main(){
  int n;
  while(1){
  cin>>n;
  if(n==0)break;
  double x[310],y[310];
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i];
  }

  int ma=1;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      double d=ds(x[i],y[i],x[j],y[j]);
      if(d>2.0)continue;
      double tx=(x[i]+x[j])/2;
      double ty=(y[i]+y[j])/2;
      double k=sqrt(1-(d/2.0)*(d/2.0));
      double vx,vy,tvx,tvy;
      vx=x[i]-tx;
      vy=y[i]-ty; 
      tvx=-vy;
      tvy=vx;
      double l=sqrt(tvx*tvx+tvy*tvy);
      tvx/=l;
      tvy/=l;
      int cnt=2;
      // cout<<tvx<<" "<<tvy<<endl;
      double ox,oy;
      ox=tx+tvx*k;
      oy=ty+tvy*k;
      //cout<<ox<<" "<<oy<<endl;
      for(int k=0;k<n;k++){
	   if(i==k||j==k)continue;
	   if(ds(ox,oy,x[k],y[k])<=1)cnt++;
      }
      ma=max(ma,cnt);
      cnt=2;
      ox=tx-tvx*k;
      oy=ty-tvy*k;
      //cout<<ox<<" "<<oy<<endl;
      for(int k=0;k<n;k++){
	   if(i==k||j==k)continue;
	if(ds(ox,oy,x[k],y[k])<=1)cnt++;
      }
      ma=max(ma,cnt);
    }
  }
  cout<<ma<<endl;
}
  return 0;
}



Measured memory_bytes: 3156
import typing


class DSU:
    '''
    Implement (union by size) + (path compression)
    Reference:
    Zvi Galil and Giuseppe F. Italiano,
    Data structures and algorithms for disjoint set union problems
    '''

    def __init__(self, n: int = 0):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a: int, b: int) -> int:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        x = self.leader(a)
        y = self.leader(b)

        if x == y:
            return x

        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x

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

        return x

    def same(self, a: int, b: int) -> bool:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        return self.leader(a) == self.leader(b)

    def leader(self, a: int) -> int:
        assert 0 <= a < self._n

        if self.parent_or_size[a] < 0:
            return a

        self.parent_or_size[a] = self.leader(self.parent_or_size[a])
        return self.parent_or_size[a]

    def size(self, a: int) -> int:
        assert 0 <= a < self._n

        return -self.parent_or_size[self.leader(a)]

    def groups(self) -> typing.List[typing.List[int]]:
        leader_buf = [self.leader(i) for i in range(self._n)]

        result = [[] for _ in range(self._n)]
        for i in range(self._n):
            result[leader_buf[i]].append(i)

        return list(filter(lambda r: r, result))


n, m = map(int, input().split())
g = DSU(n)
ab = [tuple(map(int, input().split())) for _ in range(m)]
for a, b in ab:
    g.merge(a - 1, b - 1)
print(len(g.groups()) - 1)

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

const int maxn = 440000;

template <typename T>
struct WinnerTree {
	int m;
	T b[1<<20];
	void build(T *a, int n) {
		m = 1<<(32-__builtin_clz(n));
		for (int i = 0; i < m; i++) b[m+i] = ((i < n) ? a[i] : a[0]);
		for (int i = m-1; i >= 0; i--) b[i] = min(b[i+i], b[i+i+1]);
	}
	void update(int p, T x) {
		for (p += m, b[p] = x, p >>= 1; p; p >>= 1) b[p] = min(b[p+p], b[p+p+1]);
	}
	T get(int l, int r) {
		l += m, r += m;
		assert(l < r);
		T ret = b[l];
		while (l < r) {
			if (l & 1) ret = min(ret, b[l]);
			if (r & 1) ret = min(ret, b[r-1]);
			l = l+1>>1, r >>= 1;
		}
		return ret;
	}
};

WinnerTree<pair<int, int>> wt1, wt2;

int p[maxn];
pair<int, int> p1[maxn];
pair<int, int> p2[maxn];
pair<int, int> res[maxn];
vector<int> g[maxn];
int o = 0;

inline void solve(int l, int r, int p) {
	if(l >= r) return;
	pair<int, int> fir, sec;
	if(l & 1) {
		fir = wt2.get(l / 2, r / 2);
		sec = wt1.get((fir.second + 1) / 2, (r + 1) / 2);
	} else {
		fir = wt1.get(l / 2, r / 2);
		sec = wt2.get(fir.second / 2, r / 2);
	}
	res[++ o] = make_pair(fir.first, sec.first);
	g[p].push_back(o);
	int no = o;
	solve(l, fir.second, no);
	solve(fir.second + 1, sec.second, no);
	solve(sec.second + 1, r, no);
}

struct comp {
	bool operator () (const int& i, const int& j) {
		return res[i].first > res[j].first;
	}
};

priority_queue<int, vector<int>, comp> q;
vector<int> ans;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for(int i = 0; i < n; ++ i) cin >> p[i];
	for(int i = 0; i < n; i += 2) p1[i / 2] = make_pair(p[i], i);
	for(int i = 1; i < n; i += 2) p2[i / 2] = make_pair(p[i], i);
	wt1.build(p1, n / 2); wt2.build(p2, n / 2);
	solve(0, n, 0);
	q.push(1);
	while(!q.empty()) {
		int cur = q.top(); q.pop();
		ans.push_back(res[cur].first);
		ans.push_back(res[cur].second);
		for(auto v : g[cur]) q.push(v);
	}
	assert(ans.size() == n);
	for(int i = 0; i < n; ++ i) cout << ans[i] << " \n"[i == n - 1];
	return 0;
}


Measured memory_bytes: 51572
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
	int a,b,c,x,y;
	scanf("%d%d%d%d%d",&a,&b,&c,&x,&y);
	if (a+b<=2*c) printf("%d\n",a*x+b*y);
	else printf("%d\n",min(2*c*min(x,y)+a*(x-min(x,y))+b*(y-min(x,y)),2*c*max(x,y)));
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int A, B;
    cin >> A >> B;
    cout << (3 * A + B) / 2 << endl;
    return 0;
};


Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())
y=tx-sx
x=ty-sy
path=""
path+="U"*x+"R"*y+"D"*x+"L"*y
path+="L"+"U"*(x+1)+"R"*(y+1)+"D"+"R"+"D"*(x+1)+"L"*(y+1)+"U"
print(path)

Measured memory_bytes: 3060
// ---------- begin SegmentTree Point update Range query ----------
mod segment_tree {
    pub struct PURQ<T: Clone, F: Fn(T, T) -> T> {
        n: usize,
        a: Vec<T>,
        id: T,
        op: F,
    }
    #[allow(dead_code)]
    impl<T: Clone, F: Fn(T, T) -> T> PURQ<T, F> {
        pub fn new(n: usize, id: T, op: F) -> PURQ<T, F> {
            let mut k = 1;
            while k < n {
                k *= 2;
            }
            PURQ {
                n: k,
                a: vec![id.clone(); 2 * k],
                id: id,
                op: op,
            }
        }
        pub fn update(&mut self, x: usize, v: T) {
            let mut k = self.n + x;
            let a = &mut self.a;
            a[k] = v;
            k >>= 1;
            while k > 0 {
                a[k] = (self.op)(a[2 * k].clone(), a[2 * k + 1].clone());
                k >>= 1;
            }
        }
        pub fn update_tmp(&mut self, x: usize, v: T) {
            self.a[x + self.n] = v;
        }
        pub fn update_all(&mut self) {
            for k in (1..(self.n)).rev() {
                self.a[k] = (self.op)(self.a[2 * k].clone(), self.a[2 * k + 1].clone());
            }
        }
        pub fn find(&self, mut l: usize, mut r: usize) -> T {
            let mut p = self.id.clone();
            let mut q = self.id.clone();
            l += self.n;
            r += self.n;
            while l < r {
                if (l & 1) == 1 {
                    p = (self.op)(p, self.a[l].clone());
                    l += 1;
                }
                if (r & 1) == 1 {
                    r -= 1;
                    q = (self.op)(self.a[r].clone(), q);
                }
                l >>= 1;
                r >>= 1;
            }
            (self.op)(p, q)
        }
    }
}
// ---------- end SegmentTree Point update Range query ----------

use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let _n: usize = it.next().unwrap().parse().unwrap();
    let m = 100_000;
    let mut seg = segment_tree::PURQ::new(m + 1, (0, 0), std::cmp::max);
    for s in it {
        let a: usize = s.parse().unwrap();
        let v = seg.find(0, a);
        seg.update(a, (v.0 + 1, v.1 + a));
    }
    let ans = seg.find(0, m + 1).1;
    println!("{}", ans);
}

fn main() {
    run();
}



Measured memory_bytes: 5644
#!/usr/bin/env python3
#第一回日本最強プログラマー学生選手権-予選- A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

m,d = LI()
cnt = 0
for i in range(1,m+1):
    for j in range(1,d+1):
        k = str(j)
        if len(k) == 1:
            continue
        if int(k[0]) >= 2 and int(k[1]) >= 2:
            if int(k[0])*int(k[1]) == i:
                cnt += 1
print(cnt)


Measured memory_bytes: 40304
#include <bits/stdc++.h>
using namespace std;
const int N = 17, M = (1 << 16), mod = 1e9 + 7;
int jc[M], ny[M];

int add(int x, int y) {
  return (x += y) > mod ? x - mod : x;
}

void Add(int &x, int y) {
  x = add(x, y);
}

int sub(int x, int y) {
  return (x -= y) < 0 ? x + mod : x;
}

void Sub(int &x, int y) {
  x = sub(x, y);
}

int mul(int x, int y) {
  return 1ll * x * y % mod;
}

void Mul(int &x, int y) {
  x = mul(x, y);
}

int q_pow(int x, int y) {
  int ans = 1;
  for(; y; y >>= 1) {
    if(y & 1) Mul(ans, x);
    Mul(x, x);
  }
  return ans;
}

int nm[M];
void init() {
  jc[0] = 1;
  for(int i = 1; i < M; ++i) jc[i] = mul(jc[i - 1], i);
  for(int i = 1; i < M; ++i)
    nm[i] = nm[i >> 1] + (i & 1);
  ny[M - 1] = q_pow(jc[M - 1], mod - 2);
  for(int i = M - 2; i >= 0; --i)
    ny[i] = mul(ny[i + 1], i + 1);
}

int C(int x, int y) {
  if(x < y) return 0;
  return mul(jc[x], mul(ny[y], ny[x - y]));
}

int f[N][M], a[N];
int main() { 
  init();
  int n, m;
  scanf("%d%d", &n, &m);
  for(int i = 1; i <= m; ++i) scanf("%d", &a[i]);  
  sort(a + 1, a + m + 1);
  reverse(a + 1, a + m + 1);
  f[0][0] = 1;
  int tot = 1 << n;
  for(int j = 0; j < tot; ++j)
    for(int i = 1; i <= m; ++i) {
      Add(f[i][j], f[i - 1][j]);
      for(int k = 0; k < n; ++k) {
        if((j >> k) & 1) continue;
        int last = tot - j - a[i], sum = (1 << k);
        Add(f[i][j | (1 << k)], mul(mul(f[i - 1][j], C(last, sum - 1)), jc[sum]));
     }
  }
  int ans = 0;
/*  for(int i = 1; i <= m; ++i) 
    for(int j = 0; j < tot; ++j) {
    if(f[i][j]) printf("f[%d][%d] = %d\n", i, j, f[i][j]);
  }*/
  for(int i = 0; i <= tot; ++i) {
    if(nm[i] & 1) Sub(ans, mul(jc[tot - 1 - i], f[m][i]));
    else Add(ans, mul(jc[tot - 1 - i], f[m][i]));
  }
  printf("%d\n", mul(ans, tot));
  return 0;
}

/*
2 1
3

8
*/


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define ll long long
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define vi vector<int>
#define vl vector<long long>
#define pb push_back

int abs(int a){
    return ( a>0 ? a : -a );
}
int main(){
    int a;
    cin >> a;
    rep(i,0,100){
        rep(j,0,100){
            if(4*i+7*j==a){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}






Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		a += sc.next();
		int n = Integer.parseInt(a);
		boolean b = false;
		for (int i = 1; i * i <= n; i++) {
			if (n == i * i) {
				b = true;
				break;
			}
		}
		if (b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X,i) ((X>>i)&1)
#define REP(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define ina(x,n) rep(x_i,n) cin>>x[x_i]
#define outa(x,n) rep(x_i,n) cerr<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;

const int MOD = 1e9+7;
const int INF = (1<<28);
const ll INFL = (1LL<<60);

int main() {
  int n; cin >> n;
  vl p(n); ina(p,n);
  ll mn = INF, ans = 0;
  rep(i,n) {
    if (p[i] <= mn) ans++;
    mn = min(mn, p[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef unsigned long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const double EPS = 1e-6;
const int MAX = 2005+1;
const int MAXX = MAX * MAX / 60 + 10;

LL DP[2][MAXX];
int A[MAX];

int main()
{
    int n;
    scanf("%d", &n);
    FOR(i, 0, n)
        scanf("%d", A + i);
    int sum = 0;
    FOR(i, 0, n)
        sum += A[i];
    DP[0][0] = 1;
    int lim = MAXX;
    int C = 0, N = 1;
    FOR(i, 0, n)
    {
        FOR(j, 0, lim)
        {
            DP[N][j] |= DP[C][j];
            int full = A[i] / 60;
            int part = A[i] % 60;
            int jj = j + full;
            LL res = (DP[C][j] << part) & ((1ULL << 60) - 1);
            LL res2 = (DP[C][j] >> (60 - part)) & ((1ULL << 60) - 1);
            if (jj < lim)DP[N][jj] |= res;
            if (jj + 1 < lim)DP[N][jj+1] |= res2;
        }
        swap(C, N);
        FOR(i, 0, lim)
            DP[N][i] = 0;
    }
    
    FOR(i, (sum + 1) / 2, sum+1)
    if ((DP[C][i / 60] & (1ULL << (i % 60))) > 0)
    {
        cout << i << endl;
        return 0;
    }
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
//#include <atcoder/all>
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; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    string S; cin >> S;
    REP(i,S.size()){
        if((i%2==0&&S[i]=='L') || (i%2==1&&S[i]=='R')){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

ll cal(ll b, ll n)
{
  ll ret = 0;
  while (n > 0) {
    ret += (n % b);
    n /= b;
  }
  return ret;
}

int main()
{
  ll N, S; scanf("%lld %lld", &N, &S);

  if (S >= N) {
    printf("%lld\n", (S == N) ? N + 1 : -1);
    return 0;
  }

  for (ll b = 2; b * b <= N; ++b) {
    if (cal(b, N) == S) {
      printf("%lld\n", b);
      return 0;
    }
  }

  ll val = N - S;
  ll ans = LLINF;
  for (ll p = 1; p * p <= val; ++p) {
    if (val % p != 0) { continue; }
    ll b = val / p + 1;
    if (b > sqrt(N) and cal(b, N) == S) {
      ans = min(ans, b);
    }
  }
  printf("%lld\n", ans == LLINF ? -1 : ans);
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  string x;cin>>x;
  ll s=0,t=0;
  rep(i,x.size()){
    if(x[i]=='S')s++;
    if(x[i]=='T')t=min(s,t+1);
  }
  cout<<x.size()-2*t<<endl;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <queue>
#include <climits>

using namespace std;

typedef long long ll;

const int MAXN = 200000+5;
int p[MAXN];
int t;

int main()
{
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout); 
    int n,k;
    while(cin>>n>>k) {
        for(int i=0;i<n;++i) cin>>p[i];
        int max_sum = 0;
        int sum = 0;
        for(int i=0;i<k;++i) sum += p[i];
        max_sum = sum;
        for(int i=k;i<n;++i) {
            sum = sum + p[i] - p[i-k];
            if(sum > max_sum) max_sum = sum;
        }
        double result = ((double)max_sum+k) / 2.0;
        //cout<<result<<endl;
        printf("%.8lf\n", result);
    }
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  string T;
  cin>>T;
  int tmp=0;
  int ans=0;
  for(int i=0;i<T.size();i++){
    if(T.at(i)=='A'||T.at(i)=='C'||T.at(i)=='G'||T.at(i)=='T'){
      tmp++;
      ans=max(ans,tmp);
    }else{
      tmp=0;
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int x = tx - sx;
	int y = ty - sy;
	rep(i, x) cout << "R";
	rep(i, y) cout << 'U';
	rep(i, x) cout << "L";
	rep(i, y) cout << 'D';
	cout << "L";
	rep(i, y + 1) cout << 'U';
	rep(i, x + 1) cout << 'R';
	cout << "D";
	cout << 'R';
	rep(i, y + 1) cout << 'D';
	rep(i, x + 1) cout << 'L';
	cout << 'U' << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if (h == 0 && w == 0) {
                sc.close();
                return;
            }
            for (int i = 0; i < w; i++) {
                System.out.print("#");
            }
            System.out.println();
            for (int i = 1; i < h - 1; i++) {
                for (int j = 0; j < w; j++) {
                    if (j == 0 || j == w - 1) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.println();
            }
            for (int i = 0; i < w; i++) {
                System.out.print("#");
            }
            System.out.println();
            System.out.println();
        }
    }
}


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

bool f [100001];
int c [100002];
int N ,L , R ;
int main ()
{
for ( int i =2; i <=100000; i ++) if (! f [ i ]) for ( int j = i + i ;j <=100000; j += i )
f[ j ]= true ;
for ( int i =3; i <=100000; i +=2) if (! f [ i ]&&! f [( i +1)/2]) c [ i ]++;
for ( int i =3; i <=100000; i ++) c [ i ]+= c [i -1];
scanf ("%d " ,& N );
while (N--)
{
scanf ("%d %d " ,&L ,& R );
printf ("%d\n" , c [ R ] - c [L -1]);
}
}


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

int N;
int Y;

int main(int argc, char **argv)
{
	cin >> N >> Y;

	int a, b, c;
	for (a = 0; a <= N; ++a)
	{
		for (b = 0; b <= N; ++b)
		{
			if (a + b > N) break;
			c = N - a - b;
			if (c*1000 + b*5000 + a*10000 == Y)
				goto exit;

		}
	}

	if (a + b + c > N) {a = -1; b = -1; c = -1;}
 exit:
	std::cout << a << " " << b << " " << c<< std::endl;
}


Measured memory_bytes: 256
import sys
N, M = map(int, input().split())
X = list(map(int,input().split()))
X.sort()
dis = []
if N-1 >= M-1:
    print(0)
    sys.exit()
for i in range(M-1):
    dis.append(abs(X[i+1]-X[i]))
dis.sort()
for i in range(N-1):
    del dis[-1]
print(sum(dis))

Measured memory_bytes: 13968
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;

ll n,t;
pair< ll , ll > arr[200010];

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n;
    for(ll i=0; i<n; i++) cin >> arr[i].se >> arr[i].fi;
    sort(arr,arr+n);

    for(ll i=0; i<n; i++){
        t+=arr[i].se;
        if(t>arr[i].fi){
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";

    return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];
    ll n2 = 0, n4 = 0;
    rep(i,n){
        if(v[i]%4==0) n4++;
        else if(v[i]%2==0) n2++;
    }
    if(n4*2+1 >=n) cout << "Yes" << endl;
    else if(n2>=n-n4*2) cout<<"Yes" << endl;
    else if(n2>=n) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

N = int(input())
S = input()
S = S.lower()
enc = ""

for char in list(S):
    ASCII = ord(char)
    num = ASCII - 97
    num = (num + N) % 26
    ASCII = num + 97
    enc += chr(ASCII)

print(enc.upper())

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef long double td;
typedef vector<td> vd;
typedef pair<ll,ll> ii;
typedef vector<ii> vii; typedef vector<bool> vb;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(ll i = ll(a); i < (ll)(b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define show(v,n) cerr << #v << " = "; forn(i,n) cerr << v[i] << " "; cerr << endl;
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
int MAXN = 500005;

struct nodo
{
	int v, anti, antj;
	char a;
};

nodo SET(int v, int i, int j, char a)
{
	nodo aux;
	aux.v = v; aux.anti=i; aux.antj=j; aux.a=a;
	return aux;
}

string LCS(string s1, string s2)
{
	vector < vector <nodo> > dp(3005,vector <nodo>(3005));
	int n=s1.size(), m=s2.size();
	
	forn(i,n+1)
	{
		forn(j,m+1)
		{
			if(i==0 || j==0) continue;
			if(s1[i-1]==s2[j-1])
			{
				dp[i][j]=SET(dp[i-1][j-1].v+1,i-1,j-1,s1[i-1]);
				continue;
			}
			if(dp[i-1][j].v > dp[i][j-1].v)
			{
				dp[i][j]=SET(dp[i-1][j].v,i-1,j,'a');
			}
			else dp[i][j]=SET(dp[i][j-1].v,i,j-1,'a');
		}
	}
	
	string ans;
	while(n!=0 && m!=0)
	{
		if(dp[n][m].anti == n-1 && dp[n][m].antj == m-1) ans.pb(dp[n][m].a);
		int aux = n;
		n=dp[n][m].anti; m=dp[aux][m].antj;
	}
	reverse(all(ans));
	return ans;
}
 
int main()
{ 	
	FIN;
	#ifdef input
		freopen("test1.txt", "r", stdin);
	#endif

	string s1, s2;
	cin >> s1 >> s2;
	cout << LCS(s1,s2) << endl;
    return 0;
}


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

int main(void)
{
    long long n, sum, a, i, b;
    cin >> n;
    sum = 1;
    b = 1;
    a = 1;

    for (i = 0; i < n; i++)
    {
        sum = (10 * sum) % 1000000007;
        b = (9 * b) % 1000000007;
        a = (8 * a) % 1000000007;
    }
    while (sum - 2 * b + a < 0)
    {
        sum += 1000000007;
    }
    if (n == 1)
    {
        cout << "0" << endl;
    }
    else
    {
        cout << sum - 2 * b + a << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(){
	int a, b, c, n;
	n = 0;
	scanf("%d %d %d", &a,&b,&c);
	if(a>=1&&b>=1&&c<=100){
		if(a != b) n++;
		if(a != c) n++;
		if(b != c) n++;
		if(n == 0) printf("1");
		else printf("%d\n", n);}

	return 0;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()
auto &errStream = cerr;
#ifdef LOCAL
#define cerr (cerr << "-- line " << __LINE__ << " -- ")
#else
class CerrDummy {
} cerrDummy;
template <class T> CerrDummy &operator<<(CerrDummy &cd, const T &) {
  return cd;
}
using charTDummy = char;
using traitsDummy = char_traits<charTDummy>;
CerrDummy &operator<<(CerrDummy &cd,
                      basic_ostream<charTDummy, traitsDummy> &(
                          basic_ostream<charTDummy, traitsDummy> &)) {
  return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr << "reached" << endl
#define DMP(x) cerr << #x << ":" << x << endl
#define ZERO(x) memset(x, 0, sizeof(x))
#define ONE(x) memset(x, -1, sizeof(x))

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

#define CAPITAL
void Yes(bool ex = true) {
#ifdef CAPITAL
  cout << "YES" << endl;
#else
  cout << "Yes" << endl;
#endif
  if (ex)
    exit(0);
}
void No(bool ex = true) {
#ifdef CAPITAL
  cout << "NO" << endl;
#else
  cout << "No" << endl;
#endif
  if (ex)
    exit(0);
}

const ll infLL = LLONG_MAX / 3;

#ifdef int
const int inf = infLL;
#else
const int inf = INT_MAX / 2 - 100;
#endif

signed main() {
  int N = read(), A = read(), B = read();

  print(A < B ? A : B, 2);
  print((A + B) - N < 0 ? 0 : (A + B) - N);

  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (L, R) = readLine()!!.split(" ").map { it.toLong() }

    var minMod = Long.MAX_VALUE

    for (i in L..R) {
        for (j in L..R) {
            if (i < j) {
                val mod = ((i) * (j) % 2019)

                if (mod == 0.toLong()) {
                    println(0)
                    return
                }

                minMod = Math.min(minMod, mod)
            }
        }
    }

    println(minMod)
}


Measured memory_bytes: 38004
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef vector<vector<int>> Graph;
void add_edge(Graph& g, int from, int to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

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

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

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

	ll n,k; cin >> n >> k;

	vector<ll> p(n), c(n);
	rep(i,n) { cin >> p[i]; p[i]--;}
	rep(i,n) { cin >> c[i]; }

  vector<vector<ll>> score(n, vector<ll>(n+1,0));
	vector<ll> loopCnt(n);

	rep(start, n) {
		ll sumi = 0;
		ll now = start, moveCnt = 0;
		while (p[now] != start) {
			sumi += c[p[now]];
			now = p[now];
			moveCnt++;
			score[start][moveCnt] = sumi;
		}
		++moveCnt;
		loopCnt[start] = moveCnt; 
		score[start][moveCnt] = sumi + c[p[now]];
	}

	//debug2D(score,3)

	ll ans = 0; rep(i,n) if(chmin(ans, c[i])) break;
	rep(start, n) {
		ll ansi = score[start][1];
		rep1(i, min(loopCnt[start], k)) { 
			chmax(ansi, ((k - i) / loopCnt[start]) * max(0LL, score[start][loopCnt[start]]) + score[start][i]);
		}

		//cerr << "start = " << start << " : " << ansi << endl;

		chmax(ans, ansi);
	}
	cout << ans << endl;
}



Measured memory_bytes: 198800
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;



void solve(){
    string s;
    cin >> s;
    if(s=="Sunny") cout << "Cloudy" << endl;
    else if(s=="Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
}

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

Measured memory_bytes: 256