akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define M 1000000007
#define ll long long int
#define F first
#define S second
#define INF (ll)1000000000
const int N = 1e5 + 5;
#define maax(a,b,c) max((int)a,max((int)b,(int)c))
#define miin(a,b,c) min((int)a,min((int)b,(int)c))
#define mp make_pair
#define in long long
#define ep emplace_back
#define all(a) a.begin(),a.end()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define inf (long long) 1e18
#define vl vector<ll>
#define sz(a) (ll)a.size()
#define mem(a,b) memset(a,b,a.size())
#define fr(i,m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define fre(i,m, n) for (int i = (int)(n); i <= (int)(m); i--)
#define rall(x) (x).rbegin(), (x).rend()
typedef long long LL;
typedef pair<int, int> PII;	
int solve()
{
    int a,b,q;
	cin>>a>>b>>q;
	while(q--)
	{
		int l,r,u=0;
		cin>>l>>r;
		fr(i,l,r+1)
		{
			//cout<<i<<" "<<(i%a)%b<<" "<<((i%b)%a)<<"\n";
			if(((i%a)%b) != ((i%b)%a)) u=1,cout<<i<<" ",i=r+1;
		}
		(u==0)?cout<<0<<" ":cout<<"";
	} 
	cout<<"\n";
	return 0;
}
bool check(int n)
{
	in h;
	fr(i,4,(n/2))
	{
		h=sqrt(i);
		if((h*h)==i && n%i==0)
		{
			return false;
		}
	}
	return true;
}
int soolve()
{
    string s;cin>>s;int g=0,k,l,x,y;
    fr(i,0,s.size()-1)
    {
    	if(s[i]!=s[i+1]) g++;
    }
    cout<<g/2<<"\n";
	return 0;
}
int sooolve()
{
	string a,b,c;cin>>a>>b>>c;
	map<char,int>x,y,z;
	fr(i,0,a.size()) x[a[i]]++;
	fr(i,0,b.size()) y[b[i]]++;
	fr(i,0,c.size()) z[c[i]]++;
	if(a[0] != b[0])
	{
		cout<<"NO\n";return 0;
	}
	for(auto d:x)
	{
		if(d.S > y[d.F])
		{
			cout<<"NO\n";return 0;
		}
		else if(y[d.F]>(d.S+z[d.F]))
		{
			cout<<"NO\n";return 0;
		}
	}
	cout<<"YES\n";
	return 0;
}
bool is_prime(int n)
{
	if(n==2 || n==3) return true;
	fr(i,2,sqrt(n)+1) 
	{
		if(n%i==0) return false;
	}
	return true;
}
int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
    int n;cin>>n;map<string,int>m;m["AC"]=0,m["TLE"]=0,m["WA"]=0,m["RE"]=0;
    while(n--)
    {
    	string s;cin>>s;m[s]++;
	}
	cout<<"AC x "<<m["AC"]<<"\n"<<"WA x "<<m["WA"]<<"\n"<<"TLE x "<<m["TLE"]<<"\n"<<"RE x "<<m["RE"];
	return 0;	
}	
/*No of Permutations 	:
      =>n!(n is the no of element's)	
  No of subsets:
      =>2^n-1(n is the number of element's of an array)
*/
//set-> all elements are unique and sorted *_*

Measured memory_bytes: 3620
// https://atcoder.jp/contests/abc173/tasks/abc173_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    N = N % 1000;
    cout << (N == 0 ? 0 : 1000 - N) << endl;

    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
using namespace std;
typedef long long ll;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }
const int Maxn = 1e5 + 5;
int n,k;
int main()
{
	cin>>n>>k;
	if(k==1)
		puts("0");
 	else
		cout<<n-k<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	int q; cin >> q;
	while(q--){
		int r,t; cin >> r >> t;
		if(r%100==0){
			if(t%30==0){
				cout << r/100+t/30*5 << endl;
			}
			else{
				cout << r/100+t/30*5 << " " << r/100+t/30*5+5 << endl;
			}
		} 
		else{
			if(t%30==0){
				cout << t/30*5+r/100 << " " << t/30*5+r/100+1 << endl;
			}
			else{
				cout << t/30*5+r/100 << " " << t/30*5+r/100+1 << " " << t/30*5+r/100+5 << " " << t/30*5+r/100+1+5 << endl;
			}
		}
	}
}


Measured memory_bytes: 3076
import math


N, D = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for i in range(N):
    for j in range(i+1, N):
        tmp = 0
        for x1, x2 in zip(lst[i], lst[j]):
            tmp += (x1 - x2) ** 2
        val = math.sqrt(tmp)
        # if val.is_integer():
        if val == int(val):
            ans += 1
print(ans)


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

#define vi vector<int>

int main() {

    string S;
    cin >> S;

    int ans = 0;
    int N = S.length();
    for (int i = 0; i < N/2; i++) {
        if (S[i] != S[N-1-i]) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		BigInteger N = new BigInteger(String.valueOf(sc.next()));
		BigInteger M = new BigInteger(String.valueOf(sc.next()));
		BigInteger m = M.subtract(N.multiply(new BigInteger("2")));
				
		if (m.compareTo(BigInteger.ZERO) == 0) {
			// equal
			System.out.println(N);
			sc.close();
			return;
		} else if (m.compareTo(BigInteger.ZERO) < 0) {
			// n big
			System.out.println(M.divide(new BigInteger("2")));
			sc.close();
			return;
		} else {
			// m big
			System.out.println(N.add(m.divide(new BigInteger("4"))));
		}
		
		sc.close();
	}
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
    char t[1000], p[1000];
    int n, m;
    scanf("%s", t);
    scanf("%s", p);
    for (n = 0; t[n] != '\0'; n++)
        ;
    for (m = 0; p[m] != '\0'; m++)
        ;

    int i = 0, j = 0;
    while (i <= n - m) {
        while (j < m && t[i + j] == p[j]) {
            //printf("%d %d\n", i, j);
            j++;
        }
        if (j == m)
            printf("%d\n", i);
        i++;
        j = 0;
    }
    return 0;
}

Measured memory_bytes: 1864
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
mlmis = lambda: [-int(x) for x in input().split()]
INF = float('inf')
#

def main():
    d = 'SUN,MON,TUE,WED,THU,FRI,SAT'.split(',')
    i = d.index(input())
    print(7-i)

main()


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		for (int i = 1; i <= n; i++) {
			int in = sc.nextInt();
			if (i % 2 != 0 && in % 2 != 0) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 35720
#include <iostream>
#define MAX 100001
using namespace std;

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

  int count[MAX]={};

  for(int i=1;i<=N;i++){
    int k;  cin>>k;
    if(i==k) count[i]++;
  }

  int swap=0;
  for(int i=1;i<=N;i++){
    if(count[i]>0){
      swap++;
      count[i+1]--;
    }
  }
  
  cout<<swap<<endl;
  

}


Measured memory_bytes: 640
#include<cstdio>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

typedef pair<int,int> P;
typedef pair<int,P> PP;

typedef set<P>::iterator se_it;

set<P> se[300300];

int xs[300300],ys[300300],zs[300300];
PP pps[300300];
int N;

bool check(P p,int id){
	set<P> &se=::se[id];
	int x=p.first,y=p.second;
	if(se.size()==0) return false;
	se_it it=se.lower_bound(P(x,-2));
	if(it==se.begin()) return false;
	it--;
	int py=it->second;
	if(py<y) return true;
	return false;
}

void ins(P p,int id){
	set<P> &se=::se[id];
	int x=p.first,y=p.second;
	se_it it=se.lower_bound(P(x,-2));
	if(it==se.end()){
		se.insert(p);
		return;
	}
	if(it->first==x&&it->second<y){
		return;
	}
	while(true){
		if(it==se.end()||it->second<y) break;
		se.erase(it++);
	}
	se.insert(p);
}

void put(P p){
	int lb=0,ub=N+1;
	while(ub-lb>1){
		int mid=(ub+lb)/2;
		bool flg=check(p,mid);
		if(flg) lb=mid;
		else ub=mid;
	}
	ins(p,lb+1);
}

int A,B;
int a, b, C = ~(1<<31), M = (1<<16)-1;
int r() {
  a = 36969 * (a & M) + (a >> 16);
  b = 18000 * (b & M) + (b >> 16);
  return (C & ((a << 16) + b)) % 1000000;
}

int m,n;

void init(){
	scanf("%d%d%d%d",&m,&n,&A,&B);
	if(m+n==0) exit(0);
	for(int i=0;i<m;i++){
		scanf("%d%d%d",xs+i,ys+i,zs+i);
	}
	a=A,b=B;
	for(int i=0;i<n;i++){
		xs[i+m]=r();
		ys[i+m]=r();
		zs[i+m]=r();
	}
	N=m+n;
	for(int i=0;i<=N;i++){
		se[i].clear();
	}
	for(int i=0;i<N;i++){
		pps[i]=PP(zs[i],P(-xs[i],-ys[i]));
	}
	sort(pps,pps+N);
}

int solve(){
	se[0].insert(P(-1,-1));
	for(int i=0;i<N;i++){
		P p=pps[i].second;
		p.first*=-1;
		p.second*=-1;
		put(p);
	}
	int ans=0;
	for(int i=0;i<=N;i++) if(se[i].size()>0) ans=i;
	return ans;
}

int main(){
	while(true){
		init();
		int ans=solve();
		printf("%d\n",ans);
	}
	return 0;
}

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

const int MOD = 998244353;

int main(){
	
	int n;
	cin >> n;
	vector<int> d(n);
	map<int,int> m;
	rep(i,n){
		cin >> d[i];
		++m[d[i]];
	}
	
	if(d[0]!=0){
		cout << 0 << endl;
		return 0;
	}
	else{
		ll res = 1ll;
		for(int i = 1; i < n; i++){
			res = (res * m[d[i]-1]) % MOD;
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    int N,K,ans=0;
    cin>>N;
    for(int i=0;i<N;i++){
        int a,b;
        cin>>a>>b;
        ans+=b-a+1;
    }
    cout<<ans<<endl;
}


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

//if we check path having min in degree first, visiting would be proper.
//if we dont, we might never visiting that path providing the answer
//we would also prefer having min indegree ones in our path

int const siz=1e5+1;
vector<int> adj[siz];
int depth[siz],N,M,indegree[siz];
bool vis[siz];

void dfs(int v) {
    vis[v]=true;
    for (int i:adj[v]) {
        depth[i]=max(depth[i],depth[v]+1);
        --indegree[i];
        if (indegree[i]==0)
            dfs(i);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>N>>M;
    while (M--) {
        int u,v; cin>>u>>v;
        adj[u].push_back(v);
        indegree[v]++;
    }
    for (int i=1;i<=N;i++) {
        if (!vis[i] && indegree[i]==0)
            dfs(i);
    }
    int lp=0;
    for (int i=1;i<=N;i++)
        lp=max(lp,depth[i]);
    cout<<lp<<"\n";
    return 0;
}

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


int main(){
    int t,p,r;
    while(true){
        cin >> t >> p >> r;
        if(t == 0 && p == 0 && r == 0) break;
        vector<map<int,int>> mp(t);
        map<int,int> mp2;
        rep(i,r){
            int id, pid, ti;
            string  mes;
            cin >> id >> pid >> ti >> mes;
            id--; pid--;
            if(mes == "CORRECT"){
                if( mp[id][pid] < 0) mp[id][pid] =    abs(mp[id][pid]) *1200 + ti;
                else mp[id][pid] = ti;
                mp2[id]++;
            }else{
                mp[id][pid]--;
            }
        }
        vector<tuple<int,int,int> > ans(t);
        rep(i,t){
            get<2>(ans[i]) = -i;
            for(auto x :mp[i]){
                if(x.second >= 0 ) get<1>(ans[i]) += x.second;
            }
            get<0>(ans[i]) = mp2[i];
            get<1>(ans[i]) = -get<1>(ans[i]);

        }
        sort(ALL(ans));
        reverse(ALL(ans));
        rep(i,t){
            cout << -get<2>(ans[i]) + 1 << " " << get<0>(ans[i]) << " " << -get<1>(ans[i]) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3184
import java.util.*;
public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
  	    int k = sc.nextInt();
  	    int ans = 1;
        
      	for (int i=0; i<n-1; i++) {
            ans *= k-1;
        }
        
        System.out.println(ans*k);
    }
}

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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n, k;
		string s;
		cin >> n >> k >> s;
		int x = 0;
		int ret = 0;
		for(int i=1; i < n; i++){
			if(s[i] != s[i-1])x++;
			else ret++;
		}
		while(k > 0 && x > 0){
			ret += min(x, 2);
			k--;
			x -= min(x,2);
		}
		cout << ret << "\n";
		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

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

int main(){
	double w,h,x,y;
	scanf("%lf %lf %lf %lf",&w,&h,&x,&y);
	int cont = 0;
	if(x == w/2){
		++cont;
	}
	if(y == h/2){
		++cont;
	}
	printf("%lf ",w*h/2);

	if(cont > 1)
		puts("1");
	else
		puts("0");

	return 0;
}

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

#pragma region  // {{{

#define all(x) std::begin(x), std::end(x)
#define rall(x) std::rbegin(x), std::rend(x)
#define rep(i, begin, end) for (int64_t i{begin}, i##_end{end}; i < i##_end; ++i)
#define repc(i, begin, last) for (int64_t i{begin}, i##_last{last}; i <= i##_last; ++i)
#define repr(i, begin, last) for (int64_t i{begin}, i##_last{last}; i >= i##_last; --i)
#define let const auto
using i64 = std::int64_t;
using u64 = std::uint64_t;

constexpr int32_t INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

void ioSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(11);
    std::cerr << std::fixed << std::setprecision(11);
    std::clog << std::fixed << std::setprecision(11);
}

template <class T>
std::istream& operator,(std::istream& is, T& rhs) {
    return is >> rhs;
}

#define var(type, ...) \
    type __VA_ARGS__;  \
    std::cin >> __VA_ARGS__

inline void println() {
    std::cout << '\n';
}
template <class Head, class... Tail>
inline void println(Head&& head, Tail&&... tail) {
    std::cout << head << " " + (!sizeof...(tail));
    println(std::forward<Tail>(tail)...);
}

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

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

#pragma endregion  // }}}

constexpr int MOD = int(1e9) + 7;

signed main() {
    ioSetup();

    var(i64, S);
    vector<i64> dp(S + 1);

    dp[0] = 1;
    repc(i, 3, S) {
        dp[i] = dp[i - 1] + dp[i - 3];
        dp[i] %= MOD;
    }

    println(dp[S]);

    return 0;
}


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

int main (){
  int N,L;
  cin >> N >> L ;
  string S[101];
  for(int i=0;i<N;i++){
  cin >> S[i];
  }
  sort(S,S+N);
  for(int i=0;i<N;i++){
    cout << S[i] ;
  }
}

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

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

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

    for(int i = 0; i < n; i++){
        ans += (v[i] > c[i])? v[i]-c[i] : 0;
    }
    cout << ans << endl;
}

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

int main(){
	int h1, h2, m1, m2, k;

	cin >> h1 >> m1 >> h2 >> m2 >> k;

	int awake_time = (h2*60 + m2) - (h1*60 + m1);

	cout << awake_time - k << endl;
}


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

// #define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
const int N = 1e6 + 7, M = 1000000007, inf = INT_MAX;

int freq[N], f2[N];
#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
#define pii pair<int,int>
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define prvec(v) for(auto &i: v) cout << i << " ";
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{	rtn
	const char* comma = strchr (names + 1, ',');
	cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

void solve()
{
	int n;
	cin >> n;

	int arr[n], brr[n], res[n];
	vector<pii> vec(n);
	lop(i, 0, n) cin >> vec[i].ff, vec[i].ss = i, f2[ vec[i].ff ]++;
	lop(i, 0, n) arr[i] = vec[i].ff;

	lop(i, 0, n) cin >> brr[i], freq[ brr[i] ]++;
	auto cmp = [](int a, int b) {

		if ( freq[a] != freq[b] ) return freq[a] > freq[b];
		else return a > b;
	};
	lop(i, 0, n + 1) if ( f2[i] + freq[i] > n )
	{
		cout << "No" << endl;
		return;
	}

	set<int, decltype(cmp)> st(cmp);
	lop(i, 0, N) if ( freq[i] ) st.insert(i);
	// lop(i, 0, n) cout << vec[i].ff << " "; cout << endl;
	int i = 0;
	// bug( st.size() );
	memset(res, -1, sizeof res);
	while ( i < n )
	{
		int x = vec[i].ff, id = vec[i].ss;
		if ( res[id] != -1 )
		{
			i++;
			continue;
		}
		// bug( i, x, st.size() );

		auto it = st.begin();
		int rem = -1;
		if ( *it == x  ) rem = x, st.erase(rem);
		// bug( i, x, rem, st.size() );

		// for (auto &j : st) cout << j << " -> "  << freq[j] << endl;
		if ( rem != -1 ) it = st.begin();
		// bug( st.size() );
		if ( it == st.end() ) {
			res[id] = x;
			// prvec(res);
			int found = -1;
			vector<int> v1;
#define pb push_back
			lop(j, 0, n)
			{
				if ( j == id ) continue;
				if ( res[j] != x and res[j] != -1 and arr[j] != x ) found = j, v1.pb(j);
			}
			if ( found == -1 )
			{
				cout << "Never" << endl;
				return;
			}
			int sz = v1.size();
			int j = i;
			while ( j < n and arr[j] == x )
			{
				if ( sz == 0 )
				{
					cout << "Never" << endl;
					return;
				}
				int p = v1.back();
				res[j] = res[ p ]; v1.pop_back();
				res[p] = x;
				j++;
				sz--;
				freq[x]--;
			}

			// swap(res[id], res[found]);
			// break;
		}
		else
		{
			res[id] = *it;
			int val = *it;
			st.erase(val);
			freq[val]--;
			if (freq[val]) st.insert(val);
			// bug( st.size() );
		}
		// bug(rem, res[i]);
		if ( rem != -1 ) st.insert(rem);
		// bug( st.size() );
		i++;
		// cout << "***** \n\n" << endl;
	}
	cout << "Yes" << endl;
	// return;
	lop(i, 0, n) cout << res[i] << " "; cout << endl;
}

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

	int test = 1;
	// cin >> test;
	while (test--)solve();


}






















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

typedef long long int ll;
typedef string str;

int main ()
{
	// ios::sync_with_stdio(0);
 //    cin.tie(0);
 //    cout.tie(0);
	ll t,n,m,k,i,a,b,j;
	str st;
	cin >> st;
	if(st=="AAA" || st=="BBB")
		cout << "No\n";
	else
		cout  << "Yes\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int t=0, h=0;
	int a, b, c;
	
	while(scanf("%d,%d,%d", &a, &b, &c) != EOF){
		if(a * a + b * b == c * c){
			t++;
		}else if(a == b){
			h++;
		}
	}
	
	printf("%d\n%d\n", t, h);
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
template<typename T>void chmax(T& a,const T& b){if(a<b)a=b;}

main(){
  string s,t;
  cin>>s>>t;
  ll n,m;
  n=s.size();m=t.size();

  vector<vector<ll>>lcs(3010,vector<ll>(3010));
  for(ll i=0;i<n;++i){
    for(ll j=0;j<m;++j){
      if(s[i]==t[j])chmax(lcs[i+1][j+1],lcs[i][j]+1);
      chmax(lcs[i+1][j+1],max(lcs[i+1][j],lcs[i][j+1]));
    }
  }
  // lcs[n][m]=lcs
  string ans="";
  while(n>0&&m>0){
    if(lcs[n][m]==lcs[n-1][m])n--;
    else if(lcs[n][m]==lcs[n][m-1])m--;
    else{
      n--;m--;
      ans+=s[n];
    }
  }
  reverse(ans.begin(),ans.end());
  cout<<ans<<endl;

}


Measured memory_bytes: 71168
//AUTHOR - NIMISH UPADHYAY
//FROM IIIT ALLAHABAD
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define UPADHYAY int t;cin>>t;while(t--) 
#define pb push_back
#define NIMISH ios_base::sync_with_stdio(false);cin.tie(NULL);
int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll>v[n+1];
    ll c[n+1]={0},i,j,k=1,p=1;
    while(m--){
        cin>>i>>j;
        v[i].pb(j);
        v[j].pb(i);
    }
    map<ll,ll>m1;
    for(i=1;i<=n;i++){
        if(c[i]==0&&v[i].size()!=0){
            queue<ll>q;
            q.push(i);
            c[i]=k;
            while(!q.empty()){
                j=q.front();
                q.pop();
                for(auto it:v[j]){
                    if(c[it]==0){
                        q.push(it);
                        c[it]=k;
                    }
                }
            }
            k++;
        }
    }
    for(i=1;i<=n;i++){
        if(c[i]!=0){
            m1[c[i]]++;
            p=max(p,m1[c[i]]);
        }
    }
    cout<<p;
}

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

int main() {
	int n;
	while(cin >> n, n) {
		int a[10] = {};
		for(int i = 0; i < n; i++) {
			int b; cin >> b;
			a[b]++;
		}
		for(int i = 0; i < 10; i++) {
			if(a[i]) {
				for(int j = 0; j < a[i]; j++)
					cout << "*";
				cout << endl;
			}
			else
				cout << "-" << endl;
		}
	}
}

Measured memory_bytes: 1152
import sys
n=int(input())
string_list=[input() for i in range(n)]
for i in range(n):
	for k in range(n):
		if i!=k:
			if string_list[i]==string_list[k]:
				print('No')
				sys.exit()

for i in range(n-1):
	if string_list[i][-1]!=string_list[i+1][0]:
		print('No')
		sys.exit()

print('Yes')

Measured memory_bytes: 3064
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        System.out.println(solve(a, b));
    }

    private static String solve(String a, String b) {
        return new StringBuilder(a).reverse().toString().equals(b) ? "YES" : "NO";
    }
}


Measured memory_bytes: 22480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int X;
    cin >> X;
    int hyaku = X/100;
    cout << (105*hyaku >= X?1:0) << "\n";
}

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

int main(){
  int N,T;
  long long int k=0,finish=0,sum=0;
  cin >> N >> T;
  int t[N];
  for(int i=0;i<N;i++){
    cin >> t[i];
    if(finish>t[i]){
      sum+=t[i]-k;
    }else{
      sum+=T;
    }
    finish=t[i]+T;
    k=t[i];
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(){
	int N;
	int n1=0;
	int n2=0;
	int n3=0;
	
	int i;
	for(i=0;i<10;i++){
	scanf("%d",&N);
	if(N>=n1){
	n3=n2;
	n2=n1;
	n1=N;
	}else if(N>=n2){
	n3=n2;
	n2=N;
	}else if(N>=n3){
	n3=N;
	}
	}
	printf("%d\n%d\n%d\n",n1,n2,n3);

}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#pragma warning (disable : 4996)
using namespace std;
const int INF = -1234567890;
typedef pair<int, int> pii;
int main()
{
	int a[100006];
	int n, m; scanf("%d %d", &n, &m);
	fill(a, a + n + 3, INF);
	vector<pii> graph[100006];
	for (int i = 0; i < m; i++)
	{
		int x, y, z;
		scanf("%d %d %d", &x, &y, &z);
		graph[x].push_back({ y,z });
		graph[y].push_back({ x,-z });
	}
	for (int i = 1; i <= n; i++)
	{
		if (a[i] != INF) continue;
		a[i] = 0;
		queue<pii> v;
		v.push({ i,0 });
		while (!v.empty())
		{
			int tpx = v.front().first;
			int tpy = v.front().second;
			v.pop();
			for (int i = 0; i < graph[tpx].size(); i++)
			{
				auto loc = graph[tpx][i];
				if (a[loc.first] != INF)
				{
					if (a[loc.first] - tpy != loc.second) return !printf("No");
				}
				else
				{
					a[loc.first] = loc.second + tpy;
					v.push({ loc.first,a[loc.first] });
				}
			}
		}
	}
	return !printf("Yes");
}

Measured memory_bytes: 9600
from collections import defaultdict
new = defaultdict(int)
for i in range(int(input())):
    s = input()
    new[s] += 1
print("AC x "+str(new['AC']))
print("WA x "+str(new['WA']))
print("TLE x "+str(new['TLE']))
print("RE x "+str(new['RE']))

Measured memory_bytes: 70036
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int solve(){
  int a,b;cin>>a>>b;
  cout << (b%a==0 ? a+b : b-a) << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 768
#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int sum = 0;
	for (int i = 1; i <= 9; ++i)
		for (int j = 1; j <= 9; ++j) {
			int mid1 = 0;
			int mid2 = 0;
			for (int k = 1; k <= n; ++k) {
				int h = k, t = k % 10;
				while (h >= 10)
					h /= 10;
				if (h == i && t == j)
					mid1++;
				if (h == j && t == i)
					mid2++;
			}
			sum += mid1 * mid2;
		}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
ll a[100005];
int main() {
    int n, k , q; cin >> n >> k >> q;
    for(int i = 0; i < 100005; ++i){
        a[i] = k - q;
    }
    for(int i = 0; i < q; ++i){
        int x; cin >> x;
        a[x]++;
    }
    for(int i = 1; i <= n; ++i){
        if(a[i] <= 0) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
	return 0;
}


Measured memory_bytes: 1408
process.stdin.resume();
process.stdin.setEncoding('utf8');
 
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がline1, 2行目がline2, …に入る
  var tmp = input.split("\n");
  var line0 = tmp[0].split(" ");
  //var line1 = tmp[1].split(" ");
  //var line2 = tmp[2].split(" ");
  //var line3 = tmp[3].split(" ");

  var input1 = (line0[0]);
  var input2 = (line0[1]);
//  var b = Number(line0[2]);

  var ans = "ans";

  //console.log( input1+" "+ input2 +" "+ " hoge ")

  if (input1 == "H" && input2 == "H") ans = "H";
  else if (input1 == "H" && input2 == "D") ans = "D";
  else if (input1 == "D" && input2 == "H") ans = "D";
  else if (input1 == "D" && input2 == "D") ans = "H";
  else and="error";




/*  
  for(var i=1; i <=n; i++){
    if(ans < k) ans *= 2;
    else ans += k;
  }
*/


  console.log(ans);
  
  


}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
    int N,K;
    cin >> N >> K;
    vector<int>P(N);
    rep(i, 0, N){
        cin>>P[i];
    }
    sort(P.begin(), P.end());
    ll ans = 0;
    rep(i, 0, K){
        ans+=P[i];
    }
    cout << ans << endl;
    return 0;
}


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

long long MOD=1000000007;

long long fac[2000002],finv[2000002],inv[2000002];

void COMinit(){
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<2000002;i++){
		fac[i]=fac[i-1]*i%MOD;
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}

long long COM(int n,int k){
	long long ret=1;
	for(int i=0;i<k;i++){
		ret*=n-i;
		ret%=MOD;
	}
	for(int i=0;i<k;i++){
		ret*=inv[i+1];
		ret%=MOD;
	}
	return ret;
}

long long MODpow(long long a,int b){
	if(b==0)return 1;
	if(b%2==0){
		long long t=MODpow(a,b/2);
		return (t*t)%MOD;
	}
	return (a*MODpow(a,b-1))%MOD;
}

int main(){
	COMinit();
	int n,a,b;
	cin >> n >> a >> b;
	
	long long ans=MODpow(2,n)-1;
	ans-=COM(n,a)+COM(n,b)-MOD*3;
	cout << ans%MOD << endl;
	return 0;
}

Measured memory_bytes: 47104
use proconio::fastout;
use proconio::input;

#[fastout]
fn main() {
    input! {
        n: usize,
        mut li: [u32; n],
    }
    li.sort_unstable();
    let mut ans = 0;
    for (i, &l) in li.iter().enumerate() {
        for (j, &m) in li[..i].iter().enumerate() {
            for &n in &li[..j] {
                // println!("{} {} {}", l, m, n);
                if l != m && m != n && n + m > l {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2184
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools


sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    H, W = LI()
    A = []
    [A.append(S()) for i in range(H)]

    # まず横向きで削除していく
    rm_idx = []
    for idx, a in enumerate(A):
        if '#' not in a:
            rm_idx.append(idx)

    count = 0
    for idx, i in enumerate(rm_idx):
        del A[i-count]
        count += 1

    # 縦向きに探索
    rm_idx = []
    for w in range(W):
        if all(a[w] == '.' for a in A):
            rm_idx.append(w)

    count = 0
    for idx, i in enumerate(rm_idx):
        A = [a[:i-count] + a[i-count+1:] for a in A]
        count += 1

    for a in A:
        print(''.join(a))


if __name__ == "__main__":
    main()


Measured memory_bytes: 65644
def main():
    a, b, c, k = map(int, input().split())

    sum = 0

    n = k-a
    if n <= 0:
        sum = k
        print(sum)
        exit()
    else:
        sum = a

    n = n-b
    if n <= 0:
        print(sum)
        exit()
    
    n = n-c
    if n <= 0:
        sum = sum - (k-(a+b))
        print(sum)
        exit()

main()


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}

int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n,k,ans=0;
  cin>>n>>k;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  rep(i,n){
    if(v[i]>=k) ans++;
  }
  cout<<ans<<endl;
}
///////////////////////////

Measured memory_bytes: 640
from collections import deque

h, w = map(int, input().split())
mp = ["#" * (w + 1)] + ["#" + input() + "#" for _ in range(h)] + ["#" * (w + 1)]
white = 0
for y in range(h + 2):
    white += mp[y].count(".")
vec = ((1, 0), (0, -1), (-1, 0), (0, 1))
que = deque()
que.append((1, 1, 1))
visited = [[False] * (w + 2) for _ in range(h + 2)]
visited[1][1] = True
while que:
    score, x, y = que.popleft()
    if (x, y) == (w, h):
        print(white - score)
        break

    for dx, dy in vec:
        nx, ny = x + dx, y + dy
        if mp[ny][nx] != "#" and not visited[ny][nx]:
            que.append((score + 1, nx, ny))
            visited[ny][nx] = True
else:
    print(-1)

Measured memory_bytes: 3316
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
df = list([0 for i in range(n)])
ans = -1

if sum(a) < sum(b):
    ans = -1
else:
    for i in range(n):
        df[i] = a[i] - b[i]
    minus = list(filter(lambda x: x < 0, df))
    plus = list(filter(lambda x: x > 0, df))
    m_count = len(minus)
    m_sum = sum(minus)
    #print("m_count=%d"%(m_count))
    #print("m_sum=%d"%(m_sum))
    plus.sort(reverse=True)
    #print(df)
    #print(plus)

    if m_count == 0:
        ans = 0
    else:
        for i in range(len(plus)):
            m_sum += plus[i]
            if m_sum >= 0:
                break

        if m_sum>=0:
            ans = m_count + i + 1
print(ans)

Measured memory_bytes: 19188
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2 3");
            WillReturn.Add("1 2 3");
            WillReturn.Add("0 1 1");
            //3
            //2 2 2 3
            //1 1 1 2
            //1 3 1 2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("3 2");
            WillReturn.Add("1 0");
            WillReturn.Add("2 1");
            WillReturn.Add("1 0");
            //3
            //1 1 1 2
            //1 2 2 2
            //3 1 3 2
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("1 5");
            WillReturn.Add("9 9 9 9 9");
            //2
            //1 1 1 2
            //1 3 1 4
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = { };
        Action<string> SplitAct = pStr =>
            wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();

        SplitAct(InputList[0]);
        int H = wkArr[0];
        int W = wkArr[1];

        int UB_X = W - 1;
        int UB_Y = H - 1;
        int[,] BanArr = new int[UB_X + 1, UB_Y + 1];

        for (int Y = 0; Y <= UB_Y; Y++) {
            SplitAct(InputList[Y + 1]);
            for (int X = 0; X <= UB_X; X++) {
                BanArr[X, Y] = wkArr[X];
            }
        }

        var SousaList = new List<string>();
        for (int Y = 0; Y <= UB_Y; Y++) {
            for (int X = 0; X <= UB_X; X++) {
                if (BanArr[X, Y] % 2 == 1) {
                    //右に移動可能な場合
                    if (X < UB_X) {
                        BanArr[X, Y]--;
                        BanArr[X + 1, Y]++;
                        SousaList.Add(string.Format("{0} {1} {2} {3}", Y + 1, X + 1, Y + 1, X + 1 + 1));
                    }

                    //下に移動可能な場合
                    else if (Y < UB_Y) {
                        BanArr[X, Y]--;
                        BanArr[X, Y + 1]++;
                        SousaList.Add(string.Format("{0} {1} {2} {3}", Y + 1, X + 1, Y + 1 + 1, X + 1));
                    }
                }
            }
        }
        Console.WriteLine(SousaList.Count);
        SousaList.ForEach(p => Console.WriteLine(p));
    }
}


Measured memory_bytes: 29860
import util.control.Breaks._

object Main extends App {
  val Array(n, m) = io.StdIn.readLine().split(' ').map(_.toInt)
  val coins = io.StdIn.readLine().split(' ').map(_.toInt)
  val counts = Array.fill(n+1)(Int.MaxValue)
  val queue = collection.mutable.Queue.empty[Int]
  coins.withFilter(_<=n).foreach {n =>
    counts(n) = 1
    queue.enqueue(n)
  }
  breakable(
    while (queue.nonEmpty) {
      val current = queue.dequeue()
      if (current == n) break()
      coins.foreach{c =>
        val next = c+current
        if (next <= n && counts(current)+1 < counts(next)) {
          counts(next) = counts(current) + 1
          queue.enqueue(next)
        }
      }
    }
  )
  println(counts(n))
}


Measured memory_bytes: 64580
a, b, c, k = map(int, input().split())

if a >= k:
  a = k
  b = 0
  c = 0
if a < k and a+b >= k:
  c = 0
if a+b < k:
  c = k - a - b
  
sum_a = 1 * a
sum_c = -1 * c
  
print(sum_a + sum_c)

Measured memory_bytes: 9128
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		Queue<time> E=new ArrayDeque<>(),T=new ArrayDeque<>();

		int N=in.nextInt();
		for(int i=0;i<N;i++) {
			time t=new time();
			t.h=Integer.parseInt(in.next());
			t.m=Integer.parseInt(in.next());
			E.add(t);
		}

		int M=in.nextInt();
		for(int i=0;i<M;i++) {
			time t=new time();
			t.h=Integer.parseInt(in.next());
			t.m=Integer.parseInt(in.next());
			T.add(t);
		}

		Queue<time> MG=new ArrayDeque<>();
		while(!E.isEmpty() && !T.isEmpty()) {
			time e=E.peek(),t=T.peek();
			//System.out.println(e.h+":"+e.m+" "+t.h+":"+t.m);

			if((e.h*100)+e.m < (t.h*100)+t.m) {
				MG.add(e);
				E.remove();
			}
			else if((e.h*100)+e.m > (t.h*100)+t.m) {
				MG.add(t);
				T.remove();
			}
			else {
				MG.add(e);
				E.remove(); T.remove();
			}
		}

		while(!E.isEmpty()) {
			MG.add(E.remove());
		}

		while(!T.isEmpty()) {
			MG.add(T.remove());
		}

		int size=MG.size();
		for(int i=0;i<size-1;i++) {
			time t=MG.remove();
			System.out.printf("%d:%02d ",t.h,t.m);
		}
		System.out.printf("%d:%02d\n",MG.peek().h,MG.peek().m);
	}

}

class time{
	int h=0,m=0;
}



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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


li n;
multiset<li> st;
multiset<li> sto;

int main() {
    cin >> n;
    rep(i, bit(n)) {
        li a;
        cin >> a;
        st.insert(a);
    }
    sto = st;
    vector<li> now;
    now.pb(*st.rbegin());
    st.erase(prev(st.end()));
    rin{
        sort(allof(now));
        reverse(allof(now));
        vector<li> next;
        for (auto v : now) {
            next.pb(v);
            auto it = st.upper_bound(v - 1);
            if (it == st.begin()) {
                puts("No");
                return 0;
            }
            it--;
            next.pb(*it);
            st.erase(it);
        }
        now = next;
    }
    puts("Yes");

    return 0;
}

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

public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		String data;
		int[][] nums = new int[10][10];
		while ((data = reader.readLine()) != null) {
			StringTokenizer tokenizer = new StringTokenizer(data, ",");
			int x = Integer.parseInt(tokenizer.nextToken());
			int y = Integer.parseInt(tokenizer.nextToken());
			int size = Integer.parseInt(tokenizer.nextToken());
			if (size == 1) {
				for (int i = 0; i < 3; i++) {
					for (int j = 0; j < 3; j++) {
						if (0 <= i + x - 1 && i + x - 1 <= 9 && 0 <= j + y - 1
								&& j + y - 1 <= 9) {
							if ((i == 1 && j == 1) || (i + j) % 2 == 1) {
								nums[i - 1 + x][j - 1 + y]++;
							}
						}
					}
				}
			} else if (size == 2) {
				for (int i = 0; i < 3; i++) {
					for (int j = 0; j < 3; j++) {
						if (0 <= i + x - 1 && i + x - 1 <= 9 && 0 <= j + y - 1
								&& j + y - 1 <= 9) {
							nums[i - 1 + x][j - 1 + y]++;
						}
					}
				}
			} else {
				for (int i = 0; i < 5; i++) {
					for (int j = 0; j < 5; j++) {
						if (0 <= i + x - 2 && i + x - 2 <= 9 && 0 <= j + y - 2
								&& j + y - 2 <= 9) {
							if (i == 2 || j == 2 || (i == 1 && j == 1)
									|| i * j == 3 || (i * j == 9)) {
								nums[i - 2 + x][j - 2 + y]++;
							}
						}
					}
				}
			}
		}
		int count = 0;
		int max = 0;
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				max = Math.max(max, nums[i][j]);
				if (nums[i][j] == 0) {
					count++;
				}
			}
		}
		System.out.println(count);
		System.out.println(max);
	}
}

Measured memory_bytes: 16868
def resolve():
    '''
    code here
    '''

    R, G, B, N = [int(item) for item in input().split()]

    cnt = 0

    for i in range(N+1):
        for j in range(N+1-i):
            _b = N - (i * R + j * G)
            
            if _b % B == 0 and _b >= 0:
                cnt += 1

    print(cnt)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const int MAX = 1e4;
const ll mod = 1e9+7;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i-1] * (ll)i % mod;
    inv[i] = mod - inv[mod%i] * (mod/(ll)i) % mod;
    finv[i] = finv[i-1] * inv[i] % mod;
  }
}

ll COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main(){
  COMinit();
  int n, a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  vector<vector<ll>> dp(b+1,vector<ll>(n+1,0));
  dp[a-1][0] = 1;
  for(int i = a; i <= b; i++) {
    for(int j = 0; j <= n; j++) {
      (dp[i][j] += dp[i-1][j]) %= mod;
      if(j + i*c <= n) {
        ll r = COM(n-j,i*c);
        for(int l = 1; l <= c; l++) {
          (r *= COM(i*l,i)) %= mod;
          (r *= inv[l]) %= mod;
        }
        for(int k = c; k <= min(d,(n-j)/i); k++) {
          (dp[i][j+k*i] += dp[i-1][j] * r % mod) %= mod;
          (r *= COM(n-j-i*k,i)) %= mod;
          (r *= inv[k+1]) %= mod;
        }
      }
    }
  }
  cout << dp[b][n] << endl;
  return 0;
}

Measured memory_bytes: 8320
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int X;
int G[51];//ハンバーガーの数
int E[51];//パティの数

int f(int n,int x){
	if(n==0){
		return 1;
	}
	if(x==1){
		return 0;
	}
	else if(1<x&&x<=1+G[n-1]){
		return f(n-1,x-1);
	}
	else if(1+G[n-1]+1==x){
		return E[n-1]+1;
	}
	else if(1+G[n-1]+1<x&&x<G[n]-1){
		return E[n-1]+1+f(n-1,x-1-G[n-1]-1);
	}
	else{
		return E[n-1]+1+E[n-1];
	}
}

signed main(){
	cin>>N>>X;
	G[0]=1;
	E[0]=1;
	for(int i=1;i<=50;i++){
		G[i]=1+G[i-1]+1+G[i-1]+1;
		E[i]=E[i-1]+E[i-1]+1;
	}
	DEB(G[1])END
	cout<<f(N,X)<<endl;
	return 0;
}


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

string s;

int main() {
	cin >> s;
	
	int cnt = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] != s[s.length() - 1 - i]) {
			cnt++;
		}
	}
	
	cout << cnt / 2 << endl;
	return 0;
}

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

int main(){
    int n; cin >> n;
    int Hlist[n];
    int tempmax = 0;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> Hlist[i];
    }
    for(auto i : Hlist){
        if(i >= tempmax){
            tempmax = i;
            ans += 1;
        }
    }
    cout << ans;
    return 0; 
}

Measured memory_bytes: 256