akhauriyash/Code-Regression huggingface dataset:
s = []
N = int(input())
for i in range(N):
    s.append(input())

count_A = 0
count_B = 0
count_AB = 0
count = 0

for i in range(N):
    flag = False
    for j in range(len(s[i])):
        if j == 0 and s[i][j] == "B":
            count_B += 1
            flag = True
        if s[i][j] == "A":
            if j == len(s[i]) - 1:
                count_A += 1
                if flag:
                    count_A -= 1
                    count_B -= 1
                    count_AB += 1
            elif s[i][j+1] == "B":
                count += 1

if count_A == 0 and count_B == 0:
    if count_AB > 0:
        count += count_AB - 1

else:
    if count_A <= count_B:
        count += count_A
    else:
        count += count_B

    count += count_AB

print(count)

Measured memory_bytes: 3700
N = int(input())
H = list(map(int,input().split()))
dp = [float('inf') for i in range(N)]
dp[0]=0
for i in range(N):
    for j in range(1,3):
        if i+j<N:
            dp[i+j] = min(dp[i]+abs(H[i]-H[i+j]),dp[i+j])
print(dp[N-1])

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

using namespace std;

#define llong long long int
#define ldouble long double
#define ternary(condition, x, y) ((condition) ? x : y) 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static llong MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

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

    llong n, a, b;
    cin >> n >> a >> b;
    vector<llong> X(n);
    rep(i, n) {
        cin >> X[i];
    }

    llong ans = 0;
    rep(i, n - 1) {
        if (a * (X[i + 1] - X[i]) > b) ans += b;
        else ans += a * (X[i + 1] - X[i]);
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 1024
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BGreatOceanView solver = new BGreatOceanView();
        solver.solve(1, in, out);
        out.close();
    }

    static class BGreatOceanView {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();

            int max = Integer.MIN_VALUE;
            int answer = 0;
            for (int i = 0; i < n; i++) {
                int h = in.nextInt();

                if (h >= max) {
                    answer++;
                    max = h;
                }
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



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

int main() {
	long n,i,j,k,b,ans,cur,res,wmax;
	cin >> n >> wmax;
	vector<long> v(n),w(n),dpb(wmax+1,0),dpa(wmax+1,0);
	for(i=0; i<n; i++){
		cin >> v[i] >> w[i];
	}
	
	for(i=0; i<n; i++){
		for(j=w[i]; j<=wmax; j++){
			dpa[j]=max(dpb[j],dpb[j-w[i]]+v[i]);
		}
		dpb=dpa;
	}
	cout << dpb[wmax] << endl;
	return 0;
}


Measured memory_bytes: 3288
def mul(inp):
    return int(inp * 2)


if __name__ == '__main__':
    n = int(input())
    a = list(map(mul, map(int, input().split())))
    res = [0] * n
    for x in range(0, 1):
        res[x] = a[x]
        count = 1
        for i in range(x + 1, n + x, 2):
            mod_i = i % n
            res[x] = res[x] - a[mod_i]
        for i in range(x + 2, n + x, 2):
            mod_i = i % n
            res[x] = res[x] + a[mod_i]
        res[x] = int(res[x] / 2)
    for x in range(1, n):
        res[x] = a[x - 1] - res[x - 1]
    print(' '.join(map(str, res)))


Measured memory_bytes: 19144
#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
  int w,h,x,y,r;
  cin >> w >> h >> x >> y >> r;

  if (x-r>=0 && x+r<=w && y-r>=0 && y+r<=h)
    cout << "Yes" << endl;
  else if (x-r<=0 && x+r>=w && y-r<=0 && y+r>=h)
    cout << "No" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> ipair;
typedef tuple<int, int, int> ituple;

// const int INF = INT_MAX;
// const ll INF = LLONG_MAX;
// const int MOD = ((int)1e9 + 7);
// const ld EPS = (1e-10);
#define PI acosl(-1)
#define MAX_N (200000 + 2)

class StarrySkyTree{
protected:

  const static int SIZE = 1 << 18;
  const static int DATA_SIZE = SIZE * 2 + 2;
  ll seg[DATA_SIZE], segAdd[DATA_SIZE];
  int size;

  // 木の子から親を定義する関数
  virtual ll _func(ll a, ll b) = 0;

  // 木のインデックス範囲外の時に返すデフォルト値
  virtual ll _getDefaultValue() = 0;

  void _add(int a, int b, ll x, int k, int l, int r){
    if (r <= a || b <= l) return;
    if (a <= l && r <= b){
      segAdd[k] += x;
      while (k){
        k = (k - 1) / 2;
        seg[k] = _func(seg[k * 2 + 1] + segAdd[k * 2 + 1], seg[k * 2 + 2] + segAdd[k * 2 + 2]);
      }
      return;
    }
    _add(a, b, x, k * 2 + 1, l, (l + r) / 2);
    _add(a, b, x, k * 2 + 2, (l + r) / 2, r);
  }

  ll _get(int a, int b, int k, int l, int r){
    if (r <= a || b <= l) return _getDefaultValue();
    if (a <= l && r <= b) return (seg[k] + segAdd[k]);
    ll left = _get(a, b, k * 2 + 1, l, (l + r) / 2);
    ll right = _get(a, b, k * 2 + 2, (l + r) / 2, r);
    return _func(left, right) + segAdd[k];
  }

public:
  StarrySkyTree(int n){
    assert(n <= SIZE);
    size = n;
    for (int i = 0; i < DATA_SIZE; i++){
      seg[i] = 0;
      segAdd[i] = 0;
    }
  }

  /**
  * 区間[a, b]に値xを加算する.
  * sizeは木の要素数
  */
  void add(int a, int b, ll x){
    _add(a, b+1, x, 0, 0, size+1);
  }

  /**
  * 区間[a, b]の最小値を取得.
  * sizeは木の要素数
  */
  ll get(int a, int b){
    return _get(a, b+1, 0, 0, size+1);
  }

};

class StarrySkyTreeMax : public StarrySkyTree {
  using StarrySkyTree::StarrySkyTree;
protected:
  // 木の子から親を定義する関数
  ll _func(ll a, ll b){
    return max(a, b);
  }

  // 木のインデックス範囲外の時に返すデフォルト値
  ll _getDefaultValue(){
    return LLONG_MIN;
  }
};
StarrySkyTreeMax sst = StarrySkyTreeMax(MAX_N);


void exec(){
  int n, h[MAX_N], a[MAX_N];
  cin >> n;
  for (int i = 0; i < n; i++){
    scanf("%d", &h[i]);
  }
  for (int i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }

  for (int i = 0; i < n; i++){
    ll tmp = sst.get(0, h[i] - 1);
    sst.add(h[i], h[i], tmp + a[i]);
  }

  ll ans = 0;
  for (int i = 0; i <= n; i++){
    ll tmp = sst.get(i, i);
    // printf("sst[%d] = %lld\n", i, tmp);
    ans = max(ans, tmp);
  }

  cout << ans << endl;

}

void solve(){
  int t = 1;
  // scanf("%d", &t);
  for (int i = 0; i < t; i++){
    exec();
  }
}

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


Measured memory_bytes: 9984
fn main() {
    let mut v: Vec<i32> = read();
    v.sort();
    println!("{} {} {}", v[0], v[1], v[2]);
}

fn read<T: std::str::FromStr>() -> Vec<T> {
    let mut buf = String::new();
    let stdin = std::io::stdin();
    stdin.read_line(&mut buf).unwrap();
    buf.split_whitespace().flat_map(str::parse).collect()
}



Measured memory_bytes: 5036
// Problem : E - Bomber
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_e
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 	
int mod=1e9+7;
int po(int x,int y,int m)  { if (y==0) return 1; int t=po(x,y/2,m)%m; t=(t*t)%m; if (y&1) return (t*x)%m;	return t%m; }

signed main() {

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   	
   	int n,m,k;
   	cin>>n>>m>>k;
   	vector<array<int,2>> v(k);
   	unordered_map<int,int> mm;
   	int a1[n+1]={0},a2[m+1]={0};
   	for (int i=0;i<k;++i){
   		cin>>v[i][0]>>v[i][1];
   		mm[(v[i][0]*100000000)+v[i][1]]++;
   		a1[v[i][0]]++;
   		a2[v[i][1]]++;
   	}
   	int ma1=INT_MIN;
   	int ma2=INT_MIN;
   	for (int i=1;i<=n;++i)
   		ma1=max(ma1,a1[i]);
   	for (int i=1;i<=m;++i)
   		ma2=max(ma2,a2[i]);
   	//cout<<ma1<<"  "<<ma2;
	vector<int> m1,m2;
   for (int i=1;i<=n;++i)
   	{
   		if (a1[i]==ma1){
   			m1.push_back(i);
   		}
   	}
   	for (int i=1;i<=m;++i)
   	{
   		if (a2[i]==ma2){
   			m2.push_back(i);
   		}
   	}
   	int ans=ma1+ma2-1;
   	for (int i=0;i<m1.size();++i){
   		for (int j=0;j<m2.size();++j){
   			//cout<<m1[i]<<" "<<m2[j]<<endl;
   			if (mm.find((m1[i]*100000000)+m2[j])==mm.end()){
   				ans++;
   				cout<<ans<<endl;
   				return 0;
   			}
   		}
   	}
   	cout<<ans<<endl;
   	return 0;
}

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

using namespace std;

//#define int long long

vector<int> drogi[1010];
pair<int, int> tab[1010];

//bool plecak[5010];

bool dfs( int where=1 ) {
    int a=0, suma=0;
    int x;
    vector<bool> plecak( tab[where].first+3 );
    plecak[0] = 1;
    for( int i : drogi[where] ) {
        if( !dfs( i ) ) return false;
        a += min( tab[i].first, tab[i].second );
        suma += tab[i].first+tab[i].second;
        x = abs( tab[i].first-tab[i].second );
        for( int i=tab[where].first; i>=x; i-- ) {
            if( plecak[i-x] ) plecak[i] = true;
        }
    }
    if( a > tab[where].first )
        return false;
    int jak;
    for( jak=tab[where].first-a; jak>=0; jak-- ) {
        if( plecak[jak] ) break;
    }
    a+=jak;
    suma+=tab[where].first-a;
    tab[where].second = suma-tab[where].first;

    return true;
}

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

    int n;
    cin >> n;
    for( int a, i=2; i<=n; i++ ) {
        cin >> a;
        drogi[a].push_back( i );
    }
    for( int i=1; i<=n; i++ ) {
        cin >> tab[i].first;
    }
    if( dfs() ) {
        cout << "POSSIBLE";
    } else {
        cout << "IMPOSSIBLE";
    }

    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
    int a, b;
    cin >> a >> b;
    if (1 != a && 1 != b)
    {
        cout << 1 << endl;
    }

    if (2 != a && 2 != b)
    {
        cout << 2 << endl;
    }

    if (3 != a && 3 != b)
    {
        cout << 3 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
A, B = map(int, input().split())

def mygcd(a, b):
    if a < b:
        return mygcd(b, a)
    elif b == 0:
        return a
    else:
        return mygcd(b, a % b)

ans = (A * B) // mygcd(A, B)

print(ans)

Measured memory_bytes: 2940
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define test ll t; cin>>t; while(t--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> orderedMultiset;
int solve()
{
	string s;
	cin>>s;
	int mx=0;
	int cnt=0;
	for(int i=0;i<3;i++){
		if(s[i]=='R')
			cnt++;
		else{
			mx=max(mx,cnt);
			cnt=0;
		}
	}
	mx=max(mx,cnt);
	cout<<mx<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}




Measured memory_bytes: 3612
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll =long long;
using namespace std;
using graph=vector<vector<int>>;
using field=vector<string>;
using p =pair<int,int>;
const ll mod=1000000007;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

int main(){
    ll n,k;
    cin>>n>>k;
    if(k%2!=0){
        ll tmp1=pow(n/k,3);//tmp*tmp*tmp;
        cout<<tmp1<<endl;
    }else{
        ll tmp1=pow(n/k,3);//tmp*tmp*tmp;
        ll tmp3=pow((n+k/2)/k,3);//tmp2*tmp2*tmp2;
        cout<<tmp1+tmp3<<endl;
    }
}

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

int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int r = 0;
	for(int i=0;i<n;i++)
		if(s[i]=='R') r++; //目标状态左侧R的数目
	int ans = 0;
	for(int i=0;i<r;i++) 
		if(s[i]=='W') ans++; //原串中左侧有多少W需要与右侧R交换 
	cout<<ans<<"\n";
	return 0;
}

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


int main() {
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i];

    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    int ans = 0;
    if(n % 2 == 1){
        int ind = (n-1)/2;
        ans = b[ind] - a[ind] + 1;
    }else{
        int ind = n/2;
        ans = (b[ind]+b[ind-1]) - (a[ind]+a[ind-1]) + 1;
    }

    cout << ans << endl;
}

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

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

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

template<class T>
inline void out(T a) {
	cout<<a<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


ll A,B,C;

void input() {
	cin>>A;
}

void solve() {
	cout<<abs(A-1)<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <string.h>

int main(void) {
	char str[1001], p[1001], state[10];
	int a, b, q;
	
	scanf("%s\n%d", str, &q);
	for (int i = 1; i <= q; i++) {
		scanf("%s", state);
		if (strcmp(state, "replace") == 0) {
			scanf("%d %d %s", &a, &b, p);
			for (int j = 0; j < b - a + 1; j++) {
				str[a + j] = p[j];
			}
		} else {
			scanf("%d %d", &a, &b);
			if (strcmp(state, "reverse") == 0) {
				for (int j = a; j <= b; j++) {
					p[j] = str[j];
				}
				for (int j = a; j <= b; j++) {
					str[j] = p[b + a - j];
				}

			} else {
				for (int j = a; j <= b; j++) {
					printf("%c", str[j]);
				}
				printf("\n");
			}
		}
	}

	return 0;
}

Measured memory_bytes: 2692
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
  int n;
  int cnt = 0;

  while(scanf("%d",&n) != EOF){

    cnt = 0;
    
    for(int a = 0;a < 10;a++){
      for(int b = 0;b < 10;b++){
	for(int c = 0;c < 10;c++){
	  for(int d = 0;d < 10;d++){
	    if(a+b+c+d == n){
	      cnt++;
	    }
	  }
	}
      }
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 1208
loop {
	a, b = gets.split.map &:to_i
	break if a == 0
	n = gets.to_i
	hash = {}
	n.times {
		hash[gets.split.map &:to_i] = 1
	}

	way = (0..a).map{ [0] * (b+1) }
	way[1][1] = 1

	(1..a+b-1).each{|d|
		x = 1
		y = d + 1
		loop {
			if x <= a && y <= b && !hash[[x,y]]
				way[x][y] = way[x-1][y] + way[x][y-1]
			end
			x += 1
			y -= 1
			break if y <= 0
		}
	}
	p way[a][b]
}

Measured memory_bytes: 6116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
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;
}*/

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

   vector<ll> A(N), B(M), C(M);
   for(int i = 0; i < N; i++) {
       cin >> A[i];
   }

   for(int i = 0; i < M; i++) {
       cin >> B[i] >> C[i];
   }

   priority_queue<pair<ll, int>> q;

   for(int i = 0; i < M; i++) {
       q.push(make_pair(C[i], B[i]));
   }

   for(int i = 0; i < N; i++) {
       q.push(make_pair(A[i], 1));
   }
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        pair<ll, int> p = q.top();
        q.pop();
        ans += p.first;
        p.second--;
        if(p.second > 0) q.push(make_pair(p.first, p.second));
}

    cout << ans << endl;
   
    return 0;
}

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

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

  int x = 0, y = 0;
  if (n == 100) {
    n = 101;
  }
  
  if (d == 0) {
    y = n;
  } else {
    //pow(x, y)でxのy乗が計算できる
    x = pow(100, d);
    y = x * n;
  }

  cout << y << endl;
}


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


int main () {
int N , M ; cin >> N >> M ;
vector <int > cnt (M , 0);
for ( int i = 0; i < N ; ++ i ) {
int K; cin >> K ;
for ( int j = 0; j < K ; ++ j ) {
int A; cin >> A ; --A ;
++ cnt [ A ];
}
}
int ans = 0;
for ( int i = 0; i < M ; ++ i ) {
if ( cnt [ i ] == N ) {
++ ans ;
}
}
cout << ans << endl ;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main()
{
    int n, m;
    cin >> n >> m;
    
    int ans = -1;
    int s, c;
    int v[3] = {-1, -1, -1};
    for (int i = 0; i < m; i++) {
        cin >> s >> c;
        s--;
        if (v[s] != -1 && v[s] != c) goto fin;
        v[s] = c;
    }
 
    if (n == 1) {
        if (v[0] == -1) v[0] = 0;
        ans = v[0];
    } else {
        if (v[0] == 0) goto fin;
        if (v[0] == -1) v[0] = 1;
        ans = v[0];
        for (int i = 1; i < n; i++) {
            ans = 10 * ans + max(v[i], 0);
        }
    }

 fin: 
    cout << ans << endl;
}

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

int	main()
{
	vector<int>	num_vec(3);
	for (int i = 0; i < 3; ++i)
		cin >> num_vec.at(i);
	sort(num_vec.begin(), num_vec.end());
	int	diff_2_1 = num_vec.at(2) - num_vec.at(1);
	int	diff_2_0 = num_vec.at(2) - num_vec.at(0);
	int	cnt = diff_2_1 / 2 + diff_2_0 / 2;
	if (diff_2_1 % 2 == 1 && diff_2_0 % 2 == 1)
		cnt += 1;
	if (diff_2_1 % 2 == 0 && diff_2_0 % 2 == 1)
		cnt += 2;
	if (diff_2_1 % 2 == 1 && diff_2_0 % 2 == 0)
		cnt += 2;
	cout << cnt << endl;
}



Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
int main(){
int N;
cin>>N;
if(N%10==3)cout<<"bon"<<endl;
else if(N%10==0 || N%10==1 || N%10== 6 || N%10==8)cout<<"pon"<<endl;
else cout<<"hon"<<endl;



return 0;

}

Measured memory_bytes: 3636
N = int(input())
maxA = 0
secondMaxA = 0
maxIndex = -1
for i in range(N):
  A = int(input())
  if A >= maxA:
    secondMaxA = maxA
    maxA = A
    maxIndex = i
  elif A >= secondMaxA:
    secondMaxA = A

for i in range(N):
  if i == maxIndex:
    print(secondMaxA)
  else:
    print(maxA)

Measured memory_bytes: 55640
l = input().split()
s = set(l)
a = 0
b = 0
J = ''
K = ''
for i in s:
    if l.count(i) > a:
        a = l.count(i)
        J = i
    if len(i) > b:
        b = len(i)
        K = i
print(J,K)



Measured memory_bytes: 5552
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
ll exp(ll x,ll y){
    if(y==0)return 1;
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x)%big;
    ll t=exp(x,y/2);
    return (t*t)%big;
}


int main(){
    int n,m;cin >> n >> m;
    vl a(n+1,0);
    rep(i,m){
        ll k;cin >> k;
        a[k]=-1;
    }
    a[0]=1;
    if(a[1]!=-1)a[1]=1;
    rep2(i,2,n+1){
        if(a[i]==-1)continue;
        if(a[i-1]!=-1)a[i]+=a[i-1];
        if(a[i-2]!=-1)a[i]+=a[i-2];
        a[i]%=big;
    }
    printf("%lld\n",a[n]);
}

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

#define TASKNAME ""

using namespace std;

const int INF = 1e9 + 7;
const int MAXN = 1e6 + 7;
const double EPS = 1e-8;

vector <ll> a;
ll n;

ll sum(ll pos) {
    ll mid = pos;
    ll res = 0;
    ll l = mid - 1, r = mid + 1;
    vector <ll> b(n, 0);
    b[mid] = a[0];
    bool fl = false;
    ll rp = n - 1, lp = 1;
    while (l >= 0 || r < n) {
        if (!fl) {
            if (l >= 0) {
                b[l--] = a[rp--];
            }
            if (r < n) {
                b[r++] = a[rp--];
            }
        } else {
            if (l >= 0) {
                b[l--] = a[lp++];
            }
            if (r < n) {
                b[r++] = a[lp++];
            }
        }
        fl ^= 1;
    }
    for (ll i = 0; i < n - 1; i++) {
        res += abs(b[i] - b[i + 1]);
    }
    return res;
}

ll sum1(ll pos) {
    ll mid = pos;
    ll res = 0;
    ll l = mid - 1, r = mid + 1;
    vector <ll> b(n, 0);
    b[mid] = a[n - 1];
    bool fl = true;
    ll rp = n - 2, lp = 0;
    while (l >= 0 || r < n) {
        if (!fl) {
            if (l >= 0) {
                b[l--] = a[rp--];
            }
            if (r < n) {
                b[r++] = a[rp--];
            }
        } else {
            if (l >= 0) {
                b[l--] = a[lp++];
            }
            if (r < n) {
                b[r++] = a[lp++];
            }
        }
        fl ^= 1;
    }
    for (ll i = 0; i < n - 1; i++) {
        res += abs(b[i] - b[i + 1]);
    }
    return res;
}

int main() {
    #ifdef MY
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #else
        //freopen(TASKNAME".in", "r", stdin);
        //freopen(TASKNAME".out", "w", stdout);
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    #endif // MY
    cin >> n;
    a.resize(n);
    for (ll i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    if (n % 2 == 0) {
        cout << max({sum(n / 2), sum((n + 1) / 2), sum1(n / 2), sum1((n + 1) / 2)});
    } else {
        cout << max(sum(n / 2), sum1(n / 2));
    }
}


Measured memory_bytes: 1792
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a=scan.nextInt();

		if(a%2==1) {
			System.out.println((a/2)*(a/2+1));
		}
		else {
			System.out.println((a/2)*(a/2));
		}
		
	}
}

Measured memory_bytes: 22740
S = input()
A = int(S[0:2])
B = int(S[2:4])

if (A >=1)&(A <=12)&(B >=1)&(B<=12):
    print('AMBIGUOUS')
elif (A >=1)&(A <=12)&(B >=0)&(B<=99):
    print('MMYY')
elif (A >=0)&(A <=99)&(B >=1)&(B<=12):
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3064
# coding: utf-8
class March
  def initialize(target_initials, selected_people_count)
    @target_initials = target_initials
    @selected_people_count = selected_people_count
  end

  def calculate_combination_count(names)
    index_hash = create_index_hash(names)
    target_index_hash = index_hash.select{ |initial, _| @target_initials.include?(initial) }

    # if(target_index_hash.empty?)
    #   return 0
    # end

    combinations = target_index_hash.values.map{ |same_initial_names| same_initial_names.size }.combination(@selected_people_count).to_a
    if combinations.empty?
      return 0
    end

    combinations.map { |combination| combination.inject(:*) }.inject(:+)
  end

  private
  def create_index_hash(names)
    # Hash.new{[]}だと，参照が同じ配列で初期化されてしまう
    index_hash = Hash.new{ |hash, key| hash[key] = []}
    names.each { |name| index_hash[name[0]].push(name) }
    return index_hash
  end
end

module StandardInputUtil
  def multi_gets(n)
    inputs = []
    n.times do
      inputs.push(gets.chomp)
    end
    return inputs
  end
  module_function :multi_gets
end

number_of_people = gets.to_i
names = StandardInputUtil.multi_gets(number_of_people).uniq

TARGET_INITIALS = ["M", "A", "R", "C", "H"]
SELECTED_PEOPLE_COUNT = 3
march = March.new(TARGET_INITIALS, SELECTED_PEOPLE_COUNT)
result = march.calculate_combination_count(names)

p result


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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);


void solve()
{
    int n;
    cin >> n;
    map<int, int> m;
    REP(i, n) {
        int a;
        cin >> a;
        if(m.find(a) == m.end()) m[a] = 0;
        m[a]++;
    }
    int ans = 0;
    for(auto &x : m){
        if(x.first > x.second){
            ans += x.second;
        }
        else if(x.first < x.second){
            ans += x.second - x.first;
        }
    }
    cout << ans << "\n";
}

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

Measured memory_bytes: 4736
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String[] inputArr = sc.nextLine().split(" ");
		sc.close();
		int h = Integer.parseInt(inputArr[0]);
		int w = Integer.parseInt(inputArr[1]);
		int a = Integer.parseInt(inputArr[2]);
		int b = Integer.parseInt(inputArr[3]);
		
		int hMinasB = h - b;
		int wMinasA = w - a;
		String zeroFirstStr = "";
		String oneFirstStr = "";
		for(int i = 0; i < wMinasA;i++) {
			zeroFirstStr += "0";
			oneFirstStr += "1"; 
		}
		for(int i = 0; i < a; i++) {
			zeroFirstStr += "1";
			oneFirstStr += "0";
		}
		
		for(int i = 0; i < b ; i++) {
			System.out.println(zeroFirstStr);
		}
		
		for(int i = 0; i < hMinasB; i++) {
			System.out.println(oneFirstStr);
		}
		
	}
}


Measured memory_bytes: 31956
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define Mod 998244353
#define pi 3.14159265358979323846
#define endl '\n'
//#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;


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


Measured memory_bytes: 3624
using System;

namespace vol0_0000
{
    class Program
    {
        static void Main(string[] args)
        {
            for(int i=1; i<=9; i++)
            {
                for(int j=1; j<=9; j++)
                {
                    Console.WriteLine("{0}x{1}={2}",i, j, i * j);
                }
            }
        }
    }
}


Measured memory_bytes: 15648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            double money = 100000;

            for (int i = n - 1; i >= 0; i--)
            {
                money *= 1.05d;

                money /= 1000;
                money = Math.Ceiling(money);
                money *= 1000;
            }
            Console.WriteLine(money);
        }
    }
}

Measured memory_bytes: 9056
read n x0
read -a xarr
xarr+=($x0)
xarr=(`echo ${xarr[@]} | tr ' ' '\n' | sort -n`)
d=$((xarr[1]-xarr[0]))
tx=${xarr[1]}
xarr[0]=""
xarr[1]=""
for x in ${xarr[@]}
do
    d2=$((x-tx))
    if((d>d2))
    then
        tmp=$d
        d=$d2
        d2=$tmp
    fi
    while((d2%d))
    do
        tmp=$d
        d=$((d2%d))
        d2=$tmp
    done
    tx=$x
done
echo $d

Measured memory_bytes: 45564
#include <bits/stdc++.h>
using namespace std;
// ==================================================
using i64 = int64_t; using u64 = uint64_t;
#define rep(i,a,b) for(i64 i=(int64_t)(a);i<(int64_t)(b);i++)
#define repn(i,n) rep(i,0,n)
#define din(t, ...) t __VA_ARGS__;_din(__VA_ARGS__)
#define v(t,n) vector<t> n
void _din() {} void dout() { cout << endl; }
template <typename T, typename ... Args> inline void _din(T& head, Args& ... rest) { cin >> head; _din(rest...); }
template <typename T, typename ... Args> inline void dout(T head, Args ... rest) { cout << head; if (sizeof...(rest)) cout << ' '; dout(rest...); }
template <typename T>inline void vsortg(vector<T>& v) { sort(v.begin(), v.end(), greater<T>()); }
template <typename T>inline void vsortl(vector<T>& v) { sort(v.begin(), v.end(), less<T>()); }
template <typename T> inline T nmax(T f1, T f2) { return max(f1, f2); }
template <typename T, typename ... Args> inline T nmax(T first, Args ... rest) { return nmax(first, nmax(rest...)); }
template <typename T> inline T nmin(T f1, T f2) { return min(f1, f2); }
template <typename T, typename ... Args> inline T nmin(T first, Args ... rest) { return nmin(first, nmin(rest...)); }
// ==================================================
int main()
{
	din(int, d);
	switch (d)
	{
	case 25:
		dout("Christmas");
		break;
	case 24:
		dout("Christmas Eve");
		break;
	case 23:
		dout("Christmas Eve Eve");
		break;
	case 22:
		dout("Christmas Eve Eve Eve");
		break;
	default:
		break;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int t = 0;
        for (int i = 1; i <= n; i++)
            t += i;
        System.out.printf("%d\n", t);
    }
}


Measured memory_bytes: 9552
#include <stdio.h>
	#include <stdlib.h>
	#include <string.h>
	#include <math.h>
	#include <ctype.h>
	#include <limits.h>	
	#define inf (INT_MAX-1)
	#define INF 9223372036854775807
	#define sq(n) ((n)*(n))
	#define rep(i,n) for(i=0;i<n;i++)
	#define rev(i,n) for(i=n-1;i>=0;i--)
	#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
	#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
	#define TYPE int
	#define MEMSET(a) memset(a,0,sizeof(a))
	const int mod=(int)1e09+7;

	int in(void){
		int i;scanf("%d",&i);
		return i;
	}
	long long llin(void){
		long long i;scanf("%lld",&i);
		return i;
	}
	double din(void){
		double i;scanf("%lf",&i);
		return i;
	}
	void chin(char s[]){
		scanf("%s",s);
	}
	void print(int a){
		printf("%d\n",a);
	}
	void llprint(long long a){
		printf("%lld\n",a);
	}
	void dprint(double a){
		printf("%.10f\n",a);
	}
	void print2(int a,int b){
		printf("%d %d\n",a,b);
	}
	long long max(long long a,long long b){
		return a>b?a:b;
	}
	long long min(long long a,long long b){
		return a<b?a:b;
	}
	long long llabs(long long a){
		return a>0?a:-a;
	}
	double dmax(double a,double b){
		return a>b?a:b;
	}
	int cmp(const void *a,const void *b){
		return *(TYPE *)a-*(TYPE *)b;
	}
	int cmp_r(const void *a,const void *b){
		return *(TYPE *)b-*(TYPE *)a;
	}
	void swap(int *a,int *b){
		int t=*a;
		*a=*b;
		*b=t;
	}

	int main(void){
		int a=in(),b=in();
		if((a*b)%2)puts("Odd");
		else puts("Even");
		return 0;
	}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long a = scanner.nextLong();
        long b = scanner.nextLong();
        long x = scanner.nextLong();

        long sum = (b / x) - (a / x);
        if (a % x == 0) {
            sum++;
        }
        System.out.print(sum);
    }
}


Measured memory_bytes: 20948
n,m=map(int,input().split())
s=input()
S=[]
for i,ss in enumerate(s):
  if ss=="0":
    S.append(i)
Ans=[]
cur=n
chk=True
import bisect
while cur>0:
  next=S[bisect.bisect_left(S,max(0,cur-m))]
  if next==cur:
    chk=False
    break
  else:
    Ans.append(cur-next)
    cur=next
if not chk:
  print(-1)
else:
  Ans=Ans[::-1]
  print(*Ans)


Measured memory_bytes: 10340
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int main(void){
	long long int K,X,i;
	scanf("%lld %lld",&K,&X);
	if(-1000000 <= X - K + 1 ){
		if(X + K - 1 <= 1000000){
			for(i = X - K + 1 ; i < X + K ; i ++){
				printf("%lld ",i);
			}
		} else {
			for(i = X - K + 1 ; i <= 1000000 ; i ++){
				printf("%lld ",i);
			}
		}
		
	} else {
		if(X + K - 1 <= 1000000){
			for(i = -1000000 ; i < X + K ; i ++){
				printf("%lld ",i);
			}
		} else {
			for(i = -1000000 ; i < 1000000 ; i ++){
				printf("%lld ",i);
			}
		}
	}
	return 0;
}

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

int main(){
    vector<int>v(3);
    cin >>v[0]>>v[1]>>v[2];
    int sum=0;
    if((v[0]%2)==(v[1]%2)&&(v[1]%2)==(v[2]%2)){
    }
    else if((v[0]%2)==(v[1]%2)){
        v[0]++;
        v[1]++;
        sum++;
    }
    else if((v[0]%2)==(v[2]%2)){
        v[0]++;
        v[2]++;
        sum++;
    }
    else{
        v[1]++;
        v[2]++;
        sum++;
    }
    sort(v.begin(),v.end());
    sum+=(v[2]-v[1])/2;
    sum+=(v[2]-v[0])/2;
    cout << sum << endl;
    return 0;
}

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

int main(){

  int n;
  ll x, ans = 0;
  ll a[100001] = {};

  cin >> n >> x;
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n-1; i++){
    ll tmp = a[i] + a[i+1];
    if(tmp >= x){
      ans += tmp - x;
      a[i+1] -= tmp - x;
      if(a[i+1] < 0) a[i+1] = 0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
using namespace std;

int main(){ 
  int a,b,c,n;
  cin>>n;
  string s;
  cin>>s;
  int t[26]={};
  long ans=1;
  rep(i,0,n){
    a=s[i];
    t[a-97]++;
  }
  
  rep(i,0,26){
    ans*=t[i]+1;
    ans%=1000000007;
  }
  co(ans-1);
  
  return 0;
}

Measured memory_bytes: 512
s = input()
start_zero_cnt = 0
start_one_cnt = 0
for i in range(len(s)):
  if i%2==0:
    if s[i]=='0':
      start_one_cnt += 1
    else:
      start_zero_cnt += 1
  elif i%2==1:
    if s[i]=='1':
      start_one_cnt += 1
    else:
      start_zero_cnt += 1
print(min(start_zero_cnt, start_one_cnt))

Measured memory_bytes: 3188
import bisect

N = int(input())
A = [10**9 + 1]

for i in range(N):
  target = int(input())
  target_idx = bisect.bisect_left(A, target)
  if target_idx > len(A) - 1:
    A.append(target)
  else:
    A[target_idx] = target

print(len(A))



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

int main(){
	int n, pt1 = 0, pt2 = 0;
	std::string card1, card2;
	std::cin >> n;
	for(int i=0; i<n; i++){
		std::cin >> card1 >> card2;
		if(card1 < card2)
			pt2 += 3;
		else if(card1 > card2)
			pt1 += 3;
		else{
			pt1++;
			pt2++;
		}
	}
	std::cout << pt1 << ' ' << pt2 << std::endl;
	return 0;
}

Measured memory_bytes: 1204
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000
#define mod = (int)1000000007;
#pragma endregion
lint n, k;
void solve() {
	cin >> n >> k;
	map<lint, lint> d;
	for (int i = 0; i < n; i++) {
		lint x, y; cin >> x >> y;
		d[x] += y;
	}
	lint cnt = 0;
	for (int i = 0; i <= 100010; i++) {
		cnt += d[i];
		if (cnt >= k) { printf("%d\n", i); return; }
	}
}


int main(void) {
	solve();

	return 0;
}

Measured memory_bytes: 9948
import java.util.Scanner;

public class Main {
	static boolean LOCAL = System.getSecurityManager() == null;
	Scanner sc = new Scanner(System.in);


	public static void main(String[] args) {
		new Main().run();
	}

	int[] array = new int[]{0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};
	
	void run() {
		int T = sc.nextInt();
		for(int test = 0; test < T; test++){
			String ret = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
			String now = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
			int start = sc.nextInt();
			int goal = sc.nextInt();
			for(int i =0; i < array.length * 3; i++){
				int pos = array[i%array.length];
				if(pos==start){
					now = pos + " ";
				}
				else if(pos==goal){
					now += pos;
					if(ret.length() > now.length()) ret = now;
				}
				else now += pos + " ";
			}
			System.out.println(ret);
		}
	}
}

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

int foo(int x, int y, int a){
	int z, i;
        int c = 0;
	z = y * x - y * a;

	for(i = 0; i <= y; i++){
		if(z == i * x) {
			c = 1;
			break;
		}
	}	

	return c;
}

int main(){
	int count = 0;
	int x, y;
	cin>>x>>y;
	
	for(int i = 0; i <= x; i++){
		if(foo(x, y, i)) count++;
	}	

	cout<<x + y + 2 -count<<endl;
	return 0;
}



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

namespace ABC179
{

  class A
  {
  public:
    A() = default;
    ~A() = default;


    void Run()
    {
      std::string S = {};
      std::cin >> S;

      if (*(S.rbegin()) == 's')
      {
        S.append("es");
      }
      else
      {
        S.append("s");
      }

      std::cout << S << std::endl;
    }
  };

}


int main()
{

  ABC179::A prob;
  prob.Run();

  return 0;
}



Measured memory_bytes: 3128
import numpy as np
from fractions import gcd
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.append(x)
a = np.array(list(set(a)))
a.sort()
diff = a[1:] - a[:-1]

# print(a - x)
diff = list(diff)
tmp = diff[0]
for i in diff[1:]:
    tmp = gcd(tmp, i)
print(tmp)

# print(diff.min())


Measured memory_bytes: 24992
n, m, l = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
B = [list(map(int, input().split()))for j in range(m)]
C = [[0 for k in range(l)] for i in range(n)]

for i in range(n) :
	for k in range(l) :
		for j in range(m) :
			C[i][k] += A[i][j] * B[j][k]

for i in range(n) :
	for k in range(l) :
		if k != l - 1 :
			print(C[i][k], end=" ")
		else :
			print(C[i][k])



Measured memory_bytes: 7068
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
	vi v(3);
	REP(i,3){
		cin >> v[i];
	}
	sort(ALL(v));
	if(v[1]!=v[2]){
		ans = v[2] - v[1];
		v[0] += ans;
		v[1] = v[2];
	}
	ans += (v[1] - v[0]) / 2;
	if ((v[1] - v[0]) % 2==1){
		ans += 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program {
    static void Main() {
        var n = NextLong();
        var m = NextLong();
        var s = NextString();
        var t = NextString();
        var l = LCM(n, m);
        var dic = new Dictionary<long, char>();

        foreach (var i in Enumerable.Range(0, s.Length)) {
            var j = i * l / n;
            dic[j] = s[i];
        }

        foreach (var i in Enumerable.Range(0, t.Length)) {
            var j = i * l / m;
            if (dic.ContainsKey(j) && dic[j] != t[i]) {
                WriteLine(-1);
                return;
            }
        }
        WriteLine(l);
    }

    static long LCM(long x, long y) {
        return x * y / GCD(x, y);
    }

    static long GCD(long x, long y) {
        if (x < y) {
            return GCD(y, x);
        } else if (y == 0) {
            return x;
        }
        return GCD(y, x % y);
    }

    static long NextLong() {
        return long.Parse(NextString());
    }

    static string NextString() {
        var result = new List<char>();
        while (true) {
            int next = Read();
            if (next < 0)
                break;
            var nextChar = (char)next;
            if (!char.IsWhiteSpace(nextChar))
                result.Add(nextChar);
            else if (nextChar != '\r')
                break;
        }
        return string.Join("", result);
    }
}

Measured memory_bytes: 21984
#include<bits/stdc++.h>
using namespace std;
const int N=450; 
const int M=1e5+100;
bool f[N][N];
int n,m,u[M],v[M];
bool chck[N];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        scanf("%d%d",&u[i],&v[i]);
    }
    for(int i=1;i<=n;i++){
        f[i][i]=1;
        for(int j=m;j>=1;j--){
            bool x=f[i][u[j]],y=f[i][v[j]];
            if(x&&y){
			chck[i]=1;
			break;
			}
            else if(x) f[i][v[j]]=1;
            else if(y) f[i][u[j]]=1;
        }
    }
    int ans=0;
    for(int i=1;i<n;i++){
        if(chck[i]) continue;
        for(int j=i+1;j<=n;j++){
            if(chck[j]) continue;
            bool fl=1;
            for(int k=1;k<=n;k++){ 
                if(f[i][k]&&f[j][k]) fl=0;
            } 
            ans+=fl;
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 1152