akhauriyash/Code-Regression huggingface dataset:
/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* special cases (n=1?)
* 1LL<<i and not 1<<i
* overflow (ll vs int?)
* array bounds
* if you have no idea just guess the appropriate well-known algo instead of doing nothing :/
*/

// Author:: Subash Singha Roy
// Institution:: Jalpaiguri Government Engineering College

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod (ll)(998244353)
#define fr(i,a,b) for(ll i=a;i<b;i++)
#define frr(i,a,b) for(ll i=a-1;i>=b;i--)
#define tc(t) int t;cin >>t;while(t--)
#define pb emplace_back
#define ee emplace
#define rr return 0
#define mp make_pair
#define pr  pair <ll,ll>
#define ff first
#define ss second
#define pie 3.1415926535
#define inf 999999999999999999
ll mult(ll a,ll b, ll p=mod){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=mod){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = mod) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n%p; n = n * n%p;} return r;}
ll inv(ll a, ll p = mod) {return fpow(a, p - 2, p);}
bool sa(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second<b.second);}
bool fd(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.first>b.first);}
bool sd(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second>b.second);}
ll dx[4]={0,0,1,-1};
ll dy[4]={1,-1,0,0};
bool valid(ll x,ll y,ll n,ll m){
    if(x<0 || y<0){
       return false;
   }
   else if(x>=n || y>=m){
       return false;
   }
   else
   return true;
}

ll dp[3005][3005];
int main(){
    fio;
    ll n;
    cin>>n;
    ll a[n+5];
    fr(i,0,n){
        cin>>a[i];
    }
    for(ll l=n-1;l>=0;l--){
        for(ll r=l;r<n;r++){
            if(l==r){
                dp[l][r]=a[l];
            }
            else{
                dp[l][r]=max(a[l]-dp[l+1][r],a[r]-dp[l][r-1]);
            }
        }
    }
    cout<<dp[0][n-1]<<"\n";
    rr;
}

Measured memory_bytes: 70016
#include<iostream>
#include<cstdlib>
using namespace std;
struct Node{
	int key;
	Node *right, *left, *parent;
};
Node *root, *NIL;

Node *find(Node *u, int k){
	while(u!=NIL && k!=u->key){
		if(k<u->key)	u=u->left;
		else	u=u->right;
	}
	return u;
}
void insert(int k){
	Node *y=NIL;
	Node *x=root;
	Node *z;
	z=(Node *)malloc(sizeof(Node));
	z->key=k;
	z->left=NIL;
	z->right=NIL;

	while(x!=NIL){
		y=x;
		if(z->key < x->key){
			x=x->left;
		}
		else
			x=x->right;
	}
	z->parent=y;
	if(y==NIL){
		root=z;
	}else{
		if(z->key < y->key){
			y->left=z;
		}else{
			y->right=z;
		}
	}
}
void inorder(Node *u){
	if(u==NIL)	return ;
	inorder(u->left);
	cout<<" "<<u->key;
	inorder(u->right);
}
void preorder(Node *u){
	if(u==NIL)	return ;
	cout<<" "<<u->key;
	preorder(u->left);
	preorder(u->right);
}
int main(){
	int n, i, x;
	string com;
	cin>>n;
	while(n--){
		cin>>com;
		if(com=="insert"){
			cin>>x;
			insert(x);
		}
		else if(com=="print"){
			inorder(root);
			cout<<endl;
			preorder(root);
			cout<<endl;
		}
		else if(com=="find"){
			cin>>x;
			Node *t=find(root, x);
			if(t!=NIL)	cout<<"yes"<<endl;
			else	cout<<"no"<<endl;
		}
	}
	return 0;

}


Measured memory_bytes: 21900
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath> // sqrt
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

int main(void) {
    int num;
    cin >> num;
    vector<pii> arr(num);
    for(int i = 0; i < num; i++) {
        int a, b;
        cin >> a >> b;
        arr[i] = make_pair(a, b);
    }
    auto comp = [](pii a, pii b) {
        return (a.first+a.second) > (b.first+b.second);
    };
    sort(arr.begin(), arr.end(), comp);

    vector<int64_t> points(num);
    for(int i = 0; i < num; i++) {
        if(i%2 == 0) {
            points[0] += arr[i].first;
        } else {
            points[1] += arr[i].second;
        }
    }

    cout << points[0] - points[1] << endl;
    return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

int euclid(int a, int b)
{
    if (a < b)
        euclid(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    string s;
    string t;
    cin >> s >> t;

    vector<char> vs;
    vector<char> vt;

    for (int i = 0; i < s.size(); i++)
        vs.push_back(s[i]);
    for (int i = 0; i < t.size(); i++)
        vt.push_back(t[i]);

    sort(vs.begin(), vs.end());
    sort(vt.begin(), vt.end(), greater<char>());

    string ss = "";
    string tt = "";

    for (int i = 0; i < vs.size(); i++)
        ss += vs[i];
    for (int i = 0; i < vt.size(); i++)
        tt += vt[i];

    // cout << ss << endl;
    // cout << tt << endl;
    if (ss < tt)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main (void){
    int a,b,i,ans[5];
    for(i=0;i<4;i++){
        scanf("%d%d",&a,&b);
        if(a==1)ans[i]=6000*b;
        else if(a==2)ans[i]=4000*b;
        else if(a==3)ans[i]=3000*b;
        else if(a==4)ans[i]=2000*b;
    }
    for(i=0;i<4;i++){
        printf("%d\n",ans[i]);
    }
return 0;
}

Measured memory_bytes: 600
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse=True)
b = list(set(a))
b.sort(reverse=True)
l = len(b)
c = [0 for _ in range(l)]
prei = b[0]
j = 0
for i in a:
    if i != prei:
        j += 1
    c[j] += 1
    prei = i
x = []
for i in range(l):
    if c[i] >= 2:
        x.append(b[i])
if len(x) >= 2:
    ans = x[0] * x[1]
    for i in range(len(x)):
        if c[i] >= 4:
            ans  = max(ans, x[i] ** 2)
    print(ans)
else:
    print(0)


Measured memory_bytes: 14800
def gcd(a, b):
    while a:
        a, b = b % a, a
    return b


N = int(input())
A = list(map(int, input().split()))
r = 0
b = -1

for i in range(N):
    a = gcd(r, A[i]) if r != 0 else A[i]
    if a < r:
        b = i
    r = a

r3 = 0
for i in range(N):
    if i == b - 1:
        continue
    r3 = gcd(r3, A[i]) if r3 != 0 else A[i]

r4 = 0
for i in range(N):
    if i == b:
        continue
    r4 = gcd(r4, A[i]) if r4 != 0 else A[i]

d = sorted([(gcd(A[i], A[i + 1]), i) for i in range(N - 1)])
t = d[0][1]
r1 = 0
for i in range(N):
    a = A[i-1] if i == t + 1 else A[i]
    if r1 == 0:
        r1 = a
    else:
        r1 = gcd(r1, a)
r2 = 0
for i in range(N):
    a = A[i+1] if i == t else A[i]
    if r2 == 0:
        r2 = a
    else:
        r2 = gcd(r2, a)
print(max(r1, r2, r3, r4))


Measured memory_bytes: 20460
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
	
	int N,K,a,d;
	cin >> N >> K;
	int o[N];
	for(int i=0;i<N;i++){
		o[i] = 0;
	}

	for(int i=0;i<K;i++){
		cin >> d;
		for(int j=0;j<d;j++){
			cin >> a;
			o[a-1]++;
		}
	}

	int ans = 0;
	for(int i=0;i<N;i++){
		//cout << "o[" << i << "]=" << o[i] << endl; 
		if(o[i]==0)ans++;
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;

int main()
{
	int x,mx=1;
	while(cin>>x){
		for(int i=2;i*i<=x;i++){
				int t=i;
		//	cout<<t<<endl;
			//i的指数次方
			while(1){
				t*=i;
				if(t>x)
					break;
				if(t>mx)	mx=t;
			} 
		}
		cout<<mx<<endl;
	}	
	return 0; 
} 

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

int main() {
  int N, M, MOD = 1e9+7;
  cin >> N >> M;
  if (abs(N - M) >= 2) return cout << 0 << "\n", 0;
  long ans = 1;
  if (N == M) ans *= 2;
  while (N) ans = ans * N % MOD, N--;
  while (M) ans = ans * M % MOD, M--;
  cout << ans << "\n";
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Long[] array = new Long[6];
		int a = sc.nextInt();
		int b = sc.nextInt();
		for(int i=1;4>i;i++) {
			if(i!=a) {
				if(i!=b)
					System.out.println(i);
			}
		}
	}
}

Measured memory_bytes: 21972
n, k = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] * n
dp[1] = abs(h[1]-h[0])
for i in range(2, n):
  a = [0] * min(i,k)
  for j in range(1, min(i,k)+1): 
    a[j-1] = dp[i-j]+abs(h[i]-h[i-j])
  dp[i] = min(a)

print(dp[-1])

Measured memory_bytes: 52448
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  vector<ll> h(N);
  rep(i,N){
    cin >> h[i];
  }
  ll res = 0;
  while(*max_element(h.begin(),h.end()) >0){
    for(ll i = 0;i<N;i++){
      if(h[i] != 0){
        res++;
        ll j = i;
        while(j<N){
          if(h[j] != 0){
            h[j]--;
            i++;
            j++;
          }
         if(h[j] == 0) break;
        }
      }
    }
  }
 cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int dp[100005];

int dp_madarchod_cheez_hai(int h[],int n)
{
    for(int j=3;j<=n;j++)
        dp[j]=min(abs(h[j-1]-h[j-2])+dp[j-1],abs(h[j-1]-h[j-3])+dp[j-2]);
        //jab step 1 kam se aaya and minimum add krdiya
    return dp[n];
}

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(0);
    cout.tie(0);    
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++)
        cin>>h[i];
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(h[1]-h[0]);
    cout<<dp_madarchod_cheez_hai(h,n);
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
int r, g, b, n, ans;
int main(){
	scanf("%d%d%d%d", &r, &g, &b, &n);
	for(; n >= 0; n -= r) for(int m = n; m >= 0; m -= g){
		if(m%b == 0) ans++;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main(){
    int n,a,cnt=0;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a;
        while(1){
            if(a&1){
                break;
            }
            cnt++;
            a>>= 1;
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;

const int N=2e5+5;

void solve()
{
    int h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int val1=h1*60+m1;
    int val2=h2*60+m2;
    int res=val2-val1;
    cout<<max(0ll,res-k);
}

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //int t;
    //cin>>t;
    //while(t--)
        solve();
}


Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main{
	public static void main(String[] args){
		new Main().run();
	}
	public void run() {
		try {
			// インプットデータ取得
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			int cardNo = Integer.parseInt(br.readLine());

			// 施錠は"0"、開錠は"1"
			String openFlg = "0";

			ArrayList<String> cardList = new ArrayList<String>();
			for(int i = 0; i < cardNo; i++){
					cardList.add(br.readLine());
			}
			int touchNo = Integer.parseInt(br.readLine());
			for(int j = 0; j < touchNo; j++){
				String usr = br.readLine();
				if(!cardList.contains(usr)){
					System.out.println("Unknown " + usr);
				} else {
					if(openFlg.equals("1")){
						openFlg = "0";
						System.out.println("Closed by " + usr);
					} else {
						openFlg = "1";
						System.out.println("Opened by " + usr);
					}
				}
			}
		
		} catch (Exception e) {
			e.getStackTrace();
			System.exit(0);
		}
	}
}


Measured memory_bytes: 25488
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)



int main() {
	string s;
	ll cnt = 0;
	bool isRMode = true;
	in(s);

	ll n = s.size();
	vll ans(n, 0);

	rep(i, 0, n) {
		if (isRMode) {
			if (s[i] == 'R') {
				cnt++;
			}
			else {
				ans[i - 1] += cnt / 2;
				ans[i] += cnt / 2 + 1;
				if (cnt % 2 != 0) {
					ans[i -1] += 1;
				}
				isRMode = false;
				cnt = 1;
			}
		}
		else {
			if (s[i] == 'R') {
				isRMode = true;
				cnt = 1;
			}
			else {
				cnt++;
				if (cnt % 2 == 0) {
					ans[i - cnt]++;
				}
				else {
					ans[i - cnt+1]++;
				}

			}
		}

	}

		rep(i, 0, n) {
		outs(ans[i]);
	}
	outn("");

	return 0;

}


Measured memory_bytes: 1408
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

namespace n91 {

  using i8 = std::int_fast8_t;
  using i32 = std::int_fast32_t;
  using i64 = std::int_fast64_t;
  using u8 = std::uint_fast8_t;
  using u32 = std::uint_fast32_t;
  using u64 = std::uint_fast64_t;
  using isize = std::ptrdiff_t;
  using usize = std::size_t;

  struct rep {
    struct itr {
      usize i;
      constexpr itr(const usize i) noexcept : i(i) {}
      void operator++() noexcept { ++i; }
      constexpr usize operator*() const noexcept { return i; }
      constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
    };
    const itr f, l;
    constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
    constexpr auto begin() const noexcept { return f; }
    constexpr auto end() const noexcept { return l; }
  };
  struct revrep {
    struct itr {
      usize i;
      constexpr itr(const usize i) noexcept : i(i) {}
      void operator++() noexcept { --i; }
      constexpr usize operator*() const noexcept { return i; }
      constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
    };
    const itr f, l;
    constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
    constexpr auto begin() const noexcept { return f; }
    constexpr auto end() const noexcept { return l; }
  };
  template <class T> auto md_vec(const usize n, const T& value) {
    return std::vector<T>(n, value);
  }
  template <class... Args> auto md_vec(const usize n, Args... args) {
    return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
  }
  template <class T> constexpr T difference(const T& a, const T& b) noexcept {
    return a < b ? b - a : a - b;
  }
  template <class T> void chmin(T& a, const T& b) noexcept {
    if (b < a)
      a = b;
  }
  template <class T> void chmax(T& a, const T& b) noexcept {
    if (a < b)
      a = b;
  }
  template <class F> class rec_lambda {
    F f;

  public:
    rec_lambda(F&& f) : f(std::move(f)) {}
    template <class... Args> auto operator()(Args&&... args) const {
      return f(*this, std::forward<Args>(args)...);
    }
  };
  template <class F> auto make_rec(F&& f) { return rec_lambda<F>(std::move(f)); }
  template <class T> T scan() {
    T ret;
    std::cin >> ret;
    return ret;
  }
  constexpr char eoln = '\n';
  template <class T> T ceildiv(const T& l, const T& r) {
    return l / r + (l % r != 0 ? 1 : 0);
  }

} // namespace n91

namespace n91 {

  void main_() {
    /*
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    //*/
    const u32 h = scan<u32>();
    const u32 m = scan<u32>();
    const u32 h2 = scan<u32>();
    const u32 m2 = scan<u32>();
    const u32 k = scan<u32>();
    std::cout << (h2 * 60 + m2 - h * 60 - m - k) << std::endl;
  }

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
using namespace std;
struct D{
	int x, y;
};
int main(){
	int n, m, i, j, C[51] = {0}, t;
	D b[51], e[51];
	cin >> n >> m;
	for(i = 0; i < n; i++){
		cin >> b[i].x >> b[i].y;
	}
	for(i = 0; i < m; i++){
		cin >> e[i].x >> e[i].y;
	}
	for(i = 0; i < n; i++){
		int min = 400000000;
		for(j = 0; j < m; j++){
			if(min>abs(b[i].x-e[j].x)+abs(b[i].y-e[j].y)){
				min = abs(b[i].x-e[j].x)+abs(b[i].y-e[j].y);
				t = j+1;
			}
		}
		C[i] = t;
	} 
	for(i = 0; i < n; i++){
		cout << C[i] << endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    int n; cin >> n;
    vector<ll> a(n), b(n); rep(i,n) cin >> a[i], b[i] = a[i];
    sort(all(b));
    ll ans = 0;
    rep(i,n){
        ll id = lower_bound(all(b),a[i]) - b.begin();
        if((i-id)%2 != 0) ans++;
    }
    cout << ans/2 << endl;
    return 0;
}

Measured memory_bytes: 4808
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
  int l[200],n,i,ans;
  scanf("%d",&n);
  n<<=1;
  for(i=0;i<n;++i)
  {
    scanf("%d",&l[i]);
  }

  sort(l,l+n);
  ans=0;
  for(i=0;i<n;i+=2)
  {
    ans+=l[i];
  }
  printf("%d\n",ans);
  return 0;
}
/*
2
1 3 1 2
*/
/*
5
100 1 2 3 14 15 58 58 58 29
*/


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std ; 
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define endl "\n"
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define pii pair<int,int> 
long long M  = 1e9+7;
 
 
signed main(){
    fast;
    int x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y  << endl;
}


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

namespace Contest
{
	class Program
	{
		static void Main()
		{
			var S = Console.ReadLine().ToCharArray();
			Console.WriteLine(S.Length == S.Distinct().Count() ? "yes" : "no");
#if DEBUG
			Console.ReadKey();
#endif
		}
	}
}

Measured memory_bytes: 13276
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int INF=1001001001;
const int mod = 1000000007;

int main() {
  int N;
  cin>>N;
  if(N<=999){cout<<"ABC"<<endl;}
  else{cout<<"ABD"<<endl;}
  return 0;
}

Measured memory_bytes: 3624
#include<iostream> 
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int a[3];
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	sort(a, a + 3);
	cout << a[0];
	for (int i = 1; i < 3; i++) {
		cout << " " << a[i];
	}
	cout << endl;
}


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

int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	int f=1;
	for (int i = 0; i < 3; ++i)
	{
		if (s.at(i)==s.at(i+1))
		{
			f=0;
		}
	}
	if (f==1)
	{
		cout<<"Good\n";
	}
	else
	{
		cout<<"Bad\n";
	}
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))

N, Y = inpl()

yuki= Y//10000
tY = Y%10000
higu = tY//5000
tY = tY%5000
nogu = tY//1000

for y in range(0, yuki+1):
    if (Y - 9000*y - 1000*N)%4000 != 0:
        continue
    h = (Y - 9000*y - 1000*N)//4000
    n = N - y - h
    if (h>=0) and (n>=0):
        print("{} {} {}".format(y, h, n))
        break
else:
    print("-1 -1 -1")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{

	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		
		String str = scan.next();
		
		switch(str){
			case "Sunny":
				System.out.println("Cloudy");
				break;
			case "Cloudy":
				System.out.println("Rainy");
				break;
			case "Rainy":
				System.out.println("Sunny");
		}
	}
}

Measured memory_bytes: 20820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

int main(){
    ll N;
    cin>>N;
    vector<ll> a;
    rep(i,N){
        ll v;
        cin>>v;
        a.push_back(v);
    }
    ll s;
    rep(i,50){
        int count=0;
        rep(j,N){
            if(a[j]&(1<<i)) count++;
        }
        if(count%2==1) s|=(1<<i);
    }

    rep(i,N){
        ll count=0;
        rep(j,50){
            if(((s&(1<<j))&&(!(a[i]&(1<<j))))||((!(s&(1<<j)))&&(a[i]&(1<<j)))){
                count|=(1<<j);
            }
        }
    cout<<count<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 5284
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
using namespace std;

#define LL long long

const int CN = 1e5+5;
const LL INF = 0x3f3f3f3f3f3f3f2f;

LL read(){
    LL s = 0,ne = 1; char c = getchar();
    for(;c<'0'||c>'9';c=getchar()) if(c=='-') ne=-1;
    for(;c>='0'&&c<='9';c=getchar()) s=(s<<1)+(s<<3)+c-'0';
    return s*ne;
}

class fs{
  public: int to,nxt; LL di; void init(int t,int n,LL d) {to=t;nxt=n;di=d;}
}E[CN * 51];
int hd[CN],ecnt = 0;
void add(int x,int y,LL z) {E[++ecnt].init(y, hd[x], z); hd[x] = ecnt;}

int n,m;

/* DJ */
class DJ{
  public: int id; LL v; bool operator < (const DJ& a)const {return v > a.v;}
};
priority_queue<DJ> Q; 
LL d[CN]; bool vis[CN];
LL SP(int st,int ed){
    memset(vis, 0, sizeof(vis));
    memset(d, 0x3f, sizeof(d));
    Q.push((DJ){st, d[st] = 0});
    while(!Q.empty()){
        int u = Q.top().id; Q.pop();
        if(vis[u]) continue; vis[u] = true;
        for(int k = hd[u]; k; k = E[k].nxt){
            int v = E[k].to;
            if(d[v] > d[u] + E[k].di){
                d[v] = d[u] + E[k].di;
                if(!vis[v]) Q.push((DJ){v, d[v]});
            }
        }
    }
    return d[ed] < INF ? d[ed] : -1;
}

int main()
{
    n = read(); m = read();
    while(m--){
        int u = read(),v = read(); LL c = read();
        add(u, v, c); add(v, u, c);
    }
    for(int i=1;i<n;i++) add(i + 1, i, 0);

    printf("%lld", SP(1, n));
}

Measured memory_bytes: 8564
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;
using System.IO;

namespace paiza
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = GetLong();
            var B = GetDouble();
            long Bd = (long)((B+0.001) * 100);

            long ans = (A * Bd) / 100;

            Console.WriteLine(ans);

            return;
        }


    }
}

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

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

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

Measured memory_bytes: 27508
// https://atcoder.jp/contests/hitachi2020
import * as fs from "fs";

const stdin = fs.readFileSync("/dev/stdin", "utf8");
const split = stdin.split("\n");
Main(split);

function Main(inputLines: string[]) {
  const [A, B, M] = inputLines[0].split(" ").map(ele=>Number(ele));
  const a = inputLines[1].split(" ").map(ele=>Number(ele));
  const b = inputLines[2].split(" ").map(ele=>Number(ele));
  let min = 200000;
  for (let i = 3; i < 3 + M; i++) {
    const [x, y, c] = inputLines[i].split(" ").map(ele=>Number(ele));
    const cost = a[x-1] + b[y-1] - c;
    if (min > cost) {
      min = cost;
    }
  }
  const minA = Math.min.apply(null, a);
  const minB = Math.min.apply(null, b);
  if (min > (minA + minB)) {
    console.log(minA + minB);
    return;
  }
  console.log(min);
}


Measured memory_bytes: 53708
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>

using namespace std;

long long solve(vector<long long>& sset, vector<long long>& tset, long long x) {
	long long result = INT64_MAX;

	for(auto e : sset)
		for(auto e2 : tset) {
			long long tmp, tmp2;

			tmp = abs(x - e) + abs(e - e2);
			tmp2 = abs(x - e2) + abs(e2 - e);

			result = min(result, min(tmp, tmp2));
		}

	return result;
}

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

	int A, B, Q;

	vector<long long> S, T;

	cin >> A >> B >> Q;

	for (int a = 0; a < A; a++) {
		long long tmp;
		cin >> tmp;
		S.push_back(tmp);
	}

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

	for (int b = 0; b < B; b++) {
		long long tmp;
		cin >> tmp;
		T.push_back(tmp);
	}

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

	for (int q = 0; q < Q; q++) {
		vector<long long> sset, tset;
		long long x;

		cin >> x;

		auto iter_s = lower_bound(S.begin(), S.end(), x) - S.begin();
		auto iter_t = lower_bound(T.begin(), T.end(), x) - T.begin();

		if (iter_s == A)
			iter_s--;

		if (iter_t == B)
			iter_t--;

		if (iter_s > 0)
			sset.push_back(S[iter_s - 1]);
		if (iter_s < A - 1)
			sset.push_back(S[iter_s + 1]);
		sset.push_back(S[iter_s]);

		if (iter_t > 0)
			tset.push_back(T[iter_t - 1]);
		if (iter_t < B - 1)
			tset.push_back(T[iter_t + 1]);
		tset.push_back(T[iter_t]);

		cout << solve(sset, tset, x) << '\n';
	}
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::vector<int>G[200010];
int d[200010][2],del[200010],fa[200010];
char s[200010];
std::queue<int>que;
int hd(int x){return fa[x]==x?x:fa[x]=hd(fa[x]);}
void Union(int x,int y){
	x=hd(x),y=hd(y);
	if(x==y)puts("Yes"),exit(0);
	fa[x]=y;
}
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),m=gi(),a,b;
	scanf("%s",s+1);
	while(m--)a=gi(),b=gi(),G[a].push_back(b),G[b].push_back(a),++d[a][s[b]-'A'],++d[b][s[a]-'A'];
	for(int i=1;i<=n;++i)if(!d[i][0]||!d[i][1])del[i]=1,que.push(i);
	while(!que.empty()){
		int x=que.front();que.pop();
		for(int i:G[x])if(!--d[i][s[x]-'A']&&!del[i])del[i]=1,que.push(i);
	}
	for(int i=1;i<=n;++i)if(!del[i])fa[i]=i;
	for(int i=1;i<=n;++i)if(!del[i])for(int j:G[i])if(!del[j]&&j>=i)Union(i,j);
	puts("No");
	return 0;
}



Measured memory_bytes: 13440
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

ll modpow(ll a, ll n, ll m){
    if(n == 0) return 1;
    ll half = modpow(a,n/2,m);
    ll res = half * half % m;
    if(n & 1) res = res * a % m;
    return res;
}
int main(){
    int N; cin >> N;
    vector<int> D(N);
    rep(i,N) cin >> D[i];
    if(D[0] != 0){
        cout << 0 << endl;
        return 0;
    }
    map<int,int> mp;
    rep(i,N) mp[D[i]]++;
    ll ans = 1;
    int now = -1;
    int cnt = 1;
    for(auto u : mp){
        now++;
        if(u.first != now){
            cout << 0 << endl;
            return 0;
        }
        if(u.first == 0 && u.second > 1){
            cout << 0 << endl;
            return 0;
        }
        if(u.first != 0){
            ans *= (ll)modpow((ll)cnt,(ll)u.second,MOD);
            ans %= MOD;
            cnt = u.second;
        }
    }  
    cout << ans << endl;
}


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

#define endl '\n'

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

    long long n,k; cin >> n >> k;
    if (n < k) cout << min(n, k - n) << endl;
    else if (n == k || n % k == 0) cout << 0 << endl;
    else{
        n %= k;
        cout << min(n, k - n) << endl;
    }
}

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

const int MAX_N = 12;
const int INF = 100100100;

vector<int> c(MAX_N);
vector<vector<int>> a(MAX_N, vector<int>(MAX_N));
int n, m, x;
int ans = INF;

void dfs(int i, int cost, vector<int> p) {
    if (i == n) {
        bool ok = true;
        rep(j, m) {
            ok = ok && x <= p.at(j);
        }
        if(ok) ans = min(ans, cost);
        return;
    }
    dfs(i + 1, cost, p);
    rep(j, m) {
        p.at(j) += a.at(i).at(j);
    }
    dfs(i + 1, cost + c.at(i), p);
}

int main() {
    cin >> n >> m >> x;
    rep(i, n) {
        cin >> c.at(i);
        rep(j, m) {
            cin >> a.at(i).at(j);
        }
    }

    dfs(0, 0, vector<int>(m, 0));
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
function gets(str){
  this._s = str.split("\n");
  this._y = 0;
};
gets.prototype = {
  a: function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y] = s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  },
  l: function(f){
    var s = this._s[this._y++].split(" ");
    return f?s:s.map(a=>+a);
  },
  m: function(n,f){
    var s = this._s, y = this._y, r = [], i = 0;
    if(f)for(;i < n; i++)r[i] = s[y+i].split(" ");
    else for(;i < n; i++)r[i] = s[y+i].split(" ").map(a=>+a);
    this._y += n;
    return r;
  },
};
var o=new gets(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var a = {};
  var u = "";
  for(var i = 0; i < n; i++){
    var w = o.a(1);
    if(i)if(a[w] || u !== w[0])return "No";
    a[w] = 1;
    u = w[w.length-1];
  }
  return "Yes";
}

Measured memory_bytes: 21064
#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    
    string s;
    int nagasa;
    int judge=0;
    
    cin >> s;
    nagasa=s.size()-1;
    
    for(int i=0;i<nagasa;i++){
        if(s[i]=='A' && s[i+1]=='C'){
            judge=1;
            break;
        }
    }
    
    if(judge==1){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3


def main():
    import sys
    import numpy as np

    input = sys.stdin.readline

    N, D = map(int, input().split())
    res = 0
    for _ in [0] * N:
        x, y = map(int, input().split())
        if x ** 2 + y ** 2 <= D ** 2:
            res += 1
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 28032
#include<iostream>
using namespace std;
int main()
{
	int a,b,x;
	while(cin>>x>>a>>b)
	{
		int t=a-b;
		if(a-b>=0)
		cout<<"delicious"<<endl;
		else if(a-b+x<0)
		cout<<"dangerous"<<endl;
		else 
		cout<<"safe"<<endl;
	}
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll x,y; cin>>x>>y;
	if(x%y==0)
	{
		cout<<-1<<'\n';
	}
	else
	{
		cout<<x<<'\n';
	}
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  int m = max(A, max(B, C));
  if (((3*m) - (A + B + C)) % 2 != 0) {
    m++;
  }
  cout << ((3*m) - (A + B + C)) / 2 << endl;
  
  return 0;
}

Measured memory_bytes: 256
#define _GOOD_LUCK_MCLAREN_MCL32_
#define _GOOD_LUCK_FERNANDO_ALONSO_

#include <cstdio>
#include <cstring>
#include <climits>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <utility>
using namespace std;

typedef long long ll;
const ll MOD = (ll)1e9 + 7;
const size_t MAX_S = (int)2e5 + 5;

ll dp[MAX_S][2];
int main() {
    int N, M;
    cin >> N >> M;
    if (abs(N - M) > 1) return cout << "0\n", 0;
    ll res = 1;
    for (int i = 1; i <= N; i++) res = (res * i) % MOD;
    for (int i = 1; i <= M; i++) res = (res * i) % MOD;
    cout << (res * (2 - abs(N - M)) % MOD) << '\n';
    return 0;;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll W, a, b;
    cin >> W >> a >> b;

    if(b-(a+W) > 0){
        cout << b-(a+W) << endl;
        return 0;
    }
    if(a-(b+W) > 0){
        cout << a-(b+W) << endl;
        return 0;
    }
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3620
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def solve():
    a, b = map(int, input().split())
    if a == b or a % b == 0:
        print(0, 1)
    elif b % a == 0:
        print(1, 0)
    else:
        g = gcd(a, b)
        a //= g
        b //= g
        coe = [[1, 0], [0, 1]]
        while b != 1:
            quo = a // b
            coe_d1 = coe[1]
            coe_d2 = [coe[0][0] - coe[1][0] * quo, coe[0][1] - coe[1][1] * quo]
            coe = [coe_d1, coe_d2]
            a, b = b, a % b
        print(*coe[1])

solve()

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

int a[200001];
int temp[200001];

int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	
	while(k--)
	{
		for(int i=1;i<=n;i++)
		{
			temp[max(1,i-a[i])]++;
			temp[min(n+1,i+a[i]+1)]--;
		}
		
		int s=0;
		bool f=true;
		for(int i=1;i<=n;i++)
		{
			s+=temp[i];
			a[i]=s;
			if(a[i]!=n)
				f=false;
		}
		if(f)
			break;
		
		memset(temp,0,sizeof(temp));
	}
	for(int i=1;i<=n;i++)
		cout<<a[i]<<" ";
	return 0;
}

Measured memory_bytes: 5164
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n,num,i,j,idx;
    string c;
    int cards[4][13];
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            cards[i][j]=0;  
        }
    }
    cin>> num;
    for(i=0;i<num;i++){
        cin>> c>> n;
        n--;
        if(c=="S"){
            idx=0;
        }else if(c=="H"){
            idx=1;
        }else if(c=="C"){
            idx=2;
        }else if(c=="D"){
            idx=3;
        }else{
        }
        // cout<< idx<<" "<<n<< endl;
        cards[idx][n]= 1;
    }
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(cards[i][j]==0){
                switch(i){
                    case 0:
                        c="S";
                        break;
                    case 1:
                        c="H";
                        break;
                    case 2:
                        c="C";
                        break;
                    case 3:
                        c="D";
                        break;
                }
                cout<< c<< " "<< j+1<< endl;
            }
        }
   }
    return 0;
}

Measured memory_bytes: 1208
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1111111111;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s, t;
	cin >> s >> t;

	vector<vector<int>> dp(s.size() + 1, vector<int>(t.size() + 1));
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < t.size(); j++) {
			if (s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
			chmax(dp[i + 1][j + 1], max(dp[i][j + 1], dp[i + 1][j]));
		}
	}

	DMP(dp);

	int i = s.size(), j = t.size();
	string ans;
	while (i > 0 && j > 0) {
		if (dp[i][j] == dp[i - 1][j]) i--;
		else if (dp[i][j] == dp[i][j - 1]) j--;
		else i--, j--, ans = s[i] + ans;
	}

	cout << ans << "\n";

	return 0;
}

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

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

using ll = long long;
template<typename T>
void fill_all(T& arr, const T& v) {
    arr = v;
}
template<typename ARR, typename U>
void fill_all(ARR& arr, const U& v) {
    for(auto& i: arr){fill_all(i, v);}
}

int used[2000000];

int main(){
    
    while(1){
        int a, l;
        cin >> a>>l;
        if(a==0 && l==0){break;}
        fill_all(used, -1);

        size_t i = 0;
        for (; used[a] == -1 ; i++)
        {
            used[a] = i;
            string s = to_string(a);
            while(s.size()<l){
                s = "0"+s;
            }
            std::sort(s.begin(), s.end());
            int mmm = stoi(s);
            std::sort(s.begin(), s.end(), greater<>{});
            int maxmax = stoi(s);
            a = maxmax - mmm;            
        }
        cout << used[a] <<' ' << a << ' ' << i-used[a] << endl;
        
    }
    return 0;
}


Measured memory_bytes: 11092
using System;
using System.Linq;

namespace ABC085C
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var N = inputs[0];
            var Y = inputs[1];

            for (int a = 0; a <= N; a++)
            {
                for (int b = 0; a + b <= N; b++)
                {
                    int c = N - a - b;

                    var sum = 10000 * a + 5000 * b + 1000 * c;
                    if (sum == Y)
                    {
                        Console.WriteLine($"{a} {b} {c}");
                        return;
                    }
                }
            }
            Console.WriteLine("-1 -1 -1");
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    ll x, y; cin >> x >> y;
    int cnt = 0;
    while(x <= y) {
        x *= 2;
        cnt++;
    }
    cout << cnt;
}


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

#define ll long long int 

int main()
{
    ll a,b,c,tm;
    cin>>a>>b>>c;
    
    tm=a;
    a=b;
    b=tm;
    
    tm=a;
    a=c;
    c=tm;
    
    cout<<a<<" "<<b<<" "<<c<<endl;
}


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

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

int memo[200010];
int f(int x){
	if(x == 0) return 0;
	if(memo[x] != -1) return memo[x];
	int ans = 0;
	int tmp = x;
	while(x > 0){
		ans += x % 2;
		x /= 2;
	}

	return f(tmp % ans)+1;
}

signed main(){
	memset(memo, -1, sizeof(memo));
	int n;
	cin >> n;
	string s;
	cin >> s;

	int ans = 0;
	int s1 = 0;
	int s2 = 0;
	for(int i = 0;i < n;i++){
		ans += (s[i] == '1');
	}

	int tmp1[200010] = {};
	int tmp2[200010] = {};

	tmp1[n-1] = 1;
	tmp2[n-1] = 1;
	for(int i = n-2;i >= 0;i--){
		tmp1[i] = tmp1[i+1] * 2 % (ans+1);
		if(ans != 1){
			tmp2[i] = tmp2[i+1] * 2 % (ans-1);
		}
	}

	for(int i = 0;i < n;i++){
		s1 = (s1*2 + (s[i] == '1' ? 1 : 0)) % (ans+1);
		if(ans != 1){
			s2 = (s2*2 + (s[i] == '1' ? 1 : 0)) % (ans-1);
		}
	}

	for(int i = 0;i < n;i++){
		if(s[i] == '0'){
			cout << f((s1+(tmp1[i])) % (ans+1))+1 << endl;
		}else{
			if(ans == 1){
				cout << 0 << endl;
			}else{
				cout << f(((ans-1)+s2-(tmp2[i])) % (ans-1))+1 << endl;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 8440
from collections import Counter
def getinputdata():

    array_result = []
    
    array_result.append(input().split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()

arr = sorted([int(x) for x in arr_data[0]])

mindata = int(arr[0])
middledata = int(arr[1])
maxdata = int(arr[2])

sabun01 = middledata-mindata
sabun02 = maxdata-middledata
sabun03 = maxdata-mindata

#minをmiddleに寄せてから　middleをmax
if sabun01 % 2 == 0 :
    
    cnt01 = (sabun01 // 2) + sabun02 

elif sabun01 % 2 != 0 and sabun02 % 2 != 0:

    cnt01 = (sabun01 // 2) + 1 + 2 + sabun02-1

elif sabun01 % 2 != 0 and sabun02 % 2 == 0:
    
    cnt01 = (sabun01 // 2) + 1 + 1 + sabun02


#middleをmaxに寄せてから　minをmax
if sabun02 % 2 == 0 and sabun03 % 2 == 0:
    
    cnt02 = (sabun02 // 2) + sabun03
    
elif sabun02 % 2 == 0 and sabun03 % 2 != 0:
    
    cnt02 = (sabun02 // 2) + sabun03 + 2
    
elif sabun02 % 2 != 0:
    
    cnt02 = (sabun02 // 2) + 1  + 2 + sabun03-1
    
print(min(cnt01,cnt02))    
    

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

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 2000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

ll n,k;
ll a[NMAX];

ll div_floor(ll a, ll b) {
	return a / b - (((a ^ b) < 0) and a % b);
}
ll div_ceil(ll a, ll b) {
	return a / b + (((a ^ b) >= 0) and a % b);
}

ll f(ll lim)
{
    ll ans =0;

    for(int i =0; i< n; ++i)
    {
        if(a[i] == 0)
        {
            if(lim >= 0) ans +=n-1;
        }
        else if(a[i] > 0)
        {
            ll tmp = div_floor(lim, a[i]);
            int id =  int(upper_bound(a, a+n, tmp) - a);
            if(i < id)
                ans += (id-1);
            else
            {
                ans += id;
            }
            
        }
        else
        {
            ll tmp = div_ceil(lim, a[i]);
            int id = int(lower_bound(a, a + n, tmp) - a);
            if(i >= id) ans += n - id - 1;
            else
                ans += n - id;

        }        
    }
    return ans / 2;
}

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

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

    sort(a, a + n);

    ll low = -1e18, high = 1e18, ans = 0;

    while(low <= high)
    {
        ll mid = (low + high) / 2;
        if(f(mid) >= k)
        {
            high = mid-1;
            ans = mid;
        }
        else
        {
            low = mid+1;
        }
        
    }
    cout << ans;


    return 0;
}

Measured memory_bytes: 1792