akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cmath>
#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 N,M;
  cin >> N>>M;
  
  vector<vector<int>> hyou(M,vector<int>(2,0)); 
  REP(i,M)cin >>hyou[i][0]>>hyou[i][1];
  
  vector<vector<int>> connect(N+1);  
  REP(i,M){
    int l=hyou[i][0];
    int r=hyou[i][1];
    connect.at(l).push_back(r);
    connect.at(r).push_back(l);
  }
 vector<int>dist(N+1,-1);
  queue<int>que;
  dist[1] = 0;
  que.push(1);
  while (que.size() != 0){
    int v = que.front();
    que.pop();
    for(int nv:connect[v]){
     if (dist[nv] != -1)continue;
      dist[nv] = v;
      que.push(nv);
    }
  }
  cout <<"Yes"<<endl;
  FOR(i,2,N+1){
   cout <<dist[i]<<endl; 
  }
}

Measured memory_bytes: 21096
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1001001001;
const double EPS = 1e-10;

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

int h, w;
int board[10][10];
int label[10][10];
vi color;
vvi G;

void labeling(int y, int x, int id)
{
	label[y][x] = id;
	rep(i, 4){
		int py = y + dy[i];
		int px = x + dx[i];
		if(py<0 || h<=py || px<0 || w<=px)
			continue;
		if(board[py][px] == board[y][x] && label[py][px] == -1)
			labeling(py, px, id);
	}
}

bool dfs(vi cand, int now, int depth)
{
	if(depth == 0){
		rep(i, cand.size())
			if(cand[i] != 2)
				return false;
		return true;
	}
	
	vi tmp = cand;
	rep(c, 3){
		if(c == now)
			continue;
		
		bool found = false;
		rep(i, cand.size()){
			if(cand[i]==1 && color[i]==c){
				rep(j, G[i].size()){
					if(cand[G[i][j]] == 0)
						cand[G[i][j]] = 1;
				}
				cand[i] = 2;
				found = true;
			}
		}
		if(found){
			if(dfs(cand, c, depth-1))
				return true;
			cand = tmp;
		}
	}
	return false;
}

int main()
{
	while(scanf("%d%d", &w, &h), w){
		rep(i, h) rep(j, w){
			char c[5];
			scanf("%s", c);
			if(c[0] == 'R')
				board[i][j] = 0;
			else if(c[0] == 'G')
				board[i][j] = 1;
			else
				board[i][j] = 2;
		}

		rep(i, h)
			fill(label[i], label[i]+w, -1);

		color.clear();
		rep(i, h) rep(j, w){
			if(label[i][j] == -1){
				labeling(i, j, color.size());
				color.push_back(board[i][j]);
			}
		}

		G.assign(color.size(), vi());
		rep(i, h) rep(j, w){
			rep(k, 4){
				int py = i + dy[k];
				int px = j + dx[k];
				if(py<0 || h<=py || px<0 || w<=px)
					continue;
				if(label[i][j] != label[py][px]){
					G[label[i][j]].push_back(label[py][px]);
					G[label[py][px]].push_back(label[i][j]);
				}
			}
		}

		rep(i, G.size()){
			sort(G[i].begin(), G[i].end());
			G[i].erase(unique(G[i].begin(), G[i].end()), G[i].end());
		}

		for(int depth=0;; ++depth){
			vi cand(G.size(), 0);
			rep(i, G[0].size())
				cand[G[0][i]] = 1;
			cand[0] = 2;

			if(dfs(cand, color[0], depth)){
				printf("%d\n", depth);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1080
# import numpy as np
#N=int(input().strip())
#x=[0]*N
#y=[0]*N
#
#for i in range(N):
#    x[i],y[i]=list(map(int,input().strip().split()))

import sys

def power_l(x,power): # for mod
    if power==0:
        return 1
    elif power<0:
        print('error')
        sys.exit(1)
    res = 1
    sq = x%mod
    while(power>0):
        if power&1 > 0:
            res*=sq
            res=res%mod
        sq = sq**2 %mod
        power = power >> 1
    return res%mod

def inv(x): # x^(-1)=x^(p-2) mod
    ans = power_l(x,mod-2)
    return ans
##########################
mod = 10**9+7

X, Y = list(map(int,input().strip().split()))

if (X+Y)%3 !=0:
    print(0)
    sys.exit()
m = int((2*X-Y)//3)
n = int(X-2*m)

if m<0 or n<0:
    print(0)
    sys.exit()

# compute m+nCm=(m+n)!/(m!n!)
# make factorial
f=[1,1]
for i in range(m+n-1):
    f.append((f[i+1]*(i+2))%mod)

denom = (f[m]*f[n])%mod

ans=(f[m+n] * inv(denom)) %mod
print(ans)



Measured memory_bytes: 29484
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    class UnionFind(object):
        """
        query: O(Ack^-1(n,n)) (amortize)
        """
        def __init__(self,n):
            """
            param n: number of nodes
            """
            self.__par=list(range(n))
            self.__rank=[0]*n
            self.__size=[1]*n

        def __root(self,k):
            if self.__par[k]==k: return k
            else:
                self.__par[k]=self.__root(self.__par[k])
                return self.__par[k]

        def is_same(self,i,j):
            return self.__root(i)==self.__root(j)

        def unite(self,i,j):
            i=self.__root(i)
            j=self.__root(j)
            if i==j: return
            if self.__rank[i]>self.__rank[j]:
                self.__par[j]=i
            else:
                self.__par[i]=j
                if self.__rank[i]==self.__rank[j]: self.__rank[j]+=1

    # Kruskal's algorithm
    from operator import itemgetter
    n=int(input())
    P=[0]*n
    edges=[0]*(2*n-2)
    for i in range(n):
        x,y=map(int,input().split())
        P[i]=(x,y,i)
    # xでsort
    P.sort(key=itemgetter(0))
    for k in range(n-1):
        x0,y0,i=P[k]
        x1,y1,j=P[k+1]
        edges[k]=(i,j,min(abs(x0-x1),abs(y0-y1)))
    # yでsort
    P.sort(key=itemgetter(1))
    for k in range(n-1):
        x0,y0,i=P[k]
        x1,y1,j=P[k+1]
        edges[k+n-1]=(i,j,min(abs(x0-x1),abs(y0-y1)))
    # edgesをcostでsort
    edges.sort(key=itemgetter(2))
    # union findに突っ込んでいく
    tree=UnionFind(n)
    ans=0
    for i,j,cost in edges:
        if tree.is_same(i,j): continue
        tree.unite(i,j)
        ans+=cost
    print(ans)
resolve()

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
int main(void){
    
    // Your code here!
    ll h;
    cin >> h;
    ll ans = 1;
    if(h == 1){
        cout << ans << endl;
        return 0;
    } else if(h == 2){
        cout << 3 << endl;
        return 0;
    }
    ll cnt = 1;
    for(ll i = h; i > 1 ; i /= 2){
        
        if(i / 2 <= 0){
            cout << ans << endl;
            return 0;
        }
        ans += pow(2, cnt);
        cnt++;
    }
    cout << ans << endl;
}


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

int main() {
	long long n, sum = 0;
	cin >> n;
	for(int i = 1; i <= n; ++i){
		if(i % 3 != 0 && i % 5 != 0){
			sum += i;
		}
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 3632
from sys import stdin
import sys
import numpy as np
import collections
from functools import cmp_to_key
import heapq

##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    N, M = rip()
    S = [0] * M
    C = [0] * M
    for i in range(M):
        S[i], C[i] = rip()

    for i in range(1000):
        s = str(i)
        if len(s) != N: continue
        chk = True
        for j in range(M):
            chk &= s[S[j] - 1] == str(C[j])
        if chk:
            print(i)
            sys.exit(0)
    
    print(-1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 14468
#include<bits/stdc++.h>
using namespace std;
#define hackcyborg shresth_walia
#define ll  long long
#define int long long
#define ld  long double
#define pb push_back
#define mod 998244353
#define M_PI 3.141592653589
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll binpow(ll a,ll b,ll m=mod) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%m ;
        a = (a * a)%m ;
        b >>= 1;
    }
    return res;
}
ll qw[1000005];
main()
{   IO
    ll n;
    cin>>n;
    memset(qw,0,sizeof(qw));
    ll a[n];
    for(int x=0;x<n;x++){cin>>a[x];
    ++qw[a[x]];}
    ll ans=0;
    for(int x=0;x<n;x++)
    {
            if(qw[a[x]]>1)continue;
            ll e=sqrt(a[x]);
            bool k=true;
            for(int y=2;y<=e;y++)
            {
                if(a[x]%y==0)
                {
                    if(qw[y]>0)
                        k=false;
                    if(qw[a[x]/y]>0)
                        k=false;
                    if(!k)
                        break;
                }
            }
            if(a[x]>1 && qw[1]>0)
                k=false;
            if(k)
                ++ans;
    }
    cout<<ans;
}


Measured memory_bytes: 12956
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}
inline void OddEven(bool b){ cout << (b?"Odd" : "Even") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int a,b;cin >> a >> b;
  OddEven(a*b&1);
  return 0;
}


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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	string s,t;
	cin>>s>>t;
	cout<<t<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin


def main():
    n = next_int()
    t = [next_int() for _ in range(n)]

    m = next_int()
    ans = [0] * m

    for i in range(m):
        p = next_int() - 1
        x = next_int()
        ans[i] += sum(t) - t[p] + x

    print("\n".join(map(str, ans)))


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    string a, b, c;
    cin >> a >> b >> c;

    deque<char> A(a.begin(), a.end());
    deque<char> B(b.begin(), b.end());
    deque<char> C(c.begin(), c.end());

    char target = A.front();
    A.pop_front();
    string ans;
    while (true)
    {
        if (target == 'a')
        {
            if (A.empty())
            {
                ans = "A";
                break;
            }
            target = A.front();
            A.pop_front();
        }
        else if (target == 'b')
        {
            if (B.empty())
            {
                ans = "B";
                break;
            }
            target = B.front();
            B.pop_front();
        }
        else
        {
            if (C.empty())
            {
                ans = "C";
                break;
            }
            target = C.front();
            C.pop_front();
        }
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 256
import math
n, k = map(int,input().split())

count = 0
for b in range(max(k,1),n+1):
    if n % b != 0:
        t = math.ceil(n/b)
    else:
        t = int(n/b) + 1
    if n % b >= k:
        count += (b-k)*t - ((t*b-1)-n)
    else:
        count += (b-k)*(t-1)

#k=0のとき,n=0を除外する
if k ==0:
    count -= (n-k)


print(count)


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

template<class V> class MaxFlow_dinic {
public:
	struct edge { int to,reve;V cap;};
	static const int MV = 404040;
	vector<edge> E[MV];
	int itr[MV],lev[MV];
	void add_edge(int x,int y,V cap,bool undir=false) {
		E[x].push_back((edge){y,(int)E[y].size(),cap});
		E[y].push_back((edge){x,(int)E[x].size()-1,undir?cap:0});
	}
	void bfs(int cur) {
		MINUS(lev);
		queue<int> q;
		lev[cur]=0;
		q.push(cur);
		while(q.size()) {
			int v=q.front(); q.pop();
			ITR(e,E[v]) if(e->cap>0 && lev[e->to]<0) lev[e->to]=lev[v]+1, q.push(e->to);
		}
	}
	V dfs(int from,int to,V cf) {
		if(from==to) return cf;
		for(;itr[from]<E[from].size();itr[from]++) {
			edge* e=&E[from][itr[from]];
			if(e->cap>0 && lev[from]<lev[e->to]) {
				V f=dfs(e->to,to,min(cf,e->cap));
				if(f>0) {
					e->cap-=f;
					E[e->to][e->reve].cap += f;
					return f;
				}
			}
		}
		return 0;
	}
	V maxflow(int from, int to) {
		V fl=0,tf;
		while(1) {
			bfs(from);
			if(lev[to]<0) return fl;
			ZERO(itr);
			while((tf=dfs(from,to,numeric_limits<V>::max()))>0) fl+=tf;
		}
	}
};

int N;
vector<int> E[202020];
vector<int> F[202020];
int repv[202020];
MaxFlow_dinic<int> mf;
int did[303030];
pair<int,int> R[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N-1) {
		cin>>x;
		mf.add_edge(0,1+i,1);
		while(x--) {
			cin>>y;
			E[i].push_back(y);
			F[y].push_back(i);
			mf.add_edge(1+i,y+101010,1);
		}
	}
	for(i=2;i<=N;i++) mf.add_edge(i+101010,303030,1);
	
	if(F[1].empty() || mf.maxflow(0,303030)!=N-1) return _P("-1\n");
	for(i=2;i<=N;i++) {
		FORR(e,mf.E[i+101010]) if(e.cap && e.to<101010) {
			repv[e.to-1]=i;
		}
	}
	
	queue<int> Q;
	Q.push(1);
	while(Q.size()) {
		x=Q.front();
		Q.pop();
		FORR(f,F[x]) if(did[f]==0) {
			did[f]=x;
			R[f].first=x;
			R[f].second=repv[f];
			Q.push(repv[f]);
		}
	}
	FOR(i,N-1) cout<<R[i].first<<" "<<R[i].second<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

Measured memory_bytes: 600
def main():
    N = int(input())
    if N % 2 == 1 or N == 0:
        print(0)
    else:
        base = 2
        d = 0
        while True:
            base *= 5
            x = N // base
            if x == 0:
                break
            else:
                d += x
        print(d)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
S = str(input())
cnt = 0
ch_flag = 0 

for i in range(len(S)):
  if(i + 1) >= len(S): 
    break
  if(ch_flag == 1):
    if(S[i] == '0'):
      tmp = '1'
    else:
      tmp = '0'
    ch_flag = 0
  else:
    tmp = S[i]
  if (tmp == S[i + 1]):
    ch_flag = 1
    cnt += 1
print(cnt)

Measured memory_bytes: 3188
#include <stdio.h>

int a[100005];

int main(){

	int N;

	scanf("%d",&N);

	int i;

	int k4=0;
	int k2=0;
	int k=0;

	for(i=0;i<N;i++){
	scanf(" %d",&a[i]);
	if(a[i]%4==0){k4++;}
	else if(a[i]%2==0){k2++;}
	else{k++;}
	}

	if(k4>=k){printf("Yes\n");}
	else{
		if(k4==k-1 && k2==0){printf("Yes\n");}
		else{printf("No\n");}
	}

	return 0;
}

Measured memory_bytes: 640
#![allow(unused_imports)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::{min, max};
use std::collections::{HashMap, HashSet, VecDeque, BinaryHeap};

fn main() {
    input!{
        v: [usize; 5]
    }
    for i in 0..5 {
        if v[i] == 0 {
            println!("{}", i + 1);
            return;
        }
    }
}


Measured memory_bytes: 2052
N=input()
if int(N[0:1]) > int(N[1:2]) :
    print(N[0:1]*3)
elif int(N[0:1]) == int(N[1:2]) and int(N[1:2]) >= int(N[2:3]):
    print(N[0:1]*3)
else:
    print((int(N[0:1])+1)*111)


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

int main(){
  int val,i,Mt,inn,Max;
  inn = 0;
  cin >> val;
  int hight[val];
  for(i=0;i<val;i++){
  	cin >> Mt;
    hight[i] = Mt;
  }
  Max = hight[0];
  for(i=0;i<val;i++){
    if(Max<=hight[i]) {
      inn++;
      Max = hight[i];
    }
  }
  cout << inn << endl;
}

Measured memory_bytes: 256
from itertools import accumulate
import bisect

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_acc = [0] + list(accumulate(a))  # aを0冊読む=1冊も読まない場合があるので、[0]を先頭に追加します
b_acc = list(accumulate(b))  # bisect_rightでは、x以下の要素がいくつあるか？を求めるので、こちらに0は入れません

ans = 0
for an in range(n + 1):
    rem = k - a_acc[an]
    if rem < 0:
        # aをこれ以上読めません
        break

    bn = bisect.bisect_right(b_acc, rem)
    ans = max(ans, an + bn)

print(ans)

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

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


int main(void){
    int k;
    cin >> k;
    ll sum = 0;
    rep1(a,k)rep1(b,k)rep1(c,k){
        sum += gcd(a,gcd(b,c));
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
long long n,m,k,ans;
int main()
{
    cin>>n>>m>>k;
    if(n<=m)
    {
        cout<<"1\n";
        return 0;
    }
    if(m<=k)
    {
        cout<<"-1\n";
        return 0;
    }
    cout<<((n-m)%(m-k)==0?(n-m)/(m-k):(n-m)/(m-k)+1)*2+1<<endl;
    return 0;
}

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

using namespace std;

int N;
map < long long, int > mp;

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
long long s = 0, ans = 0;
mp[0] ++;
for (int i=1; i<=N; i++)
{
    int x;
    scanf ("%d", &x), s += x;
    ans += mp[s];
    mp[s] ++;
}
printf ("%lld\n", ans);

return 0;
}


Measured memory_bytes: 12800
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();
        String S = r.s();
        int[] count = new int[26];
        for(char c : S.toCharArray())
            count[c-'a']++;
        for(char c = 'a'; c < 'z'+1; c++){
            if(count[c-'a'] == 0){
                println(c);
                return;    
            }
        }
        println("None");
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 23124
#include "bits/stdc++.h"
using  namespace std;


int main()
{

    string str; int a ;
    cin>>a>>str;

    for(int i=0 ; i<str.length() ; i++)
    {
        for (int j = 0; j <a ; ++j)
        {

            if(str[i] !='Z')
            {
                str[i]+=1;
            } else
            {
                str[i]='A';
            }

        }
    }
    cout<<str<<endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main(){
    string A, B;
    cin >> A >> B;

    int lenA = A.length();
    int lenB = B.length();
    if(A == B){
        cout << "EQUAL" << endl;
        return 0;
    }
    if(lenA == lenB){
        for (int i = 0; i < lenA; i++)
        {
            if(A[i] == B[i]){
                continue;
            }else{
                if(A[i] > B[i]) cout << "GREATER" << endl;
                else if(A[i] < B[i]) cout << "LESS" << endl;
                else cout << "EQUAL" << endl;
                break;
            }
        }
    }else{
        if(lenA > lenB) cout << "GREATER" << endl;
        else if(lenA < lenB) cout << "LESS" << endl;
        else cout << "EQUAL" << endl;
    }
    cout << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
K = []
for i in range(N):
    tmp = list(map(int, input().split()))
    del tmp[0]
    K.append(tmp)

ans = K[0][:]
for i in range(1,N):
    ans = list(set(ans) & set(K[i]))

print(len(ans))

Measured memory_bytes: 3060
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
s = input()
q = I()
rev = False
ans = deque((s))
for i in range(q):
    A = input().split()
    if A[0] == '1':
        if rev:
            rev = False
        else:
            rev = True
    else:
        if A[1] == '1':
            if rev:
                ans.append(A[2])
            else:
                ans.appendleft(A[2])
        else:
            if rev:
                ans.appendleft(A[2])
            else:
                ans.append(A[2])
if rev:
    ans.reverse()
    print(*ans,sep='')
else:
    print(*ans,sep='')


Measured memory_bytes: 17644
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main()
{
    IO;
    string s;
    cin >> s;
    int ans = 0;
    set<char> st;
    int freq[28] = {0};
    for(int i = 0; i < s.size(); i++)
    {
        freq[s[i] - 'A' + 1] ++;
    }
    for(int i = 0; i <= 27; i++)
    {
        if(freq[i] == 2)
        {
            ans++;
        }
    }
   if(ans == 2)
    cout << "Yes";
   else
    cout <<"No";
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define PIGRECO 3.141592653589793

#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 {
	~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 << "]";
}
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////
const int maxn = 1e5 + 5;
vector<int>adj[maxn];
int dp[maxn];
bool visited[maxn];
int indegree[maxn];

void dfs(int v) {


	visited[v] = true;

	for (auto it : adj[v]) {

		indegree[it]--;

		dp[it] = max(dp[it], dp[v] + 1);

		if (indegree[it] == 0 && !visited[it]) {
			dfs(it);
		}


	}


}


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


	int n, m;

	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;

		adj[a].push_back(b);
		indegree[b]++;
	}

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

		if (!visited[i] && indegree[i]==0)
			dfs(i);

	}
	int ans = 0;

	for (int i = 1; i <= n; i++) {
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;




}

Measured memory_bytes: 16144
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 1e9+7, N = 1e5 + 10; 

int vis[N];

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n,x,m;
   cin >> n >> x >> m;
   vector<int> A;
   A = {x};
   for(int i = 1; i < n and !vis[x]; ++i){
      vis[x] = 1;
      x = (x*x)%m;
      A.push_back(x);
   }   
   if(A.size() == n){
      int sm = 0;
      for(int i : A){
         sm += i;
      }
      cout << sm << '\n';
      return 0;
   }
   int occuring = A.back();
   A.pop_back();
   int sm = 0;
   for(int i : A){
      sm += i;
   }
   int pos = -1;
   for(int i = 0; i < A.size(); ++i){
      if(A[i] == occuring){
         pos = i;
         break;
      }
   }
   debug(pos);
   vector<int> rem;
   int lft = n-(int)A.size();
   int sz = (int)A.size()-pos;
   int dv = lft/sz;
   int trm = lft%sz;
   int tot = 0;
   for(int i = pos; i < A.size(); ++i){
      rem.push_back(A[i]);
      tot += A[i];
   }
   tot *= dv;
   for(int i = 0; i < trm; ++i){
      tot += rem[i];
   }
   tot += sm;
   cout << tot << '\n';
   return 0;
} 

Measured memory_bytes: 5024
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main()
{
    int n;
    string a, b;
    cin >> n >> a >> b;
    for (int i = 0; i < n; i++) {
        cout << a[i] << b[i];
    }
    cout << endl;


    return 0;

}

Measured memory_bytes: 3576
#include<iostream>
using namespace std;
#include<vector>
#define int long long int
void dfs(vector<int> adj[],int src,int color[],bool visited[],int prev,int &answer)
{
	if(visited[src])
	   return ;
	else
	{
		visited[src]=true;
		if(color[src]!=prev)
		{
			prev=color[src];
			answer++;
		}
		for(int x:adj[src])
		    dfs(adj,x,color,visited,prev,answer);
    }
}
int32_t main()
{
     int n;
     cin>>n;
     int x;
     cin>>x;
     int arr[n+1],j;
     for(j=1;j<=n;j++)
         cin>>arr[j];
     int answer=0;
     for(j=2;j<=n;j++)
     {
		 int val=(arr[j]+arr[j-1])-x;
		 if(val>0)
		 {
			 answer+=val;
			 if(arr[j]>=val)
			 {
				 arr[j]-=(val);
			 }
			 else
			 {
				 arr[j]=0;
				 val-=(arr[j]);
				 arr[j-1]-=val;
			 }
		 }
	 }
	 cout<<answer<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int mod=1e9+7;
const int N = 1e5+5;

ll dp[3000][55];
ll n,ar,a[55],ans;

int main(){
  // freopen("input.txt","r",stdin);
  cin>>n>>ar;
  for(int i = 1;i <= n;i++){
    cin>>a[i];
    if(i == 1){
      dp[0][0] = 1;
      dp[a[i]][1] = 1;
    }
    else{
      for(int j = 2500;j >= a[i];j--){
	for(int k = i;k >= 1;k--){
	  dp[j][k] = dp[j-a[i]][k-1] + dp[j][k];
	}
      }
    }
  }
  for(int i = 1;i <= n;i++){
    ans += dp[i*ar][i];
  }
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 1408
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        //String word = sc.next();
        String array = "";
        String alpha = "abcdefghijklmnopqrstuvwxyz";
        int count = 0;
        while(sc.hasNext()){
            array = array + sc.next();
        }
        for(int i=0;i<26;i++){
            for(int j=0;j<array.length();j++){
                if(array.toLowerCase().charAt(j) == alpha.charAt(i)){
                    count++;
                }
            }
            System.out.println(alpha.charAt(i) + " : " + count);
            count = 0;
        }
        sc.close();
    }
}


Measured memory_bytes: 63272
import java.util.*;

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

        long x = sc.nextLong();
        long y = sc.nextLong();

        long a = x * y;

        for (long i = x; i <= a; i += x) {
            if (x % y != 0) {
                System.out.println(x);
                return;
            }
        }

        System.out.println(-1);
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    string s = "";
    while (n) {
      s = to_string(n % 8) + s;
      n /= 8;
    }
    string ans = "";
    for (int i = 0; i < int(s.size()); i++) {
      if (s[i] <= '3') ans += s[i];
      else if (s[i] <= '4') ans += s[i] + 1;
      else ans += s[i] + 2;
    }
    cout << ans << endl;
  }  

  return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
using namespace std;
bool debug=false;

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

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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 int64_t INF = 1LL << 60;

int main() {
  string s;
  int64_t K;
  cin>>s>>K;
  
  for(int i=0;i<min((int64_t)s.size(),K);i++){
    if(s[i]>='2'){cout<<s[i]<<endl;return 0;}
  }
  cout<<1<<endl;
  

  return 0;}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      String s ;
      char[] data = new char[3];
      int j = 0;

      for(int i = 0;i<3;i++){
        s = sc.nextLine();
        data[i] = s.charAt(j);
        j++;
      }

      System.out.println(data);
  }
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
 
#define f0rn(i, a, b) for (int i=a; i<(b); i++)
#define forn(i,n) for(int i = 0; i < n; i++)
 
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
 
const int MOD = 1000000007;
 
int main() {
    string s; cin >> s;
    if(s.length()  > 9) {
        cout << "NO";
        return 0;
    }
    string comp = "";
    forn(i,s.length()) if(s[i] != 'A') comp += s[i];
    forn(i,s.length()-1) {
        if(s[i] == 'A' && s[i+1] == 'A') {
            cout << "NO"; return 0;
        }
        if(s[i] == 'A' && s[i+1] == 'I') {
            cout << "NO"; return 0;
        }
         if(s[i] == 'A' && s[i+1] == 'H') {
            cout << "NO"; return 0;
        }
    }
    if(comp == "KIHBR") cout << "YES";
    else cout << "NO";
    
    fflush(stdout);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
	int n,s=0;
	cin >> n;
	int l[n*2];
	for(int i=0;i<n*2;i++){
		cin>>l[i];
	}
	sort(l,l+n*2);
	for(int i=(n*2)-1;i>=1;i-=2){
		s+=min(l[i],l[i-1]);
	}
	cout<<s<<endl;
}


Measured memory_bytes: 256
readInt :: String -> Int
readInt = read
x ? (a,b) = if x then a else b

main = do
    s <- map readInt.words<$>getContents
    print $ solve s

solve :: [Int] -> Int
solve = push 2

push 0 _ = 0
push n [a,b] = (a>b) ? (a + push (n-1) [a-1,b], b + push (n-1) [a,b-1])


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

int main() {
  int A, B;
  cin >> A >> B;
  vector<int> C(3);
  C.at(0) = A+B;
  C.at(1) = A-B;
  C.at(2) = A*B;
  sort(C.begin(), C.end());
  cout << C.at(2) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int slove(int x,int y,int n);
const int BufferSize=1<<16;
char buffer[BufferSize],*head,*tail;
inline char Getchar() {
    if(head==tail) {
        int l=fread(buffer,1,BufferSize,stdin);
        tail=(head=buffer)+l;
    }
    return *head++;
}
inline int read() {
    int x=0,f=1;char c=Getchar();
    for(;!isdigit(c);c=Getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=Getchar()) x=x*10+c-'0';
    return x*f;
}
int main(void)
{
    int N,Q;
    N=read(),Q=read();
    while(Q)
    {
        Q--;
        int x,y;
        x = read(),y = read();
        if(N==1)
            printf("%d\n",min(x,y));
        else
        printf("%d\n",slove(x,y,N));
    }
    return 0;
}
int slove(int x,int y,int n)
{
    while(x!=y)
    {
        if(x > y)
            x = (x+n-2)/n;
        else if(y > x)
            y = (y+n-2)/n;
    }
    return x;
}


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

typedef long long ll;

int main() {
    ll ans = 0;
    ll A, B, N;
    ll div[100];
    cin >> A >> B >> N;

    ll count = 0;
    for (ll i = min(A, B); count != N; i--)
    {
        if(A % i == 0 && B % i == 0) {
            div[count] = i;
            count++;
            // cout << i << endl;
        }
    }
    
    cout << div[count - 1] << endl;

    return 0;
}


Measured memory_bytes: 3524
#include <iostream>
using namespace std;
int main (){
    string a;
    cin >> a;
    int i;
    int b=0;
    for(i=0;i<a.length();i++){
        if((i+1)%2==0){
            if(a[i]=='R')
            b = 1;
        }
        if((i+1)%2==1){
            if(a[i]=='L')
            b = 1;
        }
    }
    if(b == 0) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n, x, sum = 0, count = 1;
	scanf("%d %d", &n, &x);
	int L[n];
	for(int i = 0; i < n; i++)
		scanf("%d", &L[i]);


	for(int i = 0; i < n; i++){
		sum += L[i];
		if(sum <= x)
			count++;
		else
			break;
	}
	printf("%d", count);
	return 0;
}

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

using namespace std;

int const NMAX = 100;
int v[1 + NMAX + 1];

int main() {

  int n, a, b;
  cin >> n >> a >> b;
  //if(n == 2){
  //  cout << "Draw";
  //}
  if(abs(a - b) % 2 == 0){//First wins
    cout << "Alice";
  }else{
    cout << "Borys";
  }
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdlib>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vsort(x) sort(x.begin(),x.end())

using int64 = uint64_t;

using namespace std;

int main() {

	int i, j, k;
	int n;
	cin >> n;
	int a[10];
	rep(i, 0, n)
		cin >> a[i];
	int ans = 1;
	int p = 1;
	rep(i, 0, n) {
		if (a[i] % 2 == 0) {
			p = p * 2;
		}
		else {
			p = p * 1;
		}
		ans = ans * 3;
	}
	ans = ans - p;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define vv(type)		vector<vector<type>>
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define db(x) 			cout<<x<<" "
#define db1(x) 			cout<<x<<'\n'
#define db2(x,y) 		cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) 		cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) 		for(int i=0;i<(n);++i)
#define repA(i,a,n) 	for(int i=a;i<=(n);++i)
#define repD(i,a,n) 	for(int i=a;i>=(n);--i)
#define so(a) 			sort(a.begin(),a.end())
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
// to find all local maximaa and minima in O(n)
//	 for (int i=1;i<=n;i++)
//        {
//            if (i==1 || i==n || (p[i-1]<p[i])!=(p[i]<p[i+1]))
//           ans.push_back(p[i]);
//        }
int dx[] = { -1, 1, -1, 0, 0, -1, 1, 1 };
int dy[] = { -1, -1, 1, -1, 1, 0, 0, 1 };
int gcd(int a, int b)
{
	if (!b)
		return a;
	return gcd(b, a % b);
}
int modular_expo(int x, int y, int m)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans % m * x % m) % m;
		x = (x % m * x % m) % m;
		y /= 2;
	}
	return ans % m ;
}
int power(int x, int y)
{
	int ans = 1;
	while (y)
	{
		if (y & 1)
			ans = (ans * x);
		x *= x;
		y /= 2;
	}
	return ans;
}
void solve()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	std::vector<std::vector<pair<int, int>>> dp(n + 1, std::vector<pii> (m + 1));
	for (int i = 0; i <= n; i++)
		for (int j = 0; j <= m; j++)
		{
			if (i == 0)
			{
				dp[i][j].ff = 0;
				dp[i][j].ss = 2;
			}
			else if (j == 0)
			{
				dp[i][j].ff = 0;
				dp[i][j].ss = 0;
			}
			else if (s[i - 1] == t[j - 1])
			{
				dp[i][j].ff = (dp[i - 1][j - 1]).ff + 1;
				dp[i][j].ss = 1;
			}
			else
			{
				if (dp[i][j - 1].ff < dp[i - 1][j].ff)
				{
					dp[i][j].ff = (dp[i - 1][j]).ff;
					dp[i][j].ss = 0;
				}
				else
				{
					dp[i][j].ff = (dp[i][j - 1]).ff;
					dp[i][j].ss = 2;
				}
			}
		}
	int x = n, y = m;
	string ans = "";
	while (x > 0 && y > 0)
	{
		if (dp[x][y].ss == 1)
		{
			ans += s[x - 1];
			x--;
			y--;
		}
		else if (dp[x][y].ss == 0)
			x--;
		else
			y--;

	}
	reverse(ans.begin(), ans.end());
	db(ans);
}

int32_t main()
{
	solve();
	return 0;
}


Measured memory_bytes: 144172
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define clr(a,x) memset(a,x,sizeof(a))
#define SZ(x) ((int)(x).size())
#define lson rt<<1
#define rson rt<<1|1
#define pb push_back
#define fi first
#define se second
#define what_is(x) cerr<<#x<<" "<<x<<endl;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
template <typename T>
inline void _read(T& x){
    cin>>x;
}
void R(){}
template <typename T,typename... U>
void R(T&head,U&... tail){
    _read(head);
    R(tail...);
}

template <typename T>
inline void _write(const T& x){
    cout<<x<<' ';
}
void W(){cout<<endl;}
template <typename T,typename... U>
void W(const T&head,const U&... tail){
    _write(head);
    W(tail...);
}

void go();
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    go();
    return 0;
}
/****************ackun*********************/
const int MOD=1e9+7;
ll dp[105][105];
int n;
string ss="ACGT";
int fun(string s){
    int now=0;
    for(auto c:s){
        now*=4;
        rep(i,0,3){
            if(c==ss[i]){
                now+=i;
            }
        }
    }
    return now;
}
bool check(string s){
    string now=string(s.begin()+1,s.end());
    if(now=="AGC"||now=="ACG"||now=="GAC"){
        return false;
    }
    if(s[0]=='A'&&string(s.begin()+2,s.end())=="GC"){

        return false;
    }
    if(string(s.begin(),s.begin()+2)=="AG"&&s[3]=='C'){
        return false;
    }
    return true;
}
ll dfs(int pos,string lst3){
    //W(pos,lst3);
    //cout<<fun(lst3)<<endl;
    if(pos==n){
        return 1;
    }
    if(dp[pos][fun(lst3)]!=-1){
        return dp[pos][fun(lst3)];
    }
    ll res=0;
    rep(i,0,3){
        string lst4=lst3+ss[i];
        if(check(lst4)){
            res=(res+dfs(pos+1,string(lst4.begin()+1,lst4.end())))%MOD;
        }
    }
    dp[pos][fun(lst3)]=res;
    return res;
}
void go(){
    R(n);
    clr(dp,-1);
    W(dfs(0,"TTT"));
}


Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

bool IsPrime(int num)//素数判定
{
    if (num < 2) return false;
    else 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;
}

int main() {

    int N;
    cin >> N;
    int A[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    int B[N];
    for(int i=0;i<N;i++){
        cin >> B[i];
    }
    int C[N-1];
    for(int i=0;i<N-1;i++){
        cin >> C[i];
    }

    int result = 0;

    for(int i=0;i<N;i++){
        result+=B[A[i]-1];
        if(i!=N-1){
            if(A[i+1]-A[i]==1){
                result+=C[A[i]-1];
            }
        }

    }
    cout << result << endl;



}



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

int main()
{
    ios::sync_with_stdio(false);
    int n, m, ans = -1;
    cin >> n >> m;
    for (int i = 1; i * i <= m; i++)
    {
        if (m % i == 0)
        {
            if (i <= m / n)
                ans = max(ans, i);
            if (i >= n)
                ans = max(ans, m / i);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
int main(){
    
    string str;
    int q;
    
    string order, p;
    int a, b;
    
    string str2;
    
    cin >> str >> q;
    
    for(int i = 0; i < q; i++){
        cin >> order >> a >> b;
        
        if(order == "print"){
            cout << str.substr(a, b-a+1) << endl;
        }
        
        if(order == "reverse"){
            for(int k = b; k >= a; k--){
                str2 = str2 + str[k];
            }
            
            str.replace(a, b-a+1, str2);
            str2 = "";
        }
        
        if(order == "replace"){
            cin >> p;
            str = str.replace(a, b-a+1, p);
        }
    }

    return 0;
}


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

typedef long long int ll;

int main(void){
	int N, b, c, Q, a;
	ll sum = 0;
	std::cin >> N;
	std::vector<int> num(100001, 0);
	for(int i = 0; i < N; i++){
		std::cin >> a;
		num[a]++;
		sum += a;
	}

	std::cin >> Q;
	for(int i = 0; i < Q; i++){
		std::cin >> b >> c;
		sum += (c-b) * num[b];
		num[c] += num[b];
		num[b] = 0;
		std::cout << sum << std::endl;
	}

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
#define gap ' '
#define L(i) ((i) - (&i))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DFOR(i,a,b) for(int i=a;i>=b;i--)

const int MAXN = 1000111;
const int mxn = 1e5+10;
const int MAX = 1e6 + 1;
const int MOD = 1e9;
const int INF = 1e9;

int main(){
	int ans = INT_MIN;
	int n; cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i)
		cin >> a[i];
	for(int i = 0; i < n; ++i)
		for(int j = i+1; j < n; ++j)
			ans = max(ans,abs(a[i]-a[j]));
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3584