akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const ll mod = 1e9 + 7;

struct BIT{
    int n;
    VL bit;

    BIT(){}
    BIT(int x){
        n = x;
        bit.resize(x+1);
    }

    void init(int x){
        n = x;
        bit.resize(x+1);
    }

    void add(int i, ll x){
        i++;
        while (i <= n){
            (bit[i] += x) %= mod;
            i += i & -i;
        }
    }

    // [0, i]
    ll sum(int i){
        i++;
        ll ret = 0;
        while (i > 0){
            (ret += bit[i]) %= mod;
            i -= i & -i;
        }
        return ret;
    }

    // [l, r)
    ll sum(int l, int r){
        if (l >= r) return 0;
        return (sum(r-1) - sum(l-1) + mod) % mod;
    }
};

const ll INF = 1e18;

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    VL s(n+1);
    s[0] = -INF;
    REP(i,n) scanf("%lld", &s[i+1]);

    VL la(n+1), lb(n+1);
    int j = n;
    FORR(i,n,1){
        while (s[j] > s[i] - a) j--;
        la[i] = j;
    }
    j = n;
    FORR(i,n,1){
        while (s[j] > s[i] - b) j--;
        lb[i] = j;
    }

    BIT bita(n+1), bitb(n+1);

    bita.add(0,1);
    bitb.add(0,1);

    int zeroa = 0, zerob = 0;
    FOR(i,1,n-1){
        bita.add(i, bitb.sum(zerob, min(la[i+1]+1, (ll)i)));
        bitb.add(i, bita.sum(zeroa, min(lb[i+1]+1, (ll)i)));
        if (s[i] > s[i+1] - a) zeroa = i;
        if (s[i] > s[i+1] - b) zerob = i;

        // cout << i << endl;
        // REP(j,i+1) cout << (j >= zeroa ? bita.sum(j, j+1) : 0) << " ";
        // cout << endl;
        // REP(j,i+1) cout << (j >= zerob ? bitb.sum(j, j+1) : 0) << " ";
        // cout << endl;
    }

    ll ans = bita.sum(zeroa, n+1) + bitb.sum(zerob, n+1);
    cout << (ans % mod) << endl;
    
    return 0;
}




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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first



typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    string s;
    cin >>s;
    int l=s.length();

    for (int i = l-2; i > 0; i -= 2){
        bool f=true;
        
        for(int j = 0; j < (i/2); j++){
            if(s[j] != s[j + (i/2)])f=false;
        }

        if(f){
            ans = i;
            break;
        }
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

int main(){
  
  int A,B,C,D;
  
  cin >> A >> B >> C >> D;
  
  for(int i = 0; i < 200; i++){
    C = C - B;
    if(C <= 0) break;
    
    A = A - D;
    if(A <= 0) break;
  }
  
  if(A > C) cout << "Yes" << endl;
  else cout << "No" << endl;
}
    

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

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

mint dp[1001][1001];
int main() {
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  rep(i, h) cin >> a[i];

  dp[0][0] = 1;
  rep(i, h) {
    rep(j, w) {
      if (a[i][j] == '#') continue;
      if (i > 0 && a[i - 1][j] == '.') dp[i][j] += dp[i - 1][j];
      if (j > 0 && a[i][j - 1] == '.') dp[i][j] += dp[i][j - 1];
    }
  }
  cout << dp[h - 1][w - 1] << endl;
  return 0;
}

Measured memory_bytes: 9088
program sample
	implicit none
    character(len=3) :: a
    
    read(*,*) a
    
    if (a=='SUN') then
    	write(*,*) 7
    else if (a=='MON') then    
        write(*,*) 6
    else if (a=='TUE') then    
        write(*,*) 5  
    else if (a=='WED') then    
        write(*,*) 4      
    else if (a=='THU') then    
        write(*,*) 3
    else if (a=='FRI') then    
        write(*,*) 2
    else
    	write(*,*) 1
    end if    
    stop
end program sample





Measured memory_bytes: 2852
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>











int n, m;
bool b;



void solve()
{
	cin >> n >> m;
	b = true;
	for(int i = 1, j = n; i <=m ; i++, j--)
	{
		if(b && n % 2 == 0 && (j - i) * 2 <= n)
		{
			j--;
			b = false;
		}
		cout << i << " " << j << "\n";
	}
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


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


    ll ans = LLINF;
    for (ll i = 1; i <= sqrt(n); i++){
        if (n%i==0){
            if (ans > n%i + i)ans = n/i + i;
        }
    }

    ans-=2;
    cout << ans;
}


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

using namespace std;

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

	int n, a, b;
	cin >> n >> a >> b;
	vector<int> x(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	long long res = 0;
	for (int i = 1; i < n; i++) {
		res += min(1ll * (x[i] - x[i - 1]) * a, 1ll * b);
	}
	cout << res << '\n';

	return 0;
}



Measured memory_bytes: 640
from collections import deque
N,M,K = (int(x) for x in input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]
friends = [set() for _ in range(N)]
blocks = [set() for _ in range(N)]
searched = [0] * N
ans = [0] * N
d = deque()
for x, y in AB:
    friends[x-1].add(y-1)
    friends[y-1].add(x-1)
for x, y in CD:
    blocks[x-1].add(y-1)
    blocks[y-1].add(x-1)
for i in range(N):
    if searched[i]:
        continue
    trace = set()
    d.append(i)
    trace.add(i)
    searched[i] = 1
    while d:
        temp = d.popleft()
        for x in friends[temp]:
            if searched[x] == 0:
                d.append(x)
                trace.add(x)
                searched[x] = 1
    chain = len(trace)
    for j in trace:
        ans[j] = chain - 1 - len(trace&friends[j]) - len(trace&blocks[j])
print(*ans)

Measured memory_bytes: 129400
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	std::string s; cin >> s;

	if(s[0] == '7' or s[1] == '7' or s[2] == '7') printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 3556
n,ma,mb = map(int,input().split())
a = []
b = []
c = []
for i in range(n):
    aa,bb,cc = map(int,input().split())
    a.append(aa)
    b.append(bb)
    c.append(cc)

inf = 10**18
dp = [[[inf]*(411) for j in range(411)] for i in range(n+1)]
for i in range(n+1):
    dp[i][0][0] = 0
for i in range(n):
    for j in range(400):
        for k in range(400):
            if dp[i][j][k] == inf:continue
            dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k])
            dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i])

ans = 10**18
for j in range(1,401):
    for k in range(1,401):
        if ma*k == mb*j:
            ans = min(ans,dp[n][j][k]) 
if ans == 10**18:
    print(-1)
else:
    print(ans)





Measured memory_bytes: 129844
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

void read();
template<typename First, typename... Rest> void read(First& first, Rest&... rest);
void write();
template<typename First, typename... Rest> void write(First first, Rest... rest);
template<typename T> void write_vec(vector<T>& v, char divider);

int main(){
    int N, D;
    read(N, D);
    write(N / (2 * D + 1) + (N % (2 * D + 1) != 0));
    return 0;
}

//配列以外の入力を受け取る
void read(){

}
template<typename First, typename... Rest>
void read(First& first, Rest&... rest){
    cin >> first;
    read(rest...);
}
//
//配列以外を出力する
void write(){

}
template<typename First, typename... Rest>
void write(First first, Rest... rest){
    cout << first << " ";
    write(rest...);
}
//
//配列を区切って出力する
template<typename T>
void write_vec(vector<T>& v, char divider){
    for(size_t i = 0; i < v.size(); i++){
        cout << v[i] << divider;
    }
}
//

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#define debug(x) cout<<"***"<<x<<"***"<<endl;
using namespace std;
int main()
{
	int n,a[100005],light[100005],tmp=1,cnt=0;
	memset(light,0,sizeof(light));
	cin>>n;light[1]=1;
	for (int i=1;i<=n;i++)
		cin>>a[i];
	while (light[2]==0 && cnt<=n)//3 3 1 2
	{
		light[tmp]=0;
		tmp=a[tmp];
		light[tmp]=1;
		cnt++;
	}
	if (light[2]==1) cout<<cnt;
	else cout<<-1;

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (1LL<<57)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];
map<string, int> MS;

void solve(int T)
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		MS[s]++;
	}
	int mx = 0;
	for(auto u : MS)
	mx = max(mx, u.ss);
	vector<string> res;
	for(auto u : MS)
	{
		if(u.ss == mx)
		res.pb(u.ff);	
	}
	for(auto u : res)
	cout<<u<<"\n";
	return;	
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

// #ifndef ONLINE_JUDGE
// 	time_t time_t1, time_t2;
// 	time_t1 = clock();
// #endif

	while(T--)
	solve(T);

// #ifndef ONLINE_JUDGE
// 	time_t2 = clock();
// 	SETF();
// 	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
// 	UNSETF();
// #endif

	return 0;
}

Measured memory_bytes: 25584
#include<stdio.h>
int main()
{
    char c;
    scanf("%c", &c);
    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
        printf("vowel\n");
    else
        printf("consonant\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
    unsigned long int N = 0, A = 0, B = 0, dist = 0;
    double sum = 0;
    cin >> N >> A >> B;

    dist = B - A;
    if(dist % 2 == 0){
        cout << dist / 2 << endl;
    }else if((B - 1) < (N - A)){
        cout << A + (dist - 1) / 2 << endl;
    }else{
        cout << (N - B + 1) + (dist - 1) / 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG

#include"bits/stdc++.h"
using namespace std;

//loops
#define REP(i,n) for(int i=0;i<(ll)(n);i++)
#define REPD(i,n) for(int i=(ll)(n)-1;i>=0;i--)
#define OneToN(i,n) for(int i=1;i<(ll)(n+1);i++)
#define ZeroToN(i,n) for(int i=0;i<(ll)(n+1);i++)
#define AToB(i,a,b) for(int i=a;i<(ll)(b+1);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

//bitsearch
#define BITSEARCH(bit, n) for (int bit = 0; bit < (1<<n); ++bit)
#define isOne(bit, i) bit & (1<<i)


//arrays
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define add push_back


#define remove_unique(v) v.erase(unique(ALL(v)), v.end())

//comparision
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 (a>b) { a=b; return 1; } return 0; }

//pair
#define fir first
#define sec second
#define mp make_pair

//types
#define ll long long
#define vec vector
#define cord2d pair<int,int>
//UNCOMMENT WHEN NEEDED
//#define int ll

//input
template <class T> T get(){ T s; cin >> s; return(s);}
#define gi get<int>()
#define gs get<string>()

template <class T> vector<T> getv(int n) { vec<T> v(n); REP(i, n) cin >> v[i]; return v; }
#define gim(n) getv<int>(n)
#define gsm(n) getv<string>(n)

//output
void print(int a){ cout << a << endl; }
void print(long long a){ cout << a << endl; }
void print(string a){ cout << a << endl; }
void print(char a){ cout << a << endl; }
void print(double a){ cout << a << endl; }
void print(double a, int dig){ cout << std::setprecision(dig) << a << endl; }

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T = int>
void print(vec<T> v){ cout << v << endl; }

template <class T = int>
void print2dVec(vec<vec<T>> v2d){for(vec<T> v: v2d) {print(v);}}

void YesNo1(bool i = true){ return print(i?"Yes":"No"); }
void YESNO2(bool i = true){ return print(i?"YES":"NO"); }

//debug output
#define var_name(var) #var
template <class T> void debug(T &var, int nest = 0, string before = "") { cout << string("          ", nest) << before; print(var); }

//name replacement
#define y0 y0__
#define y1 y1__
#define j0 j0__
#define j1 j1__

//bool lambdas
#define lamb(exp) [](auto i){return exp;}
#define isEven [](int i){return i % 2 == 0;}
#define isOdd [](int i){return i % 2 != 0;}

//constants
const ll INF = 1e18;
const int MOD = 10000007;

//maths
int factorial(int k){ int sum = 1; for (int i = 1; i <= k; ++i) { sum *= i; } return sum; }
int gcd(int a, int b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

////////////////////

void Main() {
    //code here
    int r = gi;
    print(3*pow(r,2));
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Main();
}


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

using namespace std;

//typedef pair<int,int> P;

long long c[51][51];

void combo(){
	memset(c,0,sizeof(c));
	for(int i=0;i<=50;i++){
		c[i][0] = 1;
		c[i][i] = 1;
	}
	for(int i=1;i<=50;i++){
		for(int j=1;j<i;j++){
			c[i][j] = c[i-1][j-1] + c[i-1][j];
		}
	}
}


int main(){
	int N,A,B;
	long long v[50];

	scanf("%d %d %d", &N, &A, &B);
	for(int i=0;i<N;i++){
		scanf("%lld", &v[i]);
	}
	sort(v,v+N);
	reverse(v,v+N);

	combo();

	long long ans = 0;
	double avg = 0.0;

	if(v[0]==v[A-1]){
		avg = v[0];
		int num = 0;
		while(v[0]==v[num]) num++;
		int B2 = min(num,B);
		//printf("%d\n", B2);
		for(int i=A;i<=B2;i++){
			ans += c[num][i];
		}
	}else{
		int num1 = 0;
		int num2 = 0;
		for(int i=0;i<N;i++){
			if(v[i]==v[A-1]) num1++;
		}
		for(int i=A-1;i>=0;i--){
			if(v[i]==v[A-1]) num2++;
		}
		ans = c[num1][num2];
		long long sum = 0;
		for(int i=0;i<A;i++) sum+=v[i];
		avg = (double)sum/A;
	}

	printf("%.6lf\n", avg);
	printf("%lld\n", ans);

	return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef double db;

#define mp make_pair
#define pb push_back
#define pt(i) printf("%lld\n",(ll)i)
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1.0)

ll in() { ll a;scanf("%lld",&a); return a;}
db din(){ db a;scanf("%lf",&a); return a; }
ll bigmod(ll b, ll p,ll md){if(p==0) return 1;if(p%2==1){ return ((b%md)*bigmod(b,p-1,md))%md;} else {ll y=bigmod(b,p/2,md);return (y*y)%md;}}
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b);}

long long getRandom(long long a,long long b){
    long long ret = (long long)rand()*(long long)rand();
    ret %= (b - a + 1);
    ret += a;
    return ret;
}

int dp[3005][3005],path[3005][3005],len1,len2;

char s1[3005],s2[3005];

int solve(int pos1,int pos2)
{
	if(pos1==len1||pos2==len2)
		return 0;
	if(dp[pos1][pos2]!=-1)
		return dp[pos1][pos2];
	if(s1[pos1]==s2[pos2])
	{
		path[pos1][pos2]=1;
		return dp[pos1][pos2]=1+solve(pos1+1,pos2+1);
	}
	int x=solve(pos1+1,pos2);
	int y=solve(pos1,pos2+1);
	return dp[pos1][pos2]=max(x,y);
}

int main()
{
	//freopen("in.c","r",stdin);
	//freopen("out.c","w",stdout);
	scanf("%s %s",s1,s2);
	len1=strlen(s1),len2=strlen(s2);
	memset(dp,-1,sizeof dp);
	solve(0,0);
	int pos1=0,pos2=0;
	while(pos1<len1&&pos2<len2)
	{
		if(s1[pos1]==s2[pos2])
			printf("%c",s1[pos1] ),pos1++,pos2++;
		else
		{
			if(dp[pos1+1][pos2]>dp[pos1][pos2+1])
				pos1++;
			else
				pos2++;
		}
	}
	puts("");
}


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

int main() {
  int n,m;
  cin>>n>>m;
  ll vec[n];
  ll sum=0;
  for(int i=0;i<n;i++){
    cin>>vec[i];
    sum+=vec[i];
  }
  int count=0;
  for(int i=0;i<n;i++){
    if(vec[i]*4*m>=sum){
      count++;
    }
  }
  if(count>=m){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
A,B = map(int,input().split(" "))
S = list(str(input()))
#print(S)
if len(S) == A + B + 1 and S[A] == '-':
    count = 0
    for i in range(A+B+1):
        if S[i] == '-':
            count += 1
    if count == 1:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int x = scan.nextInt();
    int y = scan.nextInt();

    int a1 = scan.nextInt();
    int b1 = scan.nextInt();
    int c1 = scan.nextInt();

    ArrayList<Integer> a = new ArrayList<Integer>();
    ArrayList<Integer> b = new ArrayList<Integer>();
    ArrayList<Integer> c = new ArrayList<Integer>();

    for (int i=0;i<a1;i++){
      a.add(scan.nextInt());
    }

    for (int i=0;i<b1;i++){
      b.add(scan.nextInt());
    }

    for (int i=0;i<c1;i++){
      c.add(scan.nextInt());
    }

    Collections.sort(a,Collections.reverseOrder());
    Collections.sort(b,Collections.reverseOrder());
    Collections.sort(c,Collections.reverseOrder());

    long[] a2 = new long[a1+1];
    long[] b2 = new long[b1+1];
    long[] c2 = new long[c1+1];

    for (int j=0;j<a1;j++){
      a2[j+1] = a2[j] + a.get(j);
    }

    for (int j=0;j<b1;j++){
      b2[j+1] = b2[j] + b.get(j);
    }

    for (int j=0;j<c1;j++){
      c2[j+1] = c2[j] + c.get(j);
    }

    long sum = 0;

    int change = 0;
    while ( (x-1-change>=0) && (change<c1) && (c.get(change) >= a.get(x-1-change))){
      change += 1;
    }

    sum += c2[change] + a2[x-change];

    ArrayList<Integer> dd = new ArrayList<Integer>();
    for (int i=change;i<c1;i++){
      dd.add(c.get(i));
    }

    for (int i=0;i<change;i++){
      dd.add(a.get(x-change+i));
    }

    for (int i=0;i<b1;i++){
      dd.add(b.get(i));
    }

    Collections.sort(dd,Collections.reverseOrder());
    long[] ggg = new long[y+1];
    for (int i=0;i<y;i++){
      ggg[i+1] = ggg[i] + dd.get(i);
    }

    sum += ggg[y];
    System.out.println(sum);

  }

}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

const int N=3005;
li dp[N][N];

void solve()
{
    li n;

    cin>>n;

    vi a(n);

    f(i,0,n-1)
    {
        cin>>a[i];
    }

    fr(l,n-1,0)
    {
        f(r,l,n-1)
        {
            if(l==r)
            {
                dp[l][r]=a[l];
            }
            else
            {
                dp[l][r]=max(a[l]-dp[l+1][r],a[r]-dp[l][r-1]);
            }
        }
    }

    cout<<dp[0][n-1];
}

int main()
{    
    

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

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 49824
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
#define popcount __builtin_popcount
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}

ll N;
ll K;
std::vector<long long> A;

bool check(ll mid){
    ll cnt=0;
    for (long long i = 0; i < N; i++) {
        if(A[i]<=mid) continue;
        cnt+=A[i]/mid;
    }
    return cnt<=K;
}

int main(){
    // long long N;
    scanf("%lld",&N);
    // long long K;
    scanf("%lld",&K);
    // std::vector<long long> A(N);
    A.resize(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }

    long long ng=0, ok=INF;
    while (abs(ok - ng) > 1) {
      long long mid = (ok + ng) / 2;
      if (check(mid)) {
        ok = mid;
      } else {
        ng = mid;
      }
    }
    cout << ok << endl;

    return 0;
}


Measured memory_bytes: 4820
#gcdは3.4.3だとfractionsにある
from fractions import gcd
import math

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    n,m = mi()
    num = [-1 for i in range(n+1)]
    sclist = []
    for i in range(m):
        s,c = mi()
        sclist.append([s,c])
    for i in range(m):
        s,c = sclist[i]
        if num[s] == -1 or num[s] == c:
            num[s] = c
        else:
            print(-1)
            exit()

    if n == 1 and m == 0:
        print(0)
        exit()
    if n!= 1 and num[1] == 0:
        print(-1)
        exit()

    if num[1] == -1:
        num[1] = 1

    for i in range(1,n+1):
        if num[i] == -1:
            num[i] = 0

    ans = list(map(str,num))

    print(''.join(ans[1:]))


main()





Measured memory_bytes: 5584
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
using namespace std;

#define rep(i,n) for((i)=0; (i)<(int)(n); ++(i))
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
const int inf = 1<<28;

int limit, n, m, x;
int e0[102], s0[102], e1[102], s1[102];
int dp[102][1002];

void solve() {
  int i, j, k, l, ii, jj;
  string in;
  rep (i,n) cin >> in >> e0[i] >> s0[i];
  rep (i,m) cin >> in >> e1[i] >> s1[i];

  //memset(dp, -1, sizeof dp);
  rep (i,102) fill(dp[i], dp[i] + 1002, -inf);
  // dp[A][B] := Aツ人ツづ個人ツづーBツ円ツづ古卍づつスツ湘ェツ債づ個催妥・ツづ個鳴楪堕ォツ度
  // ツづヲツづづp[0][0] = 0ツづづ按づゥ
  dp[0][0] = 0;
  for (i = 0; i < m; ++i) {
    for (j = i; j >= 0; --j) {
      for (k = e1[i]; k <= limit; ++k) {
        dp[j+1][k] = max(dp[j+1][k], dp[j][k - e1[i]] + s1[i]);
      }
    }
  }
  
  // ツシツーツクツδ個ッツトツアツーツテツィツスツトツづ個δ環スツトツづーツ催ャツづづつィツつュ
  /*
  int secret[21];
  memset(secret, 0, sizeof secret);
  rep (i,n) {
    secret[e0[i]] = max(secret[e0[i]], s0[i]);
    rep (j,n) if (i != j) {
      secret[e0[i] + e0[j]] = max(secret[e0[i] + e0[j]], s0[i] + s0[j]);
    }
  }*/
  
  int ans = -inf;
  for (i = x; i <= m; ++i) {
    for (j = 0; j <= limit; ++j) if (dp[i][j] >= 0) {
      /*
      for (k = 0; k < 21 && k + j <= limit; ++k) {
        ans = max(ans, dp[i][j] + secret[k]);
      }*/
      
      for (k = 0; k < n; ++k) {
        if (j + e0[k] <= limit) ans = max(ans, dp[i][j] + s0[k]);
        for (l = 0; l < k; ++l) {
          if (j + e0[k] + e0[l] <= limit) {
            ans = max(ans, dp[i][j] + s0[k] + s0[l]);
          }
        }
      }
      
    }
  }
  cout << ans << endl;
}

int main() {
  while (cin >> limit >> n >> m >> x, limit) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
using namespace std;

long long work(int & num1,int num2){
    int tmp=num1+num2;int out=1;
    while (tmp/10){
        num1=tmp/10;
        num2=tmp%10;
        tmp=num1+num2;
        out++;
    }
    num1=tmp;
    return out;
}

int tot[4000100];
int d[200000];
long long c[200000];

int main()
{
    int m;scanf("%d",&m);
    long long ans=0;
    for (int i=0;i<m;++i){
        scanf("%d%lld",&d[i],&c[i]);
    }
    int len=0;
    for (int i=m-1;i>=0;--i){
        int num=d[i];
        long long tmp=c[i];
        if (num==0){
            tot[len++]=0;
            ans+=tmp-1;
            continue;
        }
        while (tmp){
            if (tmp%2){
                tot[len++]=num;
                tmp-=1;
            }
            if (tmp==0) break;
            tmp/=2;int num1=num;
            ans += tmp*work(num,num1);
        }
    }
    //for (int i=0;i<len;++i) printf("%d ",tot[i]);
    len--;
    while (len){
        ans+=work(tot[len-1],tot[len]);--len;
    }
    printf("%lld\n",ans);
}



Measured memory_bytes: 14464
def solve():
    N, M, X = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(N)]
    ans = 10**9
    for b in range(1<<N):
        cost = 0
        for i in range(N):
            if b>>i&1:
                cost += A[i][0]
        for j in range(M):
            cnt = 0
            for i in range(N):
                if b>>i&1:
                    cnt += A[i][j+1]
            if cnt<X:
                break
        else:
            ans = min(ans,cost)
    if ans==10**9:
        return -1
    return ans
print(solve())

Measured memory_bytes: 68244
#include<stdio.h>

 int cnt;
 
 void insertionSort(int A[],int n,int g);
 void shellSort(int A[],int n);

 int n;
 int A[1000000];

 int main(){
            int i;
            scanf("%d",&n);
            for(i=0;i<n;i++)scanf("%d",A+i);
            shellSort(A,n);
            printf("%d\n",cnt);
            for(i=0;i<n;i++)printf("%d\n",A[i]);
            return 0;
            }

 void insertionSort(int A[],int n,int g){
            int tmp;
            int i,j;
            for(i=g;i<n;i++){
                             tmp=A[i];
                             j=i-g;
                             while(j>=0&&A[j]>tmp){
                                                   A[j+g]=A[j];
                                                   j-=g;
                                                   ++cnt;
                                                   } 
                             A[j+g]=tmp;
                             }
             }

 void shellSort(int A[],int n){
                               int m=0;
                               int G[100];
                               int i;
                               G[0]=1;
                               for(m=1;3*G[m-1]+1<=n;m++)G[m]=3*G[m-1]+1;
                               printf("%d\n",m);
                               cnt=0;
                               for(i=m-1;i>=0;i--){
                                                   printf("%d%c",G[i]," \n"[i==0]);
                                                   insertionSort(A,n,G[i]);
                                                   }
                               }


Measured memory_bytes: 5680
#include <cstdlib>
#include <iostream>
#include <map>
using namespace std;

struct compare {
	bool operator() (const string& a, const string& b) const {
		return a.size() != b.size() ? a.size() < b.size() : a < b;
	}
};

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

	int n;
	cin >> n;

	map<string, int, compare> production;
	for(int i = 0; i < n; ++i) {
		string name;
		int number;
		cin >> name >> number;
		production[name] += number;
	}

	for(const auto& e : production) {
		cout << e.first << " " << e.second << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1224
a=input()
ok=True
for i in range(len(a)):
    if (i+1)%2==0 and a[i]=="R":
        ok=False
        break
    if (i+1)%2==1 and a[i]=="L":
        ok=False
        break

if ok:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<stdio.h>
typedef struct{
  int p,l,r,d,h,s;
}Node;
Node A[30];
int rec(int r,int p){
  A[r].d = p;
  if(A[r].r!=-1) rec(A[r].r,p+1);
  if(A[r].l!=-1) rec(A[r].l,p+1);
}
int rec2(int a){
  int l,r;
  if(a==-1) return 0;
  if(A[a].l==-1 && A[a].r==-1) return 0;
  l = rec2(A[a].l)+1;
  r = rec2(A[a].r)+1;
  return l > r ? l : r;
}
int main(){
  
  int n,id,l,r;
  int i;
  int degree;
  int a;
  scanf("%d",&n);
  for(i=0;i<n;i++) A[i].r = A[i].l = A[i].p = A[i].s = -1;
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d%d",&l,&r);
    A[id].l = l;
    A[id].r = r;
    A[l].p = A[r].p = id;
    A[l].s = r;
    A[r].s = l;
  }
  for(i=0;i<n;i++) if(A[i].p==-1) a = i;
  rec(a,0);
  for(i=0;i<n;i++) A[i].h = rec2(i);
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, sibling = %d, ",i,A[i].p,A[i].s);
    degree = 0;
    if(A[i].l!=-1) degree++;
    if(A[i].r!=-1) degree++;
    printf("degree = %d, depth = %d, height = %d, ",degree,A[i].d,A[i].h);
    if(A[i].p==-1) printf("root");
    else if(A[i].r!=-1 || A[i].l!=-1) printf("internal node");
    else printf("leaf");
    printf("\n");
  }
    
  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a<=c && c<=b) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> a(N);
    REP(i, N)
    {
        cin >> a[i];
    }

    ll excAllA = a[0];
    REP(i, N)
    {
        excAllA ^= a[i + 1];
    }
    REP(i, N)
    {
        cout << (excAllA ^ a[i]) << " ";
    }
}


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

using namespace std;

#define NMAX 100
#define NO 0
#define YES 1

int main(){

	int N,M,Mi,K,li;
	int data[NMAX+1][NMAX+1];
	vector<int> ans,out;
	bool f;

	while(1){

		cin>>N;
		if(N==0) break;

		if(!ans.empty()) ans.clear();
		if(!out.empty()) out.clear();

		for(int i=0;i<=N;i++){
			for(int j=1;j<=N;j++){
				data[i][j]=NO;
			}
		}

		for(int i=1;i<=N;i++){
			cin>>M;
			for(int j=0;j<M;j++){
				cin>>Mi;
				data[i][Mi]=YES;
			}
		}

		cin>>K;

		for(int i=0;i<K;i++){
			cin>>li;
			out.push_back(li);
		}

		for(int i=1;i<=N;i++){
			f=true;
			for(int j=0;j<K;j++){
				if(data[i][out[j]]==NO) f=false;
			}
			if(f) ans.push_back(i);
		}

		if(ans.empty()||ans.size()>=2) cout<<"-1"<<endl;
		else cout<<ans[0]<<endl;

	}

}

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

using vec = std::vector<int>;
using Land = std::vector<std::vector<int>>;

int W, H, N;
Land s;
std::vector<Land> res;

bool check(int h, int w, int a, int b, int num)
{
    if (h + a > H || w + b > W) {
        return false;
    }
    for (int i = h; i < h + a; i++) {
        for (int j = w; j < w + b; j++) {
            if (s[i][j] != 0 && s[i][j] != num) {
                return false;
            }
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (h <= i && i < h + a && w <= j && j < w + b) {
                continue;
            }
            if (s[i][j] == num) {
                return false;
            }
        }
    }
    
    return true;
}

void paint(int h, int w, int a, int b, int num)
{
    for (int i = h; i < h + a; i++) {
        for (int j = w; j < w + b; j++) {
            s[i][j] = num;
        }
    }
}

void dfs(int idx, const vec &b, const vec &k)
{
    if (idx == N) {
        res.emplace_back(s);        
        return;
    }    
    
    for (int i = 1; i <= k[idx]; i++) {
        int j = k[idx] / i;
        if (i * j != k[idx]) continue;
        for (int h = 0; h < H; h++) {
            for (int w = 0; w < W; w++) {                
                if (check(h, w, i, j, b[idx])) {
                    auto tmp = s;
                    paint(h, w, i, j, b[idx]);
                    dfs(idx + 1, b, k);
                    s = tmp;
                }
            }
        }
    }
}

void print(Land &l)
{
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (j > 0) std::cout << " ";            
            std::cout << l[i][j];
        }
        std::cout << std::endl;
    }
}

void init()
{
    s.assign(H, std::vector<int>(W));
    res.clear();
}

int main()
{
    while (std::cin >> W >> H >> N, W) {
        init();
        vec b(N), k(N);
        for (int i = 0; i < N; i++) {
            std::cin >> b[i] >> k[i];
        }

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                std::cin >> s[i][j];
            }
        }

        dfs(0, b, k);

        if (res.size() != 1) {
            std::cout << "NA" << std::endl;
        } else {
            print(res[0]);
        }
    }
    return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);
const ll mod = 1000000007;

template<int MOD> class Fp {
    ll val;
public:
    constexpr Fp(ll v = 0) noexcept : val(v % MOD) {
        if(val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator- () const noexcept { return val ? MOD - val : 0; }
    constexpr Fp operator+ (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator- (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator* (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator/ (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator+= (const Fp& r) noexcept {
        val += r.val;
        if(val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator-= (const Fp& r) noexcept {
        val -= r.val;
        if(val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator*= (const Fp& r) noexcept {
        (val *= r.val) %= MOD;
        return *this;
    }
    constexpr Fp& operator/= (const Fp& r) noexcept {
        ll a = r.val, b = MOD, u = 1, v = 0;
        while(b){
            ll t = a/b;
            a -= t*b; swap(a, b);
            u -= t*v; swap(u, v);
        }
        (val *= u) %= MOD;
        if(val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator== (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator!= (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    constexpr bool operator> (const Fp& r) const noexcept {
        return this->val > r.val;
    }
    constexpr bool operator< (const Fp& r) const noexcept {
        return this->val < r.val;
    }
    friend constexpr ostream& operator<< (ostream &os, const Fp<MOD>& x){
        ll tmp = x.val;
        os << tmp;
        return os;
    }
    friend constexpr ostream& operator>> (istream &is, const Fp<MOD>& x){
        ll tmp;
        is >> tmp;
        x = Fp<MOD>(tmp);
        return is;
    }
    constexpr Fp<MOD> modpow(ll n) noexcept {
        if(n == 0) return 1;
        auto t = modpow(n>>1);
        t *= t;
        if(n & 1) t *= *this;
        return t;
    }
};
using mint = Fp<mod>;

int main(){
    ll n; string s;
    cin >> n >> s;
    map<char, ll> l;
    rep(i, s.length()) l[s[i]]++;
    mint ans(1);
    for(auto i : l){
        if(i.second > 1) ans *= i.second + 1;
        else ans *= 2;
    }
    ans -= 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
 
int main(){
  int n,sum,m;
  cin >> n;
  m = n;
  for (int i = 8; i > 0; i--){
    int a = 1;
    for (int j = 0; j < i - 1; j++){
      a *= 10;
    }
    sum += n / a;
    n -= n / a * a;
  }
  if (m % sum == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
s={"a":"b","b":"c","c":"d","d":"e","e":"f","f":"g","g":"h","h":"i","i":"j","j":"k","k":"l","l":"m","m":"n","n":"o","o":"p","p":"q","q":"r","r":"s","s":"t","t":"u","u":"v","v":"w","w":"x","x":"y","y":"z","z":"a"}
print(s[input()])


Measured memory_bytes: 8956
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[1000];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i; j<n; j++){
            ans = max(ans, abs(a[i]-a[j]));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

const MAX_SIDE_LENGTH: i32 = 150;

#[allow(unused_assignments)] // for `score_ans`
fn main() {
    loop {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).ok();
        let mut iter = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());
        let (h, w) = (iter.next().unwrap() as i32, iter.next().unwrap() as i32);
        if h == 0 && w == 0 {
            return;
        }

        let score_org = h * h + w * w;
        let mut score_ans = std::i32::MAX;
        let mut h_ans = std::i32::MAX;
        let mut w_ans = 0;
        'search:
        for hh in 1..MAX_SIDE_LENGTH {
            for ww in (hh + 1)..MAX_SIDE_LENGTH {
                let score = hh * hh + ww * ww;
                if score > score_ans {
                    break;
                }

                if score > score_org {
                    if (score < score_ans) || ((score == score_ans) && (hh < h_ans)) {
                        score_ans = score;
                        h_ans = hh;
                        w_ans = ww;
                    }
                } else if score == score_org {
                    if hh > h {
                        score_ans = score;
                        h_ans = hh;
                        w_ans = ww;
                        break 'search;
                    }
                }
            }
        }
        println!("{} {}", h_ans, w_ans);
    }
}



Measured memory_bytes: 5020
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int a, b;
    cin >> a >> b;
    if(a < 6) b = 0;
    else if(a < 13) b /= 2;
    cout << b << endl;
    return 0;
}

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

ll mod = 1e9+7;

/*
#define NMAX 10001
ll fac[NMAX];
ll inv[NMAX];

ll mod_pow(ll a, ll n, ll mod){
    ll ret = 1;
    while(n > 0){
        if(n & 1) ret = (ret*(a % mod))%mod;
        a = ((a%mod)*(a%mod)) % mod;
        n = n >> 1;
    }
    return ret;
}

ll mod_inv(ll a, ll mod){
    return mod_pow(a, mod-2, mod);
}

void mae_nck(){
    fac[1] = 1;
    inv[1] = 1;
    for(ll i = 2; i < NMAX; i++){
        fac[i] = (fac[i-1] * i)%mod;
        inv[i] = (inv[i-1] * mod_inv(i, mod))%mod;
    }
}
*/

const int MAX = 510000;
const int MOD = 1000000007;

long long 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] * 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){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll mod_nck(ll n, ll k){
  if(k == 0 || k == n) return 1;
  ll ret = ((fac[n] * inv[k])%mod * inv[n-k])%mod;
  return ret;
}

ll nck(ll n, ll k){
  if(k == 0 || k == n) return 1;
  ll nume = 1, deno = 1;
  for(int i=0; i<k; i++){
    nume *= (n-i);
    deno *= (i+1);
  }
  return (ll)(nume/deno);
}

int main(){
    ll n, k;
    cin >> n >> k;
    COMinit();
    rep(i, 1, k+1){
        if(i > n-k+1){
            cout << 0 << endl;
        }else{
            ll ans = COM(n-k+1, i) * COM(k-1, i-1);
            cout << ans%mod << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 12160
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
typedef long long ll;
typedef std::pair<int,int> pii;
#define lson rt<<1
#define rson rt<<1|1
#define clr(a,x) memset(a,x,sizeof(a))
#define FOR(i,a,b) for(int i=(a);i<=(int)(b);++i)
#define REP(i,a,b) for(int i=(a);i>=(int)(b);--i)
#define EFOR(i,u) for(int i=lnk[u];i;i=nxt[i])
#define DEBUG(x) std::cerr<<#x<<" = "<<x<<'\n'
const int inf=1<<30;
const long long INF=1LL<<61;
void judge() {
#ifdef SIYUAN
	freopen("in.txt","r",stdin);
#endif
}
inline char nc() {
	static char buf[1000000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
template <class Tp> inline void read(register Tp &s) {
	s=0;bool neg=0;char c=nc();for(;c<'0'||c>'9';neg|=(c=='-'),c=nc());
	for(;c>='0'&&c<='9';s=10*s+(c^48),c=nc());neg&&(s=-s);
}
int pow(int x,int p,int mod) {
	int res=1;
	for(;p;p>>=1,x=1LL*x*x%mod) if(p&1) res=1LL*res*x%mod;
	return res;
}
int gcd(int x,int y) {return y?gcd(y,x%y):x;}

using namespace std;
int cnt[1000005],ans[1000005];
struct node {
	int p,y,id;
}a[1000005];

bool cmp(node a,node b) {return a.y<b.y;}
bool cmp2(node a,node b) {return a.id<b.id;}
int main() {
//	judge();
	int n,m;
	scanf("%d%d",&n,&m);
	FOR(i,1,m) {
		scanf("%d%d",&a[i].p,&a[i].y),a[i].id=i;
	}
	sort(a+1,a+m+1,cmp);
	FOR(i,1,m) {
		ans[a[i].id]=++cnt[a[i].p];
	}
	sort(a+1,a+m+1,cmp2);
	FOR(i,1,m) printf("%06d%06d\n",a[i].p,ans[i]);
	return 0;
}

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

using namespace std;


typedef long long ll;


int main(){
    int N,M;
    cin>>N>>M;
    vector<int> iland[N];
    int a,b;
    for(int i=0;i<M;++i){
        cin>>a>>b;
        --a;--b;
        iland[a].push_back(b);
    }
    
    bool flag=false;
    
    for(int i=0;i<iland[0].size();++i){
        int il=iland[0][i];
        for(int j=0;j<iland[il].size();++j){
            if(iland[il][j]==N-1){
                flag=true;
                break;
            }
        }
        
    }
    
    if(flag){
        cout<<"POSSIBLE"<<endl;
    }else{
        cout<<"IMPOSSIBLE"<<endl;
    }
}


Measured memory_bytes: 11880