akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, AC=0, WA=0, TLE=0, RE=0;
  cin >> n;
  string s;
  rep(_, n) {
    cin >> s;
    if(s=="AC") AC++;
    if(s=="WA") WA++;
    if(s=="TLE") TLE++;
    if(s=="RE") RE++;
  }
  cout << "AC x " << AC << newl;
  cout << "WA x " << WA << newl;
  cout << "TLE x " << TLE << newl;
  cout << "RE x " << RE << newl;
  return 0;
}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int n;
		int a;
		int b;
		int apoint=0,bpoint=0;
		while(true) {
			n = in.nextInt();
			if(n==0) {
				break;
			}
		for(int i=1; i <= n; i++) {
			a = in.nextInt();
			b = in.nextInt();
			if(a>b) 
				apoint += a+b;
			else if(a==b) {
				apoint += a;
				bpoint += b;
			}
			else {
				bpoint += a+b;
			}
			if(i==n) {
				System.out.println(apoint+ " "+ bpoint);
				apoint=0;
				bpoint=0;
			}
		}
			
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
//#define int long long
typedef long long ll;
#define sqr(x) ((x)*(x))
#define pb push_back 
const int N=1000002,M=998244353;
int pw(int x,int y){int z=1;for(;y;y>>=1,x=1ll*x*x%M)if(y&1)z=1ll*z*x%M;return z;}
//struct node{int to,ne}e[];
//void add(int x,int y){e[++tot]=(node){y,h[x]},h[x]=tot;}
int n,i,a[N],sum,k;
signed main(){
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]),sum+=abs(a[i]);
	sort(a+1,a+n+1);
	for (k=1;a[k]<0;k++);
	if (k==n+1 || k==1) sum-=2*abs(k==1?a[1]:a[n]);
	if (k>1) k--;
	printf("%d\n",sum);
	for (i=1;i<min(k,n-1);i++) printf("%d %d\n",a[n],a[i]),a[n]-=a[i];
	for (i=k;i<n-1;i++) printf("%d %d\n",a[i],a[i+1]),a[i+1]=a[i]-a[i+1];
	printf("%d %d",a[n],a[n-1]);
}

Measured memory_bytes: 2304
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define vll vector<ll>
#define dou(s) atof(s.c_str())
#define lon(s) atoll(s.c_str())
#define str(n) to_string(n)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()
#define line "\n"
#define mav(a) (*max_element(ALL(a)))
#define miv(a) (*min_element(ALL(a)))
#define vfind(a,n) (find(ALL(a),n)-a.begin())
#define prque priority_queue
#define MOD 1000000007ll
using namespace std;
void solve();
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

//nCk(mod p)
/*ll fac[510000], finv[510000], inv[510000];
void cmodf(ll p = MOD) {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	rep(i, 2, 510000) {
		fac[i] = fac[i - 1] * i%p;
		inv[i] = p - inv[p%i] * (p / i) % p;
		finv[i] = finv[i - 1] * inv[i] % p;
	}
}
ll cmod(ll n, ll k, ll p = MOD) {
	return fac[n] * (finv[k] * finv[n - k] % p) % p;
}*/

//最大公約数
ll gcd(ll n, ll m) {
	ll k = n % m;
	while (k != 0) { n = m; m = k; k = n % m; }
	return m;
}
ll gcd(vector<ll> a) {
	rep(i, 1, a.size()) {
		ll k = a[i - 1] % a[i];
		while (k != 0) {
			a[i - 1] = a[i];
			a[i] = k;
			k = a[i - 1] % a[i];
		}
	}
	return a.back();
}

//最小公倍数
ll lcm(ll n, ll m) {
	ll t = n * m, k = n % m;
	while (k != 0) { n = m; m = k; k = n % m; }
	return t / m;
}
ll lcm(vector<ll> a) {
	ll n;
	rep(i, 1, a.size()) {
		n = a[i - 1] * a[i];
		ll k = a[i - 1] % a[i];
		while (k != 0) {
			a[i - 1] = a[i];
			a[i] = k;
			k = a[i - 1] % a[i];
		}
		n /= a[i];
		a[i] = n;
	}
	return n;
}

//keyの小さい方から探していった時に初めてvalueがjoken以上になる時のkey（keyが増えたらvalueも増えるか同じになるとき）
ll value(ll key) {
	/*変更*/
	return 0;
}
ll mini(ll lkey, ll rkey/*ここも調べる*/, ll joken) {
	ll mkey;
	while (lkey != rkey) {
		mkey = (lkey + rkey) / 2;
		if (value(mkey) >= joken)rkey = mkey;
		else lkey = mkey + 1;
	}
	return rkey;
}

//ペア配列の整理
struct pea { ll n, m; };
void msort(vector<pea> &a, bool k = true) {
	struct hikakukansu {
		static bool unstable(const pea &x, const pea &y) { return x.m < y.m; }
		static bool stable(const pea &x, const pea &y) { return (x.m == y.m ? x.n < y.n : x.m < y.m); }
	};
	if (k)sort(ALL(a), hikakukansu::unstable);
	else sort(ALL(a), hikakukansu::stable);
}

//変数定義

//再帰関数

//アルゴリズム
void solve() {
	ll n; cin >> n;
	string s, t;
	rep(i, 0, n) {
		cin >> s >> t;
		s = ' ' + s;
		t = ' ' + t;
		vector<vll> dp(s.size(), vll(t.size()));
		rep(i, 0, t.size())dp[0][i] = 0;
		rep(i, 0, s.size())dp[i][0] = 0;
		ll ma = 0;
		rep(i, 1, s.size()) {
			rep(j, 1, t.size()) {
				if (s[i] == t[j]) {
					dp[i][j] = dp[i - 1][j - 1] + 1;
				}
				else {
					dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
				}
				ma = max(ma, dp[i][j]);
			}
		}
		cout << ma << line;
	}
}


Measured memory_bytes: 10892
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin >> n;
  cout << n / 3 << endl;
}

Measured memory_bytes: 3136
import sys
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
for i in range(n):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:
                a[j][k]=0
if a[0]==[0,0,0]:
    print('Yes')
elif a[1]==[0,0,0]:
    print('Yes')
elif a[2]==[0,0,0]:
    print('Yes')
else:
    for i in range(3):
        if a[0][i]==a[1][i]==a[2][i]:
            print('Yes')
            sys.exit()
    if a[0][0]==a[1][1]==a[2][2]:
        print('Yes')
    elif a[0][2]==a[1][1]==a[2][0]:
        print('Yes')
    else:
        print('No')


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

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))

#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;


long depths[100005];

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

  long n;
  cin >> n;

  vector<long> res;
  if (n == 3) {
    res.push_back(2);
    res.push_back(5);
    res.push_back(63);
  } else if (n == 4) {
    res.push_back(2);
    res.push_back(5);
    res.push_back(20);
    res.push_back(63);
  } else if (n < 21) {
    res.push_back(2);
    res.push_back(3);
    res.push_back(4);
    res.push_back(6);
    res.push_back(9);
    n-=5;
    rep(i, 1000) {
    if(n == 0) {
      break;
    } else {
      res.push_back(i*30+30);
      n--;
    }
    }
  } else {
    rep(i, 1000) {
      if(n == 0) {
        break;
      } else if (n >= 21) {
        rep(j_, 30) {
          int j = j_+1;
          if(j%2 == 0 || (j%3==0 && j%5) || (j%5==0 && j%3)) {
            res.push_back(i*30+j);
            n--;
          }
        }
      } else {
        res.push_back(i*30+30);
        n--;
      }
    }
  }

  rep(i, res.size()) {
    cout << res[i] << endl;
  }
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  ll k;
  cin >> s;
  cin >> k;
  int n = s.size();
  int ans1 = 0;
  int ans2 = 0;
  string t = s + s;
  bool flag = false;
  rep(i, n - 1) {
    if(s[i] != s[i + 1]) flag = true;
  }
  rep(i, n - 1) {
    if(s[i] == s[i + 1]) {
      ans1++;
      i++;
    }
  }
  rep(i, 2 * n - 1) {
    if(t[i] == t[i + 1]) {
      ans2++;
      i++;
    }
  }
  flag ? out(ans1 + (ans2 - ans1) * (k - 1)) : out(n * k / 2);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int inf = 1001001001;
 
int main(){

    ll x,ans,flag=0;
    cin >> x;
    if(x==2){
        cout << 2 << endl;
        return 0;
    }
    for(ll i=x; i<=100003; i++){
        for(ll k=i-1; 2<=k; k--){
            if(k==2 && i%k!=0){
                ans=i;
                flag=1;
                break;
            }
            else if(i%k!=0){
              continue;
            }
            else if(i%k==0){
                break;
            }
        }

        if(flag==1){
            break;
        }
    }

    cout << ans << endl;
 
}

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


int main(){
    int n;
    cin>>n;
    float a[n];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    float ans = 0;
    
    for(int i=0; i<n; i++){
        ans += 1.0 / a[i];
    }

    printf("%.6f\n", 1.0/ans);
    return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define fastio ios_base::sync_with_stdio(false)

typedef double db;
typedef long long ll;
typedef unsigned long long ull;

typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

int main() {
	fastio;
	int n; cin >> n;
	ll sum = 0;
	for(int i = 1; i <= n; ++i) {
		if(i % 3 != 0 and i % 5 != 0)
			sum += i;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(m), x(m);
    rep(i,m){
        cin>>a[i];
        int k;
        cin>>k;
        int sum  =0;
        rep(j,k){
            int t;cin>>t;
            sum+=(1<<(t-1));
        }
        x[i]=sum;
    }
    vector<ll> dp(1<<n,inf);
    dp[0]=0;
    rep(i,m){
        rep(j,1<<n){
            dp[j|x[i]]=min(dp[j|x[i]],dp[j]+a[i]);
        }
    }
    if(dp[(1<<n)-1]==inf)cout<<-1<<endl;
    else cout<<dp[(1<<n)-1]<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int maxn = 1e5+7;

int father[maxn],arr[maxn];

int root(int x)
{
    if (x==father[x]) return x;
    return father[x]=root(father[x]);
}


int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++)
    {
        scanf("%d",&arr[i]);
        father[i]=i;
    }
    for (int i=1;i<=m;i++)
    {
        int fx,fy,x,y;
        scanf("%d%d",&x,&y);
        fx=root(x);fy=root(y);
        father[fx]=fy;
    }

    int ans=0;
    for (int i=1;i<=n;i++)
    {
        if (root(i)==root(arr[i])) ans++;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<int> v(n, 0);
    rep(i, n)
    {
        cin >> v[i];
        v[i] *= -1;
    }
    vector<int> ans(1, 101010);
    rep(i, n)
    {
        //rep(j, ans.size())
        //{
        //  cerr << ans[j] << " ";
        //}
        //cerr << endl;
        auto itr = upper_bound(ALL(ans), v[i]);
        //cerr << v[i] << endl;
        if (itr != ans.end())
        {
            //itr--;
            //cerr << v[i] << endl;
            *itr = v[i];
        }
        else
        {

            ans.push_back(v[i]);
            //sort(ALL(ans));
        }
    }
    cout << ans.size() << endl;
    return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    int ans = a+b+c - max(max(a,b),c);

    dunk(ans);
}

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

int main(void)
{
    int n,k;
    cin >> n >> k;

    vector<int> p;
    int tmp;
    rep(i, n){
        cin >> tmp;
        p.push_back(tmp);
    }
    sort(p.begin(), p.end());
    int sum = 0;
    rep(i, k){
        sum += p.at(i);
    }

    cout << sum << endl;
    return 0;
}

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

using namespace std;

#define MX 35
#define MOD 1'000'000'007
#define F first
#define S second
#define br '\n'

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

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

	int n, k;
	cin >> n >> k;
	k--;
	int sum = 0, mn = 0, mx = 0;
	for(int i=0; i<k; i++)
	{
		mn = (mn + i)%MOD;
		mx = (mx + n-i)%MOD;
	}
	for(int i=k; i<=n; i++)
	{
		mn = (mn + i)%MOD;
		mx = (mx + n-i)%MOD;
		sum = (sum + mx - mn + 1)%MOD;
		if(sum < 0)
			sum += MOD;
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int s = sc.nextInt();
    long mod = 1_000_000_007L;
    long[] dp = new long[s + 1];
    dp[0] = 1L;
    for (int i = 0; i <= s; i++) {
      for (int j = 3; j <= s; j++) {
        if (i + j > s) break;
        dp[i + j] += dp[i];
        dp[i + j] %= mod;
      }
    }
    System.out.println(dp[s]);
  }
}

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

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

	int n,d;
	cin >> n >> d;
	int ans = 0;
	while(n--) {
		long long x,y;
		cin >> x >> y;
		x = abs(x);
		y = abs(y);
		long long q = ceil(sqrt(x*x + y*y));
		if(q <= (long long)d) ans++;
	}
	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef long long ll;

int n;

void make_irre (vector <ll> & a )
{
	ll g;			// Ååöñ
	vector <ll> pre;
	do{
		pre = a;
		g = a[0];
		for (int i = 1; i < n; i++ )
			g = __gcd (g, a[i] );
		rep (i, n )
			a[i] /= g;
	}while (pre != a );
}

int main()
{
	while (cin >> n && n ){
		vector <ll> d (n ), v(n );

		rep (i, n )
			cin >> d[i] >> v[i];

		// ùñªÌ
		rep (i, n ){
			ll g = __gcd(d[i], v[i] );	
			v[i] /= g;
			d[i] /= g;
		} // end rep
		// ¬x¯mÌùñ»(?)
		make_irre (v );

		// £¯mÌùñ»(?)
		make_irre (d );

		// ®ä»
		rep (i, n ){
			if (v[i] % d[i] == 0 ){
				v[i] /= d[i];
				continue;
			}else{
				ll m = d[i];
				rep (j, n )
					if (i != j )
						v[j] *= m;
			} // end if
		} // end rep
		make_irre (v );

		rep (i, n )
			cout << v[i] << endl;
	} // end loop
		
	return 0;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int n,m,p,q;
int row[300001]={0},col[300001]={0};
v(int) rowlist[300001];
int main()
{
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  int h,w,m;
  cin>>h>>w>>m;
    multiset<int> ss;
    
    v(p2) tar(m);
    
    rep(i,m) cin>>tar[i].fi>>tar[i].se;
    rep(i,m) row[tar[i].fi-1]++,col[tar[i].se-1]++,rowlist[tar[i].fi-1].push_back(i);
    rep(i,w) ss.insert(col[i]);
    int ans=0;
    rep(i,h){
        for(auto x:rowlist[i]){
            ss.erase(ss.find(col[tar[x].se-1]));
            //ss.remove(ss.find(col[tar[x].se-1]));
            col[tar[x].se-1]--;
            ss.insert(col[tar[x].se-1]);
        }
        ans=max(ans,row[i]+*ss.rbegin());

        for(auto x:rowlist[i]){
            ss.erase(ss.find(col[tar[x].se-1]));
            //ss.remove(ss.find(col[tar[x].se-1]));
            col[tar[x].se-1]++;
            ss.insert(col[tar[x].se-1]);
        }
    }
   cout<<ans<<endl;
  return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void imos(int x0, int y0, int x1, int y1, vector<vector<int>> &memo) {
    ++memo.at(x0).at(y0);
    --memo.at(x1+1).at(y0);
    --memo.at(x0).at(y1+1);
    ++memo.at(x1+1).at(y1+1);
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<pair<int, int>> xy(n);
    for (int i=0; i<n; ++i) {
        char c;
        cin >> xy.at(i).first >> xy.at(i).second >> c;
        if (c == 'B') xy.at(i).first += k;
        xy.at(i).first %= 2 * k;
        xy.at(i).second %= 2 * k;
    }

    vector<vector<int>> memo(2*k+1, vector<int>(2*k+1));
    for (int i=0; i<n; ++i) {
        ll x = xy.at(i).first, y = xy.at(i).second;
        if (x/k == y/k) {
            x = x%k, y = y%k;
            imos(0, 0, x, y, memo);
            imos(x+1, y+1, x+k, y+k, memo);
            imos(x+k+1, 0, 2*k-1, y, memo);
            imos(0, y+k+1, x, 2*k-1, memo);
            imos(x+k+1, y+k+1, 2*k-1, 2*k-1, memo);
        } else {
            x = x%k, y = y%k;
            imos(x+1, 0, x+k, y, memo);
            imos(0, y+1, x, y+k, memo);
            imos(x+1, y+k+1, x+k, 2*k-1, memo);
            imos(x+k+1, y+1, 2*k-1, y+k, memo);
        }
    }
    for (int i=0; i<2*k+1; ++i) {
        for (int j=0; j<2*k+1; ++j) {
            if (i > 0) memo.at(i).at(j) += memo.at(i-1).at(j);
            if (j > 0) memo.at(i).at(j) += memo.at(i).at(j-1);
            if (i > 0 && j > 0) memo.at(i).at(j) -= memo.at(i-1).at(j-1);
        }
    }
    int res = 0;
    for (int i=0; i<2*k; ++i) for (int j=0; j<2*k; ++j) chmax(res, memo.at(i).at(j));
    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


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

int main() {
  int num;
  cin >> num;
  
  int a = num / 100;
  num -= a * 100;
  
  int b = num / 10;
  num -= b * 10;
  
  int c = num;
  
  cout << a + b + c << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k,base=1;
	scanf("%d%d",&n,&k);
	while(n--){
		if(base*2<base+k){
			base*=2;
		}
		else{
			base+=k;
		}
	}
	printf("%d\n",base);
	return 0;
}

Measured memory_bytes: 256
X = int(input())
N = [i**5 for i in range(1000)]

for i in range(1000):
	for j in range(i, 1000):
		if N[j] - N[i] == X:
			print(j, i)
			exit()
		if N[j] + N[i] == X:
			print(j, -i)
			exit()

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

using namespace std;


int main(){
	/*input*/
	int n;
    cin >> n;
    int w[100];
    for(int i = 0;i < n; i++){
    	cin >> w[i];
    }

	/*calc*/
    int s1 = w[0];
    int s2 = w[n-1];
    int ans = 100;

    for (int i = 1; i < n-1; i++){
    	s2 = w[n-1];
    	s1 += w[i];
    	for(int j = i+1; j < n-1; j++){
    		if(i == n-2){
    			break;
    		}
    		s2 += w[j];
    	}
    	int tmp = abs(s1 - s2);
    	if(tmp < ans){
    		ans = tmp;
    	}
    }
	/*output*/
   	cout<< ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

int main(){
    std::string input;
    std::cin >> input;
    bool flag = false;
    bool result = false;
    for(int i = 0; i < input.size(); ++i){
        char hoge = input[i];
        if(flag){
            if(hoge == 'C'){
                result = true; 
                break;
            }
        }
        flag = false;
        if(hoge == 'A') flag = true;
    }
    if(result){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
}

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

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

  multiset<int> s;
  for (int i=0; i<n; i++) {
    int a;
    cin>>a;
    if (i == 0) {
      s.insert(a);
      continue;
    }
    auto it = s.lower_bound(a);
    if (it == s.begin()) {
      s.insert(a);
    } else {
      --it;
      s.erase(it);
      s.insert(a);
    }
  }

  cout<<s.size()<<endl;
}

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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)

vector<ll> a(51), b(51), c(51), d(51);
vector<int> A(11);
ll res = 0;
ll n, m, q;
void dfs(int index, int num) {
	A[index] = num;
	if (index == n) {
		ll tmp = 0;
		FOR(i, 1, q) {
			if (A[b[i]] - A[a[i]] == c[i]) {
				tmp += d[i];
			}
		}
		res = max(res, tmp);
	}
	else {
		FOR(i, num, m) {
			dfs(index + 1, i);
		}
	}
}

int main() {
	cin >> n >> m >> q;
	FOR(i, 1, q) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}
	FOR(i, 1, 10) {
		dfs(1, i);
	}
	pv(res)
	return(0);
}

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

int main(){
	int b[3] = {1,0,0};
	char input[3];

	while(cin >> input){
			int num = b[ input[0] - 'A' ];
			b[ input[0] - 'A' ] = b[ input[2] - 'A' ];
			b[ input[2] - 'A' ] = num;
		}
		if(b[0] == 1)
			cout << 'A' << endl;
		if(b[1] == 1)
			cout << 'B' << endl;
		if(b[2] == 1)
			cout << 'C' << endl;
}

Measured memory_bytes: 1132
#include<stdio.h>
#include<stdbool.h>
#include<string.h>
#define rep(i,n) for(int i=0; i < (n); i++)
int main(){
  int k;
  char s[100];
  scanf("%d%s",&k,s);
  int len=strlen(s);
  if(len<=k){
    printf("%s\n",s );
    return 0;
  }else{
    rep(i,k){
      printf("%c",s[i]);
    }
    printf("...");
    return 0;
  }
}


Measured memory_bytes: 1676
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>
#include <sstream>
#include <map>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

const ll mod = 1e9 + 7;

int main() {
	vector<int> p(3);
	cin >> p[0] >> p[1]  >> p[2];
	SORT(p);

	cout << p[0] + p[1] << endl;

}



Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

vector<pint> ans;
int main(){
    int n,k;
    cin>>n>>k;
    FOR(i,1,n) ans.pb(0,i);
    int cur=(n-1)*(n-2)/2;
    if(n==2&&k==0){
        cout<<ans.size()<<endl;
        for(auto it:ans){
            cout<<it.first+1<<" "<<it.second+1<<endl;
            }
        return 0;
    }
    if(cur<k) cout<<-1<<endl;
    else{
        cur-=k;
        FOR(i,1,n)FOR(j,i+1,n){
            if(cur>0){
                ans.pb(i,j);--cur;
            }
            if(cur==0){
                cout<<ans.size()<<endl;
                for(auto it:ans){
                    cout<<it.first+1<<" "<<it.second+1<<endl;
                }
                return 0;
            }
            
        }
    }
    return 0;
}


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

import fractions

X = A[0]
for i in range(1, N):
    X = X*A[i] // fractions.gcd(X, A[i])

output = 0
D =10**9+7
X = X%D

for i in range(N):
    output += X*pow(A[i],D-2,D)%D
    output = output % (10**9+7)
print(int(output))

Measured memory_bytes: 67176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

  vll a(n), cnt(n, 0);
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i] - 1]++;
  }

  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    ans += cnt[i] * (cnt[i] - 1) / 2;
  }

  for (ll i = 0; i < n; i++) {
    cout << ans - cnt[a[i] - 1] + 1 << endl;
  }
}

Measured memory_bytes: 5760
#include<cstdio>
#include<algorithm>
using namespace std;
int a[102000],n,h,w,c[150][150];
int main()
{
	scanf("%d%d",&h,&w);
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int cnt=1;

	for(int i=1;i<=h;i++)
	 for(int j=1;j<=w;j++)
	 {
	 	if(w-j+1>=a[cnt])
	 	{
	 		c[i][j]=cnt;a[cnt]--;
	 		if(a[cnt]==0) cnt++;
	 	}
	 	else
	 	{
	 		a[cnt]=a[cnt]-(w-j+1);
			 while(j<=w)
	 		{
	 			c[i][j]=cnt;j++;
	 		}
	 		break;
	 	}
	 }
	 int flag=0;
	for(int i=1;i<=h;i++)
	{
		if(flag==0)
		{
			for(int j=1;j<=w;j++) printf("%d ",c[i][j]);
			printf("\n");flag=1;
		}
		else
		{
			for(int j=w;j>=1;j--) printf("%d ",c[i][j]);printf("\n");flag=0;
		}
	}
	 
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
    int kazu[35];
    kazu[1]=1;
    kazu[2]=2;
    kazu[3]=4;
    for(int a=4;a<=30;a++)
kazu[a]=kazu[a-1]+kazu[a-2]+kazu[a-3];
     
    while(1)
  {
        int n;
        cin>>n;
        if(n==0)break;
        cout<<(kazu[n]/10+1)/365+1<<endl;
    }
     
    return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;


const ll mod = 1e9+7;
const int maxn = 2000000+10;

ll power(ll a, ll b){
	ll res = 1;
	while(b){
		if(b&1) res = ((res%mod)*(a%mod))%mod;
		b >>= 1;
		a = ((a%mod)*(a%mod))%mod;
	}
	return res;
}

ll fac[maxn],caf[maxn]; //factorial e inverso

ll deg(ll x,ll d){
	d %= mod - 1;
    	if(d < 0)d += mod - 1;
    	ll y = 1;
    	while (d) {
        	if (d & 1) y *= x, y %= mod;
        	x *= x, x %= mod;
        	d /= 2;
    	}
    	return y;
}
ll coeff(int n,int k){
	return fac[n] * caf[k] % mod * caf[n - k] % mod;
}


int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	fac[0] = caf[0] = 1;
	forn(i,1,maxn)fac[i] = i * fac[i - 1] % mod, caf[i] = deg(fac[i], -1);
	
	string str;
	int N,K;
	cin >> K >> str;
	N = str.size()+K;
	ll res = 0;
	forn(i,str.size(),N+1){
		int cnt25 = i-(int)str.size();
		int cnt26 = N-i;
		ll tmp = ((power(25,cnt25))*(power(26,cnt26)))%mod;
		tmp = ((tmp)*(coeff(i-1,str.size()-1)))%mod;
		res += tmp;
		res %= mod;
	}
	
	if(res < 0)res += mod;
	cout << res << '\n';
	
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 35448
fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let m: usize = sc.read();

    let mut count = vec![0; n + 1];
    for _ in 0..m {
        let p: usize = sc.read();
        let q: usize = sc.read();
        let (p, q) = if p > q { (q, p) } else { (p, q) };
        if p != 1 {
            count[p] += 1;
            count[q] += 1;
        } else {
            count[q] += 1;
        }
    }

    for &c in &count {
        if c % 2 != 0 {
            println!("NO");
            return;
        }
    }
    println!("YES");
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


Measured memory_bytes: 4352
//
// Created by rajshah9914 on 30/03/20.
//

#include <bits/stdc++.h>
using namespace std;
int n,k;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>k;
    int a[n+1];
    bool dp[k+1];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<=k;i++)
    {
        for(int x=0;x<n;x++)
        {
            if(i>=a[x] && !dp[i - a[x]])
                dp[i]=true;
        }
    }
    cout << (dp[k] ? "First" : "Second") << endl;
}

//#include <bits/stdc++.h>
//using namespace std;
//
//const int mxN=100, mxK=1e5;
//int n, a[mxN], k;
//bool dp[mxK+1];
//
//int main() {
//    ios::sync_with_stdio(0);
//    cin.tie(0);
//
//    cin >> n >> k;
//    for(int i=0; i<n; ++i)
//        cin >> a[i];
//    for(int i=0; i<=k; ++i) {
//        for(int j=0; j<n; ++j)
//            if(i-a[j]>=0&&!dp[i-a[j]])
//                dp[i]=1;
//    }
//    cout << (dp[k]?"First":"Second");
//}

Measured memory_bytes: 384
#include <stdio.h>
char S[105];
int main()
{
    int flag=1;
    scanf("%s",S);
    for(int i=0;i<105;i++){
            if((i+1)%2!=0&&S[i]=='L'){
                    flag=0;
            break;
            }
            if((i+1)%2==0&&S[i]=='R'){
                    flag=0;
            break;
            }
    }
    if(flag==1) printf("Yes");
    else printf("No");
    return 0;
}


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

int main() {
    vector<int> len;
    len.push_back(60);
    for (int i = 0; i < 5; i++) {
        len.push_back(len[i] + 20);
    }

    vector<int> widht;
    widht.push_back(2);
    widht.push_back(5);
    for (int i = 2; i <= 5; i++) {
        widht.push_back(widht[1] * i);
    }

    vector<int> price;
    price.push_back(600);
    for (int i = 0; i < 5; i++) {
        price.push_back(price[i] + 200);
    }

    int N;
    while (cin >> N, N) {
        int sum  = 0;
        for (int i = 0; i < N; i++) {
            int x, y, z, d;
            cin >> x >> y >> z >> d;

            for (int j = 0; j < 6; j++) {
                if (len[j] >= x + y + z && widht[j] >= d) {
                    sum += price[j];
                    break;
                }
            }
        }

        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//SOLVE
void solve(void)
{
  string str1,str2;
  cin>>str1>>str2;
  int L1 = str1.size();
  int L2 = str2.size();
  vector<vector<int> > DP (L1+1,vector<int>(L2+1,0));
  for (int i = 1; i <= L1; i++)
  {
    for (int j = 1; j <= L2; j++)
    {
      DP[i][j] = max(DP[i-1][j],max(DP[i][j-1],DP[i-1][j-1]+(int)(str2[j-1] == str1[i-1])));
    }
  }
  string ANS = "";
  int p2 = L2,p1 = L1;

  while((p2 > 0 && p1 > 0))
  {
    // DEBUG(p1,p2,"\n");
    if(str1[p1-1] == str2[p2-1])
    {
      ANS.push_back(str1[p1-1]);
      p1--;p2--;
    }
    else if(DP[p1-1][p2]>DP[p1][p2-1])
    {
      p1--;
    }
    else
    {
      p2--;
    }

  }
  reverse(ALL(ANS));
  cout<<ANS<<endl;
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define l first
#define r second

using namespace std;

const int maxn = 3e5 + 1;

int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int k; cin >> k;
    cout << a[k - 1];
    return 0;
}


Measured memory_bytes: 256
// atcoder/abc164/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  // for (int i = 1; i < 60; ++i) {
  //   cout << i * 2019 << endl;
  // }

  str s;
  while (cin >> s) {
    lli sum = 0;
    const int M = 2019;
    const int N = 2;
    const lli K = 2;
    static int dp[2][M][K];
    fill(&dp[0][0][0], &dp[N - 1][M - 1][K - 1] + 1, 0);
    dp[0][0][false] = 1;
    for (int i = 0; i < s.size(); ++i) {
      int curr = i % 2;
      int next = (curr + 1) % 2;
      for (int j = 0; j < M; ++j) {
        dp[next][j][false] = dp[next][j][true] = 0;
      }
      for (int j = 0; j < M; ++j) {
        {
          dp[next][(j * 10 + s[i] - '0') % M][true] += dp[curr][j][true];
        }
        {
          dp[next][j][false] += dp[curr][j][false];
        }
        {
          dp[next][(j * 10 + s[i] - '0') % M][true] += dp[curr][j][false];
        }
      }
      sum += dp[next][0][true];
    }
    cout << sum << endl;
  }


  return 0;
}


Measured memory_bytes: 3768
#include<iostream>
#define ll long long
using namespace std;
int main(){
	ll n,m,l;
	cin >>n>>m>>l;
	ll mat[100][100]={{}};
	ll mat2[100][100]={{}};
	ll mat3[100][100]={{}};
	for (int i=0;i<n;i++) {
		for (int j=0;j<m;j++) {
			cin >> mat[i][j];
		}
	}
	for (int j=0;j<m;j++) {
		for (int k=0;k<l;k++) {
			cin >> mat2[j][k];
		}
	}
	for (int i=0;i<n;i++) {
		for (int j=0;j<m;j++) {
			for (int k=0;k<l;k++) {
				mat3[i][k]+=mat[i][j]*mat2[j][k];
			}
		}
	}
	for (int i=0;i<n;i++) {
		for (int j=0;j<l;j++) {
			cout << (j==0 ? "":" ") << mat3[i][j];
		}
		cout << endl;
	}
}



Measured memory_bytes: 3336
# include <iostream>
# include <math.h>

using namespace std;


int main()
{
    int X, N;

    cin >> X >> N;

    int* p;
    p = new int[N];

    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
    }
    bool found = true;
    int output = 0;

    for (int i = 0; i < N; i++)
    {
        if (p[i] == X)
        {
            found = true;
            i = N;
        }
        else
        {
            found = false;
            output = X;
        }
    }

    if (N == 0)
    {
        found = false;
        output = X;
    }

    int j = 1;
    while (found)
    {
        for (int i = 0; i < N; i++)
        {
            if (p[i] == X-j)
            {
                found = true;
                i = N;
            }
            else
            {
                found = false;
                output = X - j;
            }
        }

        if (found)
        {
            for (int i = 0; i < N; i++)
            {
                if (p[i] == X + j)
                {
                    found = true;
                    i = N;
                }
                else
                {
                    found = false;
                    output = X + j;
                }
            }
        }
        j++;
    }
    cout << output;

    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
using lint = long long;

#pragma GCC optimize ("Ofast", "unroll-loops")
#pragma GCC target ("arch=ivybridge")

const int nmax = 204800, block = 2048, unrl = 16;
int a[nmax], b[nmax];

int main() {

	int N, i, j, k;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%d", &a[i]);
	for (int i = 0; i < N; i++) scanf("%d", &b[i]);

	int ans = 0;
	for (i = 0; i + unrl <= N; i += unrl) {
		for (j = 0; j + block <= N; j += block) {
			for (k = j; k < block + j; k++) {

				ans ^= (a[i + 0] + b[k]) ^ (a[i + 1] + b[k]);
				ans ^= (a[i + 2] + b[k]) ^ (a[i + 3] + b[k]);
				ans ^= (a[i + 4] + b[k]) ^ (a[i + 5] + b[k]);
				ans ^= (a[i + 6] + b[k]) ^ (a[i + 7] + b[k]);
              	ans ^= (a[i + 8] + b[k]) ^ (a[i + 9] + b[k]);
				ans ^= (a[i + 10] + b[k]) ^ (a[i + 11] + b[k]);
				ans ^= (a[i + 12] + b[k]) ^ (a[i + 13] + b[k]);
				ans ^= (a[i + 14] + b[k]) ^ (a[i + 15] + b[k]);

			}
		}
	}

	for (i = 0; i < N / unrl * unrl; i++) {
		for (j = N / block * block; j < N; j++) {
			ans ^= a[i] + b[j];
		}
	}	
	for (; i < N; i++) {
		for (j = 0; j < N; j++) {
			ans ^= a[i] + b[j];
		}
	}

	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <set>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <deque>
#include <memory.h>
#include <assert.h>
#include <cstring>
#include <cmath>

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef double ld;
typedef pair<ll, ll> pll;

const ll inf = 1e18;

int main() {

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

	//ifstream cin("input.txt");
    //ofstream cout("output.txt");
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

	int n;
	cin >> n;

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

	ll minn = inf, maxx = -inf;
	int posMax, posMin;
	for (int i = 0; i < n; ++i) {
		if (a[i] < minn) {
			minn = a[i];
			posMin = i;
		}
		if (a[i] > maxx) {
			maxx = a[i];
			posMax = i;
		}
	}

	vector<pii> ans;

	if (maxx > 0 && minn < 0) {
		if (abs(maxx) > abs(minn)) {
			for (int i = 0; i < n; ++i) {
				if (a[i] < 0) {
					a[i] += maxx;
					ans.pb({posMax, i});
				}
			}
		} else {
			for (int i = 0; i < n; ++i) {
				if (a[i] > 0) {
					a[i] += minn;
					ans.pb({posMin, i});
				}
			}
		}
	}

	bool allPositive = true, allNegative = true;
	for (int i = 0; i < n; ++i) {
		if (a[i] < 0) {
			allPositive = false;
		}
		if (a[i] > 0) {
			allNegative = false;
		}
	}

	assert(allPositive || allNegative);

	if (allPositive) {
		for (int i = 1; i < n; ++i) {
			if (a[i] < a[i - 1]) {
				a[i] += a[i - 1];
				ans.pb({i - 1, i});
			}
		}
	} else {
		for (int i = n - 2; i >= 0; --i) {
			if (a[i] > a[i + 1]) {
				a[i] += a[i + 1];
				ans.pb({i + 1, i});
			}
		}
	}

	cout << sz(ans) << "\n";
	for (int i = 0; i < sz(ans); ++i) {
		cout << ans[i].first + 1 << " " << ans[i].second + 1 << "\n";
	}

}


Measured memory_bytes: 256