akhauriyash/Code-Regression huggingface dataset:
// I need some holiday
// But I don't wish that everyday is holiday
// Because I didn't bear the pain
// Because it wasn't a true freedom
//         ——『イヤホンと蝉時雨』·Orangestar

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return cur == ed && (ed = (cur = buffer) + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur == ed) ? EOF : *cur++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

// END tpl.

const int MAXN = 150;

int n, K, MOD;

inline void input()
{
	n = read<int>(), K = read<int>(), MOD = read<int>();
}


namespace sub0
{
	inline int calc(int N)
	{
		static int f[MAXN + 5][MAXN + 5];
		memset(f, 0, sizeof f);

		f[0][0] = 1;
		for(int i = 0; i < N; ++i)
			for(int j = 0; j <= K / 2; ++j) if(f[i][j])
			{
				(f[i + 1][j + 1] += f[i][j]) %= MOD;
				(f[i + 1][0] += f[i][j]) %= MOD;
			}

		int ans = 0;
		for(int i = 0; i <= K / 2; ++i) (ans += f[N][i]) %= MOD;
		return ans;
	}

	inline void solve()
	{
		int ans = (LL) calc(n / 2) * calc(n - n / 2) % MOD;
		printf("%d\n", (ans + MOD) % MOD);
	}
}

namespace sub1
{
	inline void solve()
	{
		static int f[MAXN + 5][MAXN + 5][MAXN + 5];

		f[0][0][0] = 1;
		for(int i = 0; i < K / 2 + (n + 1) / 2; ++i)
			for(int j = 0; j <= K + 1; ++j) for(int k = 0; k <= n; ++k) if(f[i][j][k])
			{
				int p = (i + 1 - K / 2) * 2 - 1, q = (i + 1) * 2;

				// 0 0
				(f[i + 1][0][0] += f[i][j][k]) %= MOD;

				// 1 0
				if(1 <= p && p <= n)
				{
					if(j > 0) (f[i + 1][j + 1][0] += f[i][j][k]) %= MOD;
					else (f[i + 1][0][0] += f[i][j][k]) %= MOD;
				}

				// 0 1
				if(1 <= q && q <= n) (f[i + 1][0][k + 1] += f[i][j][k]) %= MOD;

				// 1 1
				if(1 <= p && p <= n && 1 <= q && q <= n) (f[i + 1][max(j + 1, k + 2)][k + 1] += f[i][j][k]) %= MOD;
			}

		int ans = 0;
		for(int i = 0; i <= K + 1; ++i) for(int j = 0; j <= n; ++j) (ans += f[K / 2 + (n + 1) / 2][i][j]) %= MOD;
		printf("%d\n", (ans + MOD) % MOD);
	}
}

int main()
{
#ifdef K_ON
	freopen("E.in", "r", stdin);
	freopen("E.out", "w", stdout);
#endif

	input();
	if(K % 2 == 0) sub0::solve();
	else sub1::solve();

	return 0;
}




Measured memory_bytes: 12672
#include <bits/stdc++.h>
#define N 100
#define INF 1e9 + 5
#define LINF 1e18 + 5

using namespace std;
using ll = long long;
string a, b;
int memo[3002][3002];
int solve(int y, int x)
{

    if (x == 0 || y == 0)
        return memo[y][x] = 0;
    int &best = memo[y][x];
    if (best != -1)
        return best;
    best = max(solve(y - 1, x), solve(y, x - 1));
    if (a[y] == b[x])
        best = max(best, solve(y - 1, x - 1) + 1);
    return best;
}
/*
 abyxb
a10000 
x11122
y11222
b12223
*/
int main()
{
    cin >> a >> b;
    a = "$" + a;
    b = "$" + b;
    int y , x;
    y = a.length()-1;
    x = b.length()-1;
    //memo.resize(a.length() + 1, vector<int>(b.length() + 1, -1));
    memset(memo, -1, sizeof(memo));
    int maxlenth = solve(y, x);
    string t = "";
    while (x > 0 && y > 0)
    {
        if (memo[y][x] == memo[y - 1][x])
            y--;
        else if (memo[y][x] == memo[y][x - 1])
            x--;
        else
        {
            t = a[y--] + t;
            x--;
        }
    }
    cout << t;
    return 0;
}

Measured memory_bytes: 35968
N = int(input())
a1 = []
a2 = []
for i, v in enumerate(input().split()):
    if i % 2 == 0:
        a1.append(v)
    else:
        a2.append(v)

if N % 2 == 0:
    a1, a2 = a2, a1
if a1:
    print(*reversed(a1),end=' ')
print(*a2)

Measured memory_bytes: 22336
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>
#include <bitset>
#include <numeric>

using namespace std;
typedef long long ll;
ll MOD = 1000000007;

vector<ll> divisor(ll n)
{
    vector<ll> ret;
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return (ret);
}

int main()
{
    int n, K;
    cin >> n >> K;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];

    vector<ll> s = divisor(accumulate(a, a + n, 0));
    for (int k = s.size() - 1; k > -1; k--)
    {
        int t[n];
        for (int i = 0; i < n; i++)
        {
            t[i] = a[i] % s[k];
        }
        sort(t, t + n);
        ll l = accumulate(t, t + n, 0), r = 0;
        for (int i = n - 1; i > -1; i--)
        {
            if (r + l <= K * 2 && l == r)
            {
                cout << s[k] << endl;
                return 0;
            }
            r += s[k] - t[i];
            l -= t[i];

            if (r + l < (K * 2) && r == l)
            {
                cout << s[k] << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m,k;
  cin >> n >> m >> k;
  vector<P> l,r;
  l.pb(P(MAXL,-1));
  l.pb(P(-MAXL,-2));
  rep(i,n) {
    ll x,y;
    cin >> x >> y;
    if(y==1) r.pb(P(x,i+1));
    else l.pb(P(x,i+1));
  }
  sort(all(l));
  sort(all(r));
  map<ll,ll> ma;
  ma[-2]=-MAXL;
  rrep(i,r.size()) {
    int x=upper_bound(all(l),r[i])-l.begin();
    ll d=(l[x].F+r[i].F)/2;
    if(ma.count(l[x].S)) d=max(d,ma[l[x].S]);
    ma[r[i].S]=min(d,r[i].F+m);
    ma[l[x].S]=max(d,l[x].F-m);
  }
  REP(i,1,l.size()-1) {
    if(!ma.count(l[i].S)) ma[l[i].S]=max(ma[l[i-1].S],l[i].F-m);
  }
  rep(i,k) {
    int x;
    R x;
    pr(ma[x]);
  }
}

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


Measured memory_bytes: 10728
S = str(input())

n = len(S)
ans = [0 for x in range(n)]
i = 0
ToRight = True
while i < n - 1:
    start = i
    while i < n - 1 and S[i + 1] == S[i]:
        i += 1
    if ToRight:
        ans[i] += (i + 1 - start) // 2 + (i + 1 - start) % 2
        ans[i + 1] += (i + 1 - start) // 2
    else:
        ans[start] += (i + 1 - start) // 2 + (i + 1 - start) % 2
        ans[start - 1] += (i + 1 - start) // 2
    i += 1
    ToRight = not ToRight
if S[n - 2] == 'R':
    ans[n - 1] += 1

print(*ans)

Measured memory_bytes: 6408
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
  	int n;
  	cin>>n;
  	long ans = 0;
  	for(int i = 1;i<=n; i++){
  	    for(int j=1;j<=n;j++){
  	        for(int k=1;k<=n;k++){
  	            int a = __gcd(i,j);
  	            int b = __gcd(a,k);
  	            ans +=b;
  	        }
  	    }
  	}
  	cout<<ans<<endl;
 	return 0; 
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <algorithm>

using namespace std;
using ll = long long;

int n, k, g;
char s[100010];
int main() {
	scanf("%d %d", &n, &k);
	scanf("%s", s);

	g = 1;
	for (int i = 1; i < n; i++)
		if (s[i - 1] != s[i])
			g++;

	int s = n - g;
	for (int i = 0; i < k; i++) {
		if (g == 1)
			continue;
		if (3 <= g) {
			s += 2;
			g -= 2;
			continue;
		}
		s += 1;
		g -= 1;
	}
	printf("%d\n", s);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int A[] = new int[26];
		for (int i=0;i<s.length();i++) {
			A[s.charAt(i)-'a']++;
		}
		for (int i=0;i<A.length;i++) {
			if (A[i]==0) {
				System.out.print(s);
				System.out.print((char)(i+'a'));
				return;
			}
		}
		for (int i=A.length-1;i>=0;i--) {
			A[s.charAt(i)-'a']--;
			for (char c=(char) (s.charAt(i)+1);c<='z';c++) {
				if (A[c-'a']==0) {
					System.out.print(s.substring(0,i));
					System.out.print(c);
					return;
				}
			}
		}
		System.out.println(-1);
	}
}

Measured memory_bytes: 35636
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long
using namespace std;

int main() {
	string ans = "No";
	int n,sum,max;
	cin >> n;
	int b[10];
	max = 0;
	sum = 0;
	rep(i, n) {
		cin >> b[i];
		if (max < b[i]) {
			max = b[i];
		}
		sum += b[i];
	}
	sum = sum - max;
	if (sum > max) {
		ans = "Yes";
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
// Author : Nachiket Kanore
// Institute : PICT, Pune

/* It does not matter how slowly you go as long as you do not stop.*/

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcount(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define see(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define see(x...)
#endif

const int inf = 1e18;
const int N = 1005;



int32_t main(){
    FAST;

    int a , b;  cin >> a >> b;
    if(a < b)
        cout << 0;
        else cout << 10;

    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
using namespace std;
int main(void){
    int W[10];
    int K[10];
    
    int i=0;
    while(i<10){
        cin>>W[i];
        i++;
    }
    while(i<20){
        cin>>K[i-10];
        i++;
        
    }
    sort(W,W+10);
    sort(K,K+10);
    
    cout<<W[7]+W[8]+W[9]<<" "<<K[7]+K[8]+K[9]<<endl;
    
}



Measured memory_bytes: 3148
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
    int b,c,i,n,x,m,a[100000];
    cin>>n>>x;
    for(i=1;i<=n;i++)
    {
       cin>>a[i];
    }
    for(i=1;i<=n;i++)
    {
        m=m+a[i];
    }
    sort(a+1,a+n+1);
    c=x-m;
    b=c/a[1];
    b=b+n;
    cout<<b<<endl;
    return 0;
}


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

using namespace std;


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 2e6 + 1, MOD = 1e9 + 7, mod = 998244353, INF = 3e17;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

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

char c[2000][2000];
queue <pair <pair <int, int>, int>> q;

bool check (int i, int j) {
    if (i < 0 || i >= n || j < 0 || j >= m) return false;
    if (c[i][j] == '#') return false;
    return true;
}

void bfs () {
    while (!q.empty()) {
        int i1 = q.front().ff.ff, j1 = q.front().ff.ss, xod = q.front().ss;
        maxx = xod;
        q.pop();
        for (int i = 0; i < 4; i++) {
            int x = i1 + dx[i], y = j1 + dy[i];
            if (check(x, y)) {
                c[x][y] = '#';
                q.push({{x, y}, xod + 1});
            }
        }
    }
}

signed main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);
   cin >> n >> m;
   for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
       cin >> c[i][j];
       if (c[i][j] == '#') q.push({{i, j}, 0});
    }
    bfs();
    cout << maxx;

}


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


#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

ll mod = 1e9 + 7ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll inf = 1ll << 60;

int n, m;
vector<int> s,t;

int main() {
    cin >> n >> m;
    int v;
    rp(i, 0, n){
        scanf("%d", &v);
        s.emplace_back(v);
    }
    rp(i, 0, m){
        scanf("%d", &v);
        t.emplace_back(v);
    }

    vector<vector<ll>> dp(2020, vector<ll>(2020));
    rp(i, 0, m+1){
        dp.at(0).at(i) = 1;
    }
    rp(i, 0, n+1){
        dp.at(i).at(0) = 1;
    }
    rp(i, 1, n+1){
        rp(j, 1, m+1){
            if(s.at(i-1) == t.at(j-1)) dp.at(i).at(j) = (dp.at(i).at(j-1) + dp.at(i-1).at(j))%mod;
            else dp.at(i).at(j) = (mod + dp.at(i).at(j-1) + dp.at(i-1).at(j) - dp.at(i-1).at(j-1))%mod;
        }
    }
    printf("%lld", dp.at(n).at(m));

}


Measured memory_bytes: 32256
#include<stdio.h>
#define INF 1000000000
int cnt=0;
void merge(int *,int,int,int);
void mergeSort(int *,int,int);
int main(){
  int n;
  int S[500001];
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&S[i]);
  mergeSort(S,0,n);
  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i!=n-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",cnt);
  return 0;
}

void merge(int S[],int left,int mid,int right){
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1+1],R[n2+1];
  int i,j,k;
  for(i=0;i<n1;i++) L[i] = S[left + i];
  for(i=0;i<n2;i++) R[i] = S[mid + i];
  L[n1] = INF;
  R[n2] = INF;
  i = 0;
  j = 0;
  for(k = left; k< right;k++){
    if(L[i] <= R[j]){
      S[k] = L[i];
      i++;
    }
    else {
      S[k] = R[j];
      j++;
    }
    cnt++;
  }
}

void mergeSort(int S[],int left,int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right) / 2;
    mergeSort(S,left,mid);
    mergeSort(S,mid,right);
    merge(S,left,mid,right);
  }
}



Measured memory_bytes: 5628
S = list(input())

C = [0 for i in range(4)]
for i in range(4):
    for j in range(4):
        if S[i] == S[j]:
            C[i] += 1

for i in range(4):
    if C[i] != 2:
        print("No")
        break
else:
    print("Yes")


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

int main(){
  int n,t;
  cin>>n>>t;
  string str;
  cin>>str;
  
  long long time=0;
  for(int i=0;i<str.size();i++){
    if(str[i]=='^'){
      int num=str[i+1]-'0';
      long long N=1;
      for(int j=0;j<num&&N<(1e9);j++)N*=n;
      time+=N;
      if(time*t>1000000000)break;
    }
  }

  if(time*t>1000000000)cout << "TLE"<<endl;
  else cout <<time*t<<endl;


}

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

#define int long long
#define w cout
#define e '\n'
#define sz(x) (int)x.size()
template<class T, class U> inline istream& operator>>(istream& str, pair<T, U> &p) { return str >> p.first >> p.second; }
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }

const int N = 1e6 + 10 , mod = 998244353;


signed main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n; cin >> n;
	vector<int> v(n); cin >> v;
	int curr = v[0] , ans = 0;
	for(int i = 0; i < n ;i ++ ){
		curr = min(curr , v[i]);
		if(curr >= v[i]) ans++;
	}
	w << ans;
}



Measured memory_bytes: 1792
def solve(m, d):
    ans = 0
    for i in range(1, m+1):
        for j in range(1, d+1):
            d1 = j % 10
            d10 = j // 10
            if (d1 >= 2) and (d10 >= 2) and (d1 * d10 == i):
                ans += 1
    return ans

m, d = map(int, input().split())
print(solve(m, d))

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int A,B,K;
    cin >> A >> B >> K;
    vector<int> ans;
    for (int i = A; i <= B; i++){
        if (i < A+K){
            ans.push_back(i);
        } else if (i > B-K){
            ans.push_back(i);
        }
    }
    for (int i = 0; i < (int)ans.size(); i++){
        cout << ans[i] << endl;
    }


    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef long double ld;
const ld pi = 4*atan((ld)1);
const ll mod = 1e9 + 7;
const ll inf = 922337203685477;
const ll nax = 2e5 + 5;

set<pair<ll,ll>> st;
ll n, m, cnt;
vector<vector<ll>> v(nax);
ll vis[nax];

void dfs(ll x){
	vis[x] = 1;
	cnt++;
	for(auto y : v[x]){
		if(!vis[y]){
			dfs(y);
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n >> m;
	for(ll i = 1; i <= m; i++){
		ll a, b;
		cin >> a >> b;
		if(a > b){
			swap(a, b);
		}
		if(!st.count({a, b})){
			st.insert({a, b});
		}
	}
	for(auto x : st){
		ll a = x.ff;
		ll b = x.ss;
		v[a].pb(b);
		v[b].pb(a);
	}
	ll ans = 0;
	for(ll i = 1; i <= n; i++){
		if(!vis[i]){
			cnt = 0;
			dfs(i);
			ans = max(ans, cnt);
		}
	}
	cout << ans << '\n';
}



Measured memory_bytes: 34332
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
typedef unsigned long long ull;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	ll f=1;
	while((c=getchar())!='-' && (c<'0' || c>'9'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=350+10,inf=0x3f3f3f3f,mod=1e9+7;
int n;
ll K;
struct Hash_Table{
	static const int mod1=3e4+7;
	int Begin[mod1],Next[maxn*100],e;
	ull to1[maxn*100],to2[maxn*100];
	ull Pw1[maxn],Pw2[maxn];
	vector<pair<ll,ll> > vc[maxn*100];
	void init(){
		memset(Begin,0,sizeof(Begin));
		e=0;
		Pw1[0]=Pw2[0]=1;
		REP(i,1,n) Pw1[i]=Pw1[i-1]*11ull,Pw2[i]=Pw2[i-1]*29ull;
	}
	void insert(ll *a,ll l,ll r){
		ull x=0,y=0;
		REP(i,1,n) x=x*Pw1[1]+a[i],y=y*Pw2[1]+a[i];
		int i=0;
		for(i=Begin[x%mod1];i;i=Next[i])
			if(to1[i]==x && to2[i]==y){
//				cout<<x<<' '<<y<<' '<<to1[i]<<' '<<to2[i]<<endl;
				break;
			}
		if(!i){
			to1[++e]=x;to2[e]=y;
			Next[e]=Begin[x%mod1];
			Begin[x%mod1]=e;
			i=e;
		}
//		cout<<x<<' '<<y<<endl;
//		cout<<i<<' '<<l<<' '<<r<<endl;
		vc[i].push_back(make_pair(l,r));
	}
	int findans(){
		int ans=0;
		for(int l=0;l<mod1;++l)
			for(int i=Begin[l];i;i=Next[i]){
				ll L=0,R=-1;
				sort(vc[i].begin(),vc[i].end());
				REP(j,0,vc[i].size()-1)
					if(vc[i][j].first>R){
						ans=(ans+(R-L+1)%mod)%mod;
						L=vc[i][j].first,R=vc[i][j].second;
//						cout<<ans<<endl;
//						cout<<vc[i][j].first<<' '<<vc[i][j].second<<endl;
//						cout<<L<<' '<<R<<endl;
					}
					else R=max(R,vc[i][j].second);
//				cout<<L<<' '<<R<<endl;
				ans=(ans+(R-L+1)%mod)%mod;
//						cout<<ans<<endl;
				vc[i].clear();
			}
		return ans;
	}
}Hash;
ll a[maxn];
struct point{
	ll b,c;
	bool operator <(const point &rhs) const{
		return c<rhs.c;
	}
}tmp[maxn];
int Minnum(ll x,ll y){
	if(x>y) return inf;
	int num=0;
	DREP(i,59,0){
		if((x&(1ll<<i))!=(y&(1ll<<i))){
			if(x&((1ll<<i)-1)) num++;
			break;
		}
		else num+=(x>>i)&1;
	}
	return num;
}
ll r[maxn];
void add(int p,ll res){
	if(res<0) return; 
	ll Min=tmp[1].b-(1<p);
	REP(i,1,n){
		r[i]=tmp[i].b-(i<p);
		Min=min(Min,r[i]);
	}
	if(Min<0) return;
	REP(i,1,n) r[i]-=Min;
	sort(r+1,r+n+1);
//	REP(i,1,n) printf("%lld%c",r[i],i==iend?'\n':' ');
//	cout<<Min<<' '<<res<<endl;
//	cout<<Min<<' '<<res<<endl;
	Hash.insert(r,max(Min-res,0ll),Min);
}
int main(){
	int T=1;
	while(T--){
		n=read(),K=readll();
		Hash.init();
		REP(i,1,n) a[i]=readll();
		REP(k,0,60){
			REP(i,1,n)
				tmp[i]=(point){a[i]>>k,a[i]&((1ll<<k)-1)};
			sort(tmp+1,tmp+n+1);
			ll l=0;
			for(int i=1,nxt;i<=n;l=tmp[i].c+1,i=nxt+1){
				nxt=i;
				while(nxt<n && tmp[nxt+1].c==tmp[i].c) ++nxt;
				add(i,K-Minnum(l,tmp[i].c)-k);
			}
		}
		printf("%d\n",Hash.findans());
	}
	return 0;
}

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

int main() {
  int K;
  string S,T;
  cin>>K>>S;
  if(S.size()<=K){
    cout << S << endl;
  }
  else{
    
   
    cout << S.substr(0,K) << "..." << endl;
  }
      
  
}


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

int main() {
	int x[5];
	cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];
	for(int i=0;i<5;i++) {
		if(x[i]==0) {
			cout<< i + 1;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9+5;
constexpr long long INFLL = 1LL<<60;
constexpr double eps = (1e-9);

void warshall_floyd(const int& n, vector<vector<int>>& d) {
  rep(k, n) rep(i, n) rep(j, n) chmin(d[i][j], d[i][k] + d[k][j]);
}

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

  int h, w;
  cin >> h >> w;

  vector<vector<int>> c(10, vector<int>(10));
  rep(i, 10) rep(j, 10) cin >> c[i][j];

  warshall_floyd(10, c);

  ll ans = 0;

  rep(i, h) rep(i, w) {
    int a; cin >> a;
    if (a == -1 ) continue;
    ans += c[a][1];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e2+20;
char a[N][N],b[N][N];
int main()
{
	int n,m;
	while(cin>>n>>m)
	{
		for(int i=0;i<n;i++)
			scanf("%s",a[i]);
		for(int i=0;i<m;i++)
			scanf("%s",b[i]);
		//枚举第一个开始匹配的点 然后暴力匹配即可 
		bool match;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(i+m-1>=n||j+m-1>=n) continue;
				
				match=true;
				for(int x=0;x<m;x++)
				{
					for(int y=0;y<m;y++)
					{
						if(a[i+x][j+y]!=b[x][y])
						match=false;
					}
				}
				if(match)
				break;
			}	
			if(match)
			break;
		}	
		if(match)
		puts("Yes");
		else
		puts("No");
		
	}
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m,i,j,a[100005],cnt[100005];
set<int> v;
vector<int> ans;
void print(){
	for(i=0;i<n;i++){
		printf("%d%c",ans[i],(i+1==n?'\n':' '));
	}
	exit(0);
}
void inc(int x){
	ans.push_back(x);
	v.erase(x);
}
void dec(){
	v.insert(ans.back());
	ans.pop_back();
}
void dfs(int ban){
	if(ans.size()==n){
		print();
	}
	if(v.count(ban)&&cnt[ban]==n-ans.size()){
		return;
	}
	cnt[ban]--;
	for(set<int>::iterator it=v.begin();it!=v.end();it++){
		if(*it==ban) continue;
		inc(*it);
		dfs(a[*it]);
		dec();
	}
	cnt[ban]++;
}
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		cnt[a[i]]++;
		v.insert(i);
	}
	for(i=1;i<=n;i++){
		inc(i);
		dfs(a[i]);
		dec();
	}
	puts("-1");
	return 0;
}

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

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

using namespace std;

int main() {
  string s; cin >> s;
  s.erase(unique(s.begin(), s.end()), s.end());
  cout << (int)s.size() - 1 << "\n";
}


Measured memory_bytes: 512
from collections import deque
from collections import defaultdict
import math
t = int(input())
def solve(n):
    if dist[n] != float('inf'):
        return dist[n]
    if n == 0:
        return 0
    if n == 1:
        return d
    ans = float('inf')
    for x,cost in ([5,c],[3,b],[2,a]):
        e = 0
        if n%x:
            e = 1 
        y = n%x
        ans = min(ans,solve(n//x) + cost + (e*d*y))

        if e ==1:
            ans = min(ans,solve(n//x+1) + cost + ((x-y)*d))
    dist[n] = min(ans,n*d)   
    return dist[n]

for i in range(t):
    n,a,b,c,d, = list(map(int,input().split()))
    dist = defaultdict(lambda: float('inf'))
    print(solve(n))


Measured memory_bytes: 11220
# encoding:utf-8
import numpy
import bisect
 
def main():
	n, x = list(map(int, input().split()))
	nums = list(map(int, input().split()))

	nums.sort()
	cum_nums = numpy.cumsum(nums)

	if x > cum_nums[-1]:
		print(n - 1)
	else:
		idx = bisect.bisect_right(cum_nums, x)
		print(idx)


if __name__ == '__main__':
	main()

Measured memory_bytes: 21804
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		long integer[] = new long[num];
		boolean plus[] = new boolean[num];
		for(int i = 0; i < num; i ++) {
			integer[i] = sc.nextLong();
		}
		Arrays.sort(integer);
		for(int i = 0; i < num; i ++) {
			plus[i] = i == 0 ? false : i == num - 1 ? true : integer[i] >= 0;
		}
		int count[] = {0, 0};
		int ans = 0;
		PriorityQueue<Long> lPlus = new PriorityQueue<>();
		PriorityQueue<Long> lMinus = new PriorityQueue<>();
		for(int i = 0; i < num; i ++) {
			count[plus[i] ? 1 : 0] ++;
			ans += integer[i] * (plus[i] ? 1 : -1);
			if(plus[i]) {
				lPlus.add(integer[i]);
			}else {
				lMinus.add(integer[i]);
			}
		}
		System.out.println(ans);


		for(int n = 1; n <= num - 1; n ++) {
			long tmp[] = {(long)lPlus.poll(), (long)lMinus.poll()};
			if(lPlus.size() <= lMinus.size()) {
				System.out.println(tmp[0]+" "+tmp[1]);
				lPlus.add(tmp[0] - tmp[1]);
			}else {
				System.out.println(tmp[1]+" "+tmp[0]);
				lMinus.add(tmp[1] - tmp[0]);
			}
		}
	}
}

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

int main(){
  int h, w;
  cin >> h >> w;
  
  vector<string> board(50);
  for (int i=0;i<h;++i) cin >> board.at(i);
  
  const vector<int> dx = {1,0,-1,0,1,1,-1,-1};
  const vector<int> dy = {0,1,0,-1,1,-1,1,-1};
  
  for (int i=0;i<h;++i){
      for (int j=0;j<w;++j){
      	if (board.at(i).at(j) == '#') continue;
        
        int n=0;
        for (int k=0;k<8;++k){
          const int ni = i + dy.at(k);
          const int nj = j + dx.at(k);
          if (ni < 0 || h <= ni) continue;
          if (nj < 0 || w <= nj) continue;
          
          if (board.at(ni).at(nj) == '#') n++;
        }
        
        board.at(i).at(j) = char(n+'0');
      }
  }
  for (int i = 0 ; i < h ; ++i) cout << board.at(i) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod


int half(int X){
    int x = 0;
    while(X%2 ==0){
        X /= 2;
        x ++;
    }
    return x;
}

signed main(){
    int N; cin>>N;
    vec a(N); REP(i,N) cin>>a[i];
    int ans = 0;
    REP(i,N){
        ans += half(a[i]);
    }
    cout<<ans <<endl;
}

Measured memory_bytes: 384
def cal (operand, a, b):
    if operand == "+":
        return int(a) + int(b)
    elif operand == "-":
        return int(a) - int(b)
    elif operand == "*":
        return int(a) * int(b)
s =[]
top = 0
S = list(input().split())
stk = []
for i in S:
    if i.isdigit() == True:
        stk.append(int(i))
    else:
        b = stk.pop()
        a = stk.pop()
        stk.append(cal(i, a, b))
print(stk[0])


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

const int N = 110;

inline char get(void) {
	static char buf[100000], *S = buf, *T = buf;
	if (S == T) {
		T = (S = buf) + fread(buf, 1, 100000, stdin);
		if (S == T) return EOF;
	}
	return *S++;
}
inline void read(int &x) {
	static char c; x = 0;
	for (c = get(); c < '0' || c > '9'; c = get());
	for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
}

int n, d;
int a[N], buc[N];

inline void Godie(void) {
	puts("Impossible");
	exit(0);
}

int main(void) {
	read(n);
	for (int i = 1; i <= n; i++) {
		read(a[i]); ++buc[a[i]];
	}
	d = *max_element(a + 1, a + n + 1);
	if (d & 1) {
		for (int i = d - d / 2; i <= d; i++) {
			buc[i] -= 2; if (buc[i] < 0) Godie();
		}
		for (int i = d - d / 2; i; i--)
			if (buc[i]) Godie();
	} else {
		if (!buc[d / 2]) Godie(); --buc[d / 2];
		for (int i = d / 2 + 1; i <= d; i++) {
			buc[i] -= 2; if (buc[i] < 0) Godie();
		}
		for (int i = d / 2; i; i--)
			if (buc[i]) Godie();
	}
	puts("Possible");
	return 0;
}

Measured memory_bytes: 256
S = list(str(input()))
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
    print('Yes')
elif S[0] == S[2] and S[1] == S[3] and S[0] != S[1]:
    print('Yes')
elif S[0] == S[3] and S[1] == S[2] and S[0] != S[1]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

typedef int Type;
struct Fenwick{
    vector<Type> bit;
    Fenwick(int n){
        bit = vector<Type>(n + 1);
    }
    void update(int i, Type v){
        int n = bit.size();
        ++i;
        while(i <= n){
            bit[i] += v;
            i += i & -i;
        }
    }
    Type get(int i){
        Type res = 0;
        ++i;
        while(i > 0){
            res += bit[i];
            i -= i & -i;
        }
        return res;
    }
};

bool judge(const vector<int> &a, int K) {
	int N = a.size();
	vector<int> b(N + 1);
	for(int i = 0; i < N; ++i) {
		b[i+1] = a[i] >= K ? 1 : -1;
		b[i+1] += b[i];
	}
	int t = 0;
	Fenwick bit(N * 2 + 1);
	for(int i = 0; i < N; ++i) {
		bit.update(b[i] + N, 1);
		t += bit.get(b[i+1] + N);
	}
	//cout << t  << "," << (N * (N +1) / 2 + 1) / 2<< endl;

	return t >= (N * (N + 1) / 2 + 1) / 2;
}

signed main(){
	int N;
	cin >> N;
	vector<int> a(N);
	for(int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	int l = 0, u = (int)1e10;
	while(u - l > 1) {
		int c = (l + u) / 2;
		if (judge(a, c)) {
			l = c;
		} else {
			u = c;
		}
	}
	cout << l << endl;
	return 0;
}


Measured memory_bytes: 3420
#include<bits/stdc++.h>
using namespace std;
const int N = 5e2+10;
const int P = 1e9+7;

inline int pow_mod(int x,int k){
   int base = x,res = 1;
   while(k){
      if(k & 1)res = 1LL*res*base%P;
      k >>= 1;
      base = 1LL*base*base%P;
   }
   return res;
}

int fact[N],inv[N];
void init(){
   fact[0] = inv[0] = 1;
   for(int i = 1;i < N; ++i)fact[i] = 1LL*fact[i-1]*i%P;
   inv[N-1] = pow_mod(fact[N-1],P-2);
   for(int i = N-2;i > 0; --i)inv[i] = 1LL*inv[i+1]*(i+1)%P;
}

inline int c(int x,int y){
   return 1LL*fact[x]*inv[x-y]%P*inv[y]%P;
}

int n,m,k;

int gcd(int x,int y){
   if(x < y)swap(x,y);
   return (y == 0)?x:gcd(y,x%y);
}

inline int calc(int x){
   int ret = 0;
   for(int i = 1;i <= x; ++i){
      ret += pow_mod(k,gcd(i,x));
      ret %= P;
   }
   ret = 1LL*ret*pow_mod(x,P-2)%P;
   return ret;
}

stack<int> s1;
vector<int> v1[N];

struct edge{
   int x,y;
}e[N];

int ga[N][N];

vector<int> p[N];
int tot;
int dfn[N],cut[N],low[N];
int ins[N];
int cnt,ct;
void tarjan(int x,int fa,int rt){
   dfn[x] = low[x] = ++cnt;
   ct = 0;
   for(int i = 0;i < (int)v1[x].size(); ++i){
      int y = v1[x][i];
      if(y == fa)continue ;
      if(!dfn[y]){
         s1.push(y); ins[y] = 1;
         tarjan(y,x,rt);
         low[x] = min(low[x],low[y]);
         if(low[y] >= dfn[x]){
            ++ct;
            if(x != rt || ct > 1)cut[x] = 1;
            ++tot;
            int w;
            do {
               w = s1.top(); s1.pop(); ins[w] = 0;
               p[tot].push_back(w);
            }while(w != y);
            p[tot].push_back(x);
         }
      }
      else if(dfn[y] < low[x])low[x] = dfn[y];
   }
}
int vis[N];
int vise[N];
int main(){
   init();
   scanf("%d%d%d",&n,&m,&k);
   for(int i = 1;i <= m; ++i){
      int u,v;
      scanf("%d%d",&u,&v);
      v1[u].push_back(v); v1[v].push_back(u);
      e[i].x = u; e[i].y = v;
      ga[u][v] = i; ga[v][u] = i;
   }
   for(int i = 1;i <= n; ++i){
      if(!dfn[i])tarjan(i,0,i);
   }
   int edgenum;
   int res = 1;
   for(int i = 1;i <= tot; ++i){
      memset(vis,0,sizeof vis);
      for(int j = 0;j < (int)p[i].size(); ++j){
         int y = p[i][j];
         vis[y] = 1;
      }
      edgenum = 0;
      for(int j = 0;j < (int)p[i].size(); ++j){
         int y = p[i][j];
         for(int k = 0;k < (int)v1[y].size(); ++k){
            int w = v1[y][k];
            if(vis[w]){
               ++edgenum;
               vise[ga[y][w]] = 1;
            }
         }
      }
      edgenum /= 2;
      if(edgenum == p[i].size())
         res = 1LL*res*calc(edgenum)%P;
      else if(edgenum == 1 && (int)p[i].size() == 2)
         res = 1LL*res*k%P;
      else 
         res = 1LL*res*c(k-1+edgenum,k-1)%P;
   }
   printf("%d\n",res);
   return 0;
}


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

using namespace std;

const int N = 3000 + 3;

int main() {
  string s, t;
  cin >> s >> t;

  int dp[N][N];
  memset(dp, 0, sizeof dp);

  for(int i = 1; i <= s.size(); ++i) {
    for(int j = 1; j <= t.size(); ++j) {
      if(s[i - 1] == t[j - 1]) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
      } else {
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      }
    }
  }

  string ans = "";
  int y = s.size(), x = t.size();

  while(y > 0 && x > 0) {
    if(s[y - 1] == t[x - 1]) { //only decrease both when they have the same char
      ans += s[y - 1]; //or t[x - 1];
      --y;
      --x;
    } else if(dp[y - 1][x] > dp[y][x - 1]) --y;
    else --x;
  }

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

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 35456
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    string s1, s2;
    cin >> s1;
    cin >> s2;
    sort(s1.begin(), s1.end());
    sort(s2.begin(), s2.end());
    reverse(s2.begin(), s2.end());

    if(s1<s2) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string  s;
string t="AKIHABARA";
int main(){
    while(cin>>s){
        bool flag=false;
        int len=s.length();

        if(s=="t"){
            cout<<"YES"<<endl;
            continue;
        }else if(len > 9){
            cout<<"NO"<<endl;
            continue;
        }
        if(s[0]!='A') s.insert(s.begin(),'A');
        for(int i=2;i<=s.length();++i){
            if(s[i-1]=='H' && s[i]!='A') s.insert(s.begin()+i,'A');
            if(s[i-1]=='B' && s[i]!='A') s.insert(s.begin()+i,'A');
            if(s[i-1]=='R' && s[i]!='A') s.insert(s.begin()+i,'A');
        }
        if(s==t)
            cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#include<map>
typedef long long ll;
using namespace std;
#define INF 0x3f3f3f3f
/**
*超时有可能是输入的问题
*注意边界
*仔细读题
*没思路试试逆向思维
**加油，奥利给！！！ 
**/
map<int,int>p;
int a[200000];
int main()
{
	ll m,n,i,j,t,s=0,k;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		if(i%3!=0&&i%5!=0)
		s+=i;
	}
	cout<<s;
 } 

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

int main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
}


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

const long long P = 1000000007;

int main(){
    long long n;
    cin >> n;
    if (n == 1LL){
        cout << 0 << endl;
        return 0;
    }
    long long t0 = 1;
    for (int i = 1; i <= n; ++i){
        t0 = t0 * 10 % P;
    }
    long long t1 = 1;
    for (int i = 1; i <= n; ++i){
        t1 = t1 * 9 % P;
    }
    long long t2 = 1;
    for (int i = 1; i <= n; ++i){
        t2 = t2 * 8 % P;
    }
    long long ans = ((t0 - t1 * 2 + t2) % P + P) % P;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3548
#include <stdio.h>
#include <stdbool.h>

bool is_equilateral_triangle(A, B, C)
{
    if (A == B && B == C) { return true;  }
    else                  { return false; }
}

void exawizard2019_a(A, B, C)
{
    if (is_equilateral_triangle(A, B, C)) { printf("%s\n", "Yes"); }
    else                                  { printf("%s\n", "No" ); }
}

int main (void)
{
    /* variables for main process */
    unsigned char A, B, C;

    /* support variables for main process */
    int retval_scanf;

    // STEP.01
    // read out the given integers
    retval_scanf = scanf("%hhu %hhu %hhu", &A, &B, &C);

    // STEP.02
    // determine if there exists an equilateral triangle whose sides have lengths A, B and C.
    exawizard2019_a(A, B, C);
    
    // STEP.TRUE_END
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main {
	static long count = 0;
	public static void main (String[] args) {
		Scanner scan = new Scanner (System.in);
		int n = scan.nextInt();
		int[] data = new int[n];
		
		for (int i = 0; i < n; i++) {
			data[i] = scan.nextInt();
		}
		scan.close();
		
		MergeSort (data, 0, n);
		
		System.out.println(count);
	}
	
	static void MergeSort (int[] data, int left, int right) {
		
		if (left + 1 < right) {
			int mid = (left + right) / 2;
			
			MergeSort(data, left, mid);
			MergeSort(data, mid, right);
			
			Merge(data, left, mid, right);
			
		}
	}
	
	static void Merge (int[] data, int left, int mid, int right) {
		int n1 = mid - left;
		int n2 = right - mid;
		final int INFTY = 1000000000;
		
		int[] L = new int[n1 + 1];
		int[] R = new int[n2 + 1];
		
		for (int i = 0; i < n1; i++) {
			L[i] = data[left + i];
		}
		for (int i = 0; i < n2; i++) {
			R[i] = data[mid + i];
		}
		
		L[n1] = INFTY;
		R[n2] = INFTY;
		
		int i = 0, j = 0;
		int k = left;
		
		while (true) {
			
			if (i == n1 && j == n2) break;
			
			if (L[i] <= R[j]) {
				data[k] = L[i];
				i++;
			} else {
				count += (n1 - i);
				data[k] = R[j];
				j++;
			}
			k++;
		}
		
	}
}



Measured memory_bytes: 74080
import math
def primes(n):
    l= []
    for i in range(2,math.floor(math.sqrt(n))):
        while n % i == 0:
            n = n//i
            l.append(i)
        if n == 1: 
            break
    
    if n > 1:
        l.append(n)
    return l

a,b=map(int,input().split())
sa=set(primes(a))
sb=set(primes(b))
sans=sa.intersection(sb)
print(len(sans)+1)

Measured memory_bytes: 3188
from sys import stdin

a,b,x = [int(x) for x in stdin.readline().rstrip().split()]
point = 0

if a%x==0:
    c = a
else:
    c = a-a%x+x
if c > b:
    print(0)
    exit()
else:
    point += 1
    point += (b-c)//x

print(point)

Measured memory_bytes: 3064
class Allocation
{
    public static void Main()
    {
        var line = System.Console.ReadLine();
        string[] inputInfo = line.Split(' ');
        int luggageCount = int.Parse(inputInfo[0]);
        int truckCount = int.Parse(inputInfo[1]);
        int[] luggageW8 = new int[luggageCount];

        int totalW8 = 0;
        int maxW8   = 0;
        for (int i = 0; i < luggageCount; ++i)
        {
            luggageW8[i] = int.Parse(System.Console.ReadLine());
            if (maxW8 < luggageW8[i]) {
                maxW8 = luggageW8[i];
            }
            totalW8 += luggageW8[i];
        }
        int searchCapacity = (totalW8 + truckCount - 1) / truckCount; //?°???°????????????
        searchCapacity = searchCapacity > maxW8 ? searchCapacity : maxW8;
        int needTruckCount = 0;
        bool endFlg = false;
        for (; endFlg != true; )
        {
            endFlg = true;
            needTruckCount = 1;
            int restCapacity = searchCapacity;
            for (int index = 0; index < luggageCount; ++index)
            {
                restCapacity -= luggageW8[index];
                if (restCapacity < 0)
                {
                    restCapacity = searchCapacity;
                    restCapacity -= luggageW8[index];
                    ++needTruckCount;
                    if (needTruckCount > truckCount)
                    {
                        ++searchCapacity;
                        endFlg = false;
                        break;
                    }
                }
            }
        }
        System.Console.WriteLine(searchCapacity);
    }
}

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

#define MAX 100005
#define NIL -1

struct Node
{
  int parent;
  int left;
  int right;
};

Node T[MAX];
int n;
int depth[MAX];

void print(int u)
{
  int child;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].parent << ", ";
  cout << "depth = " << depth[u] << ", ";

  if (T[u].parent == NIL)
  {
    cout << "root, ";
  }
  else if (T[u].left == NIL)
  {
    cout << "leaf, ";
  }
  else
  {
    cout << "internal node, ";
  }

  cout << "[";
  for (int i = 0, child = T[u].left; child != NIL; i++, child = T[child].right)
  {
    if (i)
      cout << ", ";
    cout << child;
  }
  cout << "]" << endl;
}

int rec(int u, int p)
{
  depth[u] = p;
  if (T[u].right != NIL)
  {
    rec(T[u].right, p);
  }
  if (T[u].left != NIL)
  {
    rec(T[u].left, p + 1);
  }
}

int main()
{
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    T[i].parent = T[i].left = T[i].right = NIL;
  }

  int id;
  int degree;
  int child;
  int l; // 兄弟をつくるため
  for (int i = 0; i < n; i++)
  {
    cin >> id >> degree;
    for (int j = 0; j < degree; j++)
    {
      cin >> child;
      if (j == 0)
      {
        T[id].left = child;
      }
      else
      {
        T[l].right = child;
      }
      l = child; // 兄弟更新
      T[child].parent = id;
    }
  }

  int root;
  for (int i = 0; i < n; i++)
  {
    if (T[i].parent == NIL)
    {
      root = i;
    }
  }

  rec(root, 0);

  for (int i = 0; i < n; i++)
  {
    print(i);
  }

  return 0;
}


Measured memory_bytes: 7764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n,d,ans=0;
    cin>>n>>d;
    rep(0,i,n){
        ll x,y;
        cin>>x>>y;
        if(x*x+y*y<=d*d)++ans;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3636
N,_,C = map(int, input().strip().split(' '))
B = list(map(int, input().strip().split(' ')))
correct_c = 0
for _ in range(N):
  A = list(map(int, input().strip().split(' ')))
  if sum([a*b for a,b in zip(A,B)])+C > 0:
    correct_c += 1
print(correct_c)

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    map<string, ll> strs;
    for (int i = 0; i < N; i++)
    {
        string S;
        cin >> S;
        strs[S]++;
    }
    vector<pair<ll, string>> counts;
    for (auto str : strs)
    {
        counts.emplace_back(str.second, str.first);
    }
    sort(counts.begin(), counts.end());
    ll maxCount = counts.at(counts.size() - 1).first;
    for (auto count : counts)
    {
        if (count.first < maxCount)
        {
            continue;
        }
        cout << count.second << endl;
    }
    return 0;
}


Measured memory_bytes: 27632