akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1000000007;
int num(int x){
    int a = 10;
    int ans = 1;
    while (x >= a){
        ans++;
        a *= 10;
    }
    return ans;
}
int pw(int a, int b){
	int ans = 1;
	int st = a;
	for (int i=0; i < 30; i++){
		int ba = (1LL<<i)&b;
		if (ba != 0){
			ans *= st;
			ans %= MOD;
		}
		st*=st;
		st%=MOD;
	}
	return ans;
}
int solve(int s) {
    ios_base::sync_with_stdio(false);
    int ans = 0;
    int S = 0;
    int i = 1;
    while (true){
        int pl = num(i);
        if (S + pl <= s){
            i++;
            S += pl;
        }
        else break;
    }
    if (s == S) ans++;
    for (int j=2; j < 10000000; j++){
        S -= num(j-1);
        while (true){
            int pl = num(i);
            if (S + pl <= s){
                i++;
                S += pl;
            }
            else break;
        }
        if (s == S) ans++;
    }
    //cout << ans << endl;
    int now = 90000000;
    for (int j=8; j <= 1000000; j++){
        int X = -s;
        int Y = s;
        int p = s/(j+1) + 1;
        X += p*(j+1);
        Y -= p*j;
        if (Y > 0){
            ans += (Y-1) / j + 1;
            ans %= MOD;
        }
        if (Y % j == 0 && Y >= 0){
            X += (Y/j) * (j+1);
            ans += now - X + 1;
            ans %= MOD;
        }
        now *= 10;
        now %= MOD;
    }
    //cout << ans << endl;
    if (s > 1000000){
        for (int a=1; a <= 100; a++){
            for (int b=1; b <= 100; b++){
                if ((s-b) % (a+b) != 0) continue;
                int XX = (s-b) / (a+b);
                if (XX > 1000000){
                    //cout << a << " " << b << endl;
                    ans++;
                }
            }
        }
        //cout << ans << endl;
        for (int j=1; j <= 100; j++){
            if (s/j > 1000000 && s % j == 0){
				int G = 9*pw(10, s/j-1);
                int XX = j;
                ans += G - XX + 1;
            }
        }
    }
    ans %= MOD;
    ans += MOD;
    return ans%MOD;
}

signed main(){
    int s;
    cin >> s;
    int A = solve(s);
    cout << A << endl;
}


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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    ll X; cin >> X;
    ll M = X / 500;
    X %= 500;
    ll L = X / 5;
    cout << M*1000 + L*5 << endl;
    return 0;
}


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

int jos(int n, int k)
{
 int i;
 for( i = k-1; i<(k-1)*n ; i = (k*i) / (k-1)+1);
 return(k*n-i);
 }
 int main()
{
 int n,k;
 while(cin>>n>>k, n || k)
 {
  cout<< jos(n , k) <<endl;
  }
 }

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>

#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

int main() {

	int a, b;
	cin >> a >> b;

	cout << a - b + 1 << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
b = list(map(int,input().split()))
a = []
for i in range(len(b)):
    if i == 0:
        a.append(b[0])
    else:
        if b[i] >= b[i-1]:
            a.append(b[i-1])
        elif b[i] < b[i-1]:
            a.append(b[i])
a.append(b[-1])
print(sum(a))

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

// Author: Ashish

int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  int answer=0;
  cin>>n;
  answer=n/500;
  answer*=1000;
  n%=500;
  n=n-(n%5);
  answer+=n;
  cout<<answer;

  return 0;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()
#define arr array

template<typename T> void umin(T& a,T b){a = min(a,b);}
template<typename T> void umax(T& a,T b){a = max(a,b);}

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e18;


void pre(){



}
 

void solve(){
    
    int n;
    cin >> n;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin >> a[i];
    
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(a[i] == a[j])
                continue;
            for(int k=j+1;k<=n;k++){
                if(a[i] != a[k] and a[j] != a[k]){
                    if(a[i] + a[j] > a[k] and a[i] + a[k] > a[j] and a[j] + a[k] > a[i])
                        ans++;
                }
            }
        }
    }
    cout << ans ;
    
}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 3560
#include<stdio.h>
#include<string.h>
int main(){
    char s[101];
    scanf("%s",s);
    int ans = 0;
    for(int i = 0; i < strlen(s) / 2; i++){
        if(s[i] != s[strlen(s) - i - 1]){
            ans ++;
            s[strlen(s) - i - 1] = s[i];
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, K = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = 0
    for i in range(K,N+2):
        cnt += (N*(N+1)//2-(N-i)*(N-i+1)//2) - (i-1)*i//2+1
    cnt = int(cnt % (1e9+7))
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, long long M, std::vector<long long> A){
    int cnt = 0;
    int sum = accumulate(all(A), 0);
    rep(i,0,N) if (A[i] >= ceil(1.0 * sum / (4 * M))) cnt++;
    cout << (cnt >= M ? "Yes" : "No") << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}


Measured memory_bytes: 256
<?php
  $n = trim(fgets(STDIN));
  $min = PHP_INT_MAX;
  $min = min($min,trim(fgets(STDIN)));
  $min = min($min,trim(fgets(STDIN)));
  $min = min($min,trim(fgets(STDIN)));
  $min = min($min,trim(fgets(STDIN)));
  $min = min($min,trim(fgets(STDIN)));
  
  $ans = 4+ceil($n/$min);
  printf("%d", $ans);


Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n; cin>>n;
    int k; cin>>k;
    string s; cin>>s;
    int cnt=1;
    rep(i,n-1){
        if(s[i]!=s[i+1]) cnt++;
    }
    cout<<min(n-1,n-cnt+2*k)<<endl;
    return 0;
}

Measured memory_bytes: 512
BIG_NUM = 2000000000

N=int(input())

table=list(map(int, input().split()))

maxinum = -BIG_NUM
mininum = BIG_NUM
total = 0

for x in table:
    if maxinum< x:
        maxinum =x
    if mininum > x:
        mininum = x
    total += x
    
print("%d %d %d"%(mininum, maxinum, total))


Measured memory_bytes: 6588
#include "bits/stdc++.h"

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

constexpr int dx[4] = {1, 0, -1, 0};
constexpr int dy[4] = {0, 1, 0, -1};


int f(int N) {
    int sum = 0;
    while(N > 0) {
        sum += N % 10;
        N /= 10;
    }
    return sum;
}

int main() {
    int N;
    cin >> N;
    int sum = f(N);
    if (N % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int main(void){
	int n,m,l;
	int i,j,k;
	int a[101][101],b[101][101];
	LL c[101][101];
	cin>>n>>m>>l;
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			c[i][j]=0;
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			cin>>a[i][j];
		}
	}
	for(i=0;i<m;i++){
		for(j=0;j<l;j++){
			cin>>b[i][j];
		}
	}
	for(i=0;i<n;i++){
		for(k=0;k<m;k++){
			for(j=0;j<l;j++){
				c[i][j]+=(LL)a[i][k]*b[k][j];
			}
		}
	}
	
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			if(j)	cout<<" ";
			cout<<c[i][j];
		}
		cout<<endl;
	}
	return 0;
}
	


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

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fileRead freopen("input.txt", "r", stdin);
#define fileWrite freopen("output.txt", "w", stdout);

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}

///-------------------------------------------------------------------

int main()
{
    int n,k;
    cin>>n>>k;
    int a[n], dp[n];
    fill(dp, dp+n, 1e9);
    dp[0]=0;
    for0(i,n) cin>>a[i];
    for0(i,n){
        for(int j=i+1; j<=i+k; j++){
            if(j<n) dp[j] = min(dp[j], dp[i]+abs(a[i]-a[j]));
            else break;
        }
    }
    cout<<dp[n-1];
}

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

//          N   E  S  W
int di[] = {-1, 0, 1, 0};
int dj[] = {0,  1, 0, -1};

int h,w;
char g[60][60];
char op[1010];
char vis[60][60][4][1010];
char vis_while[60][60][4][1010];
int dir;
int ci, cj;

char *Prog(char *);
pair<char*,bool> Cond(char *);

pair<char*,bool> Cond(char *p){
    bool inv = false;
    if(*p == '~'){
        inv = true;
        ++p;
    }
    bool res = false ||
        (*p=='N' && dir == 0) ||
        (*p=='E' && dir == 1) ||
        (*p=='S' && dir == 2) ||
        (*p=='W' && dir == 3) ||
        (*p=='C' && g[ci+di[dir]][cj+dj[dir]] == '#') ||
        (*p=='T');
    res ^= inv;
    ++p;
    return make_pair(p,res);
}

char *If(char *p){
    ++p;
    bool cond;
    tie(p,cond) = Cond(p);
    if(cond){
        p = Prog(p);
        ++p;
        return p;
    } else {
        int d = 1;
        while(d != 0){
            if(*p == '[') ++d;
            else if(*p == ']') --d;
            ++p;
        }
        return p;
    }
}

char *While(char *p){
    ++p;
    char *cond_begin = p;
    while(1){
        if(vis_while[ci][cj][dir][p-op]) throw -1;
        vis_while[ci][cj][dir][p-op] = true;

        bool cond;
        tie(p,cond) = Cond(p);
        if(cond){
            p = Prog(p);
            p = cond_begin;
        } else {
            int d = 1;
            while(d != 0){
                if(*p == '{') ++d;
                else if(*p == '}') --d;
                ++p;
            }
            return p;
        }
    }
}

int cnt;
char *Move(char *p){
    if(vis[ci][cj][dir][p-op]) throw -1;
    vis[ci][cj][dir][p-op] = true;
    ++cnt;

    if(*p == '>') dir = (dir+1) & 3;
    if(*p == '<') dir = (dir-1) & 3;
    if(*p == 'v'){
        int ni = ci + di[(dir+2) & 3];
        int nj = cj + dj[(dir+2) & 3];
        if(g[ni][nj] != '#'){
            ci = ni; cj = nj;
        }
    }
    if(*p == '^'){
        int ni = ci + di[dir];
        int nj = cj + dj[dir];
        if(g[ni][nj] != '#'){
            ci = ni; cj = nj;
        }
    }

    if(g[ci][cj] == 'g') throw cnt;
    ++p;
    return p;
}

char *Statement(char *p){
    if(*p == '[') p = If(p);
    else if(*p == '{') p = While(p);
    else p = Move(p);
    return p;
}

char *Prog(char *p){
    while(*p == '[' || *p == '{' || *p == '^' || *p == 'v' || *p == '<' || *p == '>'){
        p = Statement(p);
    }
    return p;
}

int main(){
    while(cin >> h >> w){
        memset(vis, 0, sizeof vis);
        memset(vis_while, 0, sizeof vis_while);
        cnt = 0;
        dir = 0;
        rep(i,h) cin >> g[i];
        rep(i,h) rep(j,w) if(g[i][j] == 's') ci = i, cj = j;
        cin >> op;
        int ans = -1;
        try {
            Prog(op);
        } catch(int r){
            ans = r;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 31552
#include <stdio.h>
#include <vector>
#include <limits>
#include <map>
#include <iostream>

using namespace std;
int main() {
  int n, t;
  scanf("%d %d", &n, &t);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);

  int mi = a[0];
  int ma = -(int)1e9;
  map<int, int> m;
  for (int i = 1; i < n; ++i) {
    int diff = a[i] - mi;
    m[diff]++;
    mi = min(mi, a[i]);
    ma = max(ma, diff);
  }
  printf("%d\n", m[ma]);
  return 0;
}



Measured memory_bytes: 5376
package main
 
import("fmt")
 
func main(){
  var a,b int
  fmt.Scan(&a, &b)
  fmt.Print(lcm(a,b))
}

func gcd(a,b int) int {
  if b ==0 {
    return a
  }else {
    return gcd(b, a%b)
  }
}

func lcm(a,b int) int {
  return a*b / gcd(a,b)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

int main(){ 
  Int N;
  cin >> N;
  
  Int q, r, s, t, ans;
  q = N / 15;
  r = N % 15;
  s = 0;
  t = 0;
  
  for(int i = 0; i<=r; i++) {
    if (i%3!=0 && i%5!=0) {
      s += i;
      t ++;
    }
  }
  
  ans = 60 * q * q + 15 * q * t + s;
  
  cout << ans << endl;

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    long long A,B,N;
    cin >>A>>B>>N;

    long long x=min(N,B-1);
    long long ans=A*x/B;
    cout << ans << endl;



}


Measured memory_bytes: 3648
function Main (input) {
  const inputs = input.split(/\s/g)[0].split('');
  const patterns = inputs.map((sign) => sign === '+' ? 1 : -1);
  const result = patterns.reduce((prev, current) => prev + current, 0);
  console.log('%s', result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7624
#!/usr/bin/env python3
import math
N, M = map(int, input().split())
MOD = 10**9 + 7

if abs(N-M) > 1:
    print(0)
elif abs(N-M) == 1:
    print(math.factorial(N)*math.factorial(M)%MOD)
else:
    print(math.factorial(N)*math.factorial(M)*2%MOD)


Measured memory_bytes: 11064
while line = gets
a = line.split.map(&:to_i)
b = gets.split.map(&:to_i)

count1 = 0
count2 = 0

for i in (0..3)
  for j in (0..3)
    if a[i] == b[j]
      if i == j
        count1 += 1
      else
        count2 += 1
      end
    end
  end
end
puts count1.to_s+" "+count2.to_s
end


Measured memory_bytes: 6844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"
#define MOD 1000000007
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))

int main()
{	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	ll n,x;
 cin>>n>>x;
 if(n<x) 
   cout<<"0";
 else cout<<"10";
	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int P = 998244353;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
 
  vector<vector<long long>> dpv(C - A + 1, vector<long long>(D - B + 1, 0));
  dpv[0][0] = 1;  // Boundary condition.
  for (int i = 0; i <= C - A; ++i) {
    for (int j = 0; j <= D - B; ++j) {
      if (i == 0 && j == 0) continue;
 
      dpv[i][j] = 0;
      if (i > 0) {  // Last step was adding a row.
        dpv[i][j] += (B + j) * dpv[i - 1][j];
      }
      if (j > 0) {  // Last step was adding a col
        dpv[i][j] += (A + i) * dpv[i][j - 1];
      }
      if (i > 0 && j > 0) {
        dpv[i][j] -= ((A + i - 1) * (B + j - 1) * dpv[i - 1][j - 1]) % P;
      }
      while (dpv[i][j] < 0) {
        dpv[i][j] += P;
      }
      while (dpv[i][j] >= P) {
        dpv[i][j] %= P;
      }
    }
  }
  cout << dpv.back().back() << endl;
}

Measured memory_bytes: 73508
N = int(input())
S = input()

l = 0
r = S[1:].count('E')
result = l + r

for i in range(1, N):
    if S[i - 1] == "W":
        l += 1
    if S[i] == "E":
        r -= 1
    result = min(result, l + r)

print(result)


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

int n,x,y;
int dis[2010][2010];
int cnt[2010];

int main()
{
	scanf("%d%d%d",&n,&x,&y);
	for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++)
	{
		dis[i][j]=min(j-i,min(abs(i-x)+abs(j-y)+1,abs(i-y)+abs(j-x)+1));
		cnt[dis[i][j]]++;
	}
	for(int i=1;i<n;i++) printf("%d\n",cnt[i]);
	return 0;
}

Measured memory_bytes: 17532
#include <stdio.h>

int main(void) {
    double b;
    long int ans, a;
    scanf("%ld %lf", &a, &b);
    int c = b * 100+0.0001;
    ans = (long)(a * c) / 100;
    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 1748
function main(input) {
  let [n, m, q] = input[0].trim().split(" ").map(e => parseInt(e))
  let [a,b,c,d] = [[],[],[],[]]
  for(let i = 0; i < q; i++) {
    [a[i],b[i],c[i],d[i]] = input[i+1].split(' ').map(e=>parseInt(e))
  }
  
  function dfs(arr, num, id) {
    arr.push(num)
    if(id < n-1) {
      let ret = 0
      for(let j = num; j <= m; j++) {
        let rep = dfs(arr.concat(), j, id+1)
        ret = Math.max.apply(null, [ret, rep])
      }
      return ret
    } else {
      let ret = 0
      for(let j = 0; j < q; j++) {
        if(arr[b[j]-1] - arr[a[j]-1] == c[j]) {
          ret += d[j]
        }
      }
      return ret
    }
  }
  
  let ar = []
  let ans = 0
  for(let i = 1; i <= m; i++) {
    let rep = dfs(ar.concat(), i, 0)
    ans = Math.max(ans, rep)
  }
  console.log(ans.toString())
}

main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split('\n'))

Measured memory_bytes: 35672
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>

using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;

#define rep(i,x) for(Int i = 0; i < (Int)(x); i++)
#define rrep(i,x) for(Int i = ((Int)(x) - 1); i >= 0; i--)
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

Int dx[4] = {1,0,-1,0};
Int dy[4] = {0,1,0,-1};
const Int INF = 1001002003004005006ll;
const Int mod = 1e9 + 7;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//











//nの階乗の素因数分解


int main(){
        int n;
        cin >> n;
        Int ret = 1;
        for(int i = 2; i <= n; i++){
                bool flag = true;
                //iが素数かどうか判定して
                for(int j = 2; j * j <= i; j++){
                        if(i%j == 0) flag = false;
                }
                //もし素数なら
                if(flag){
                        int ord = 0;
                        int v = n;
                        //nの素因数分解をその素数でした時の数を数える。要はその素数で何回割り切れるか数える。
                        while(v){
                                ord += v/i;
                                v /= i;
                        }
                        //それぞれの素因数の数足す１を掛け合わせるとその約数の数になる。
                        ret = ret * (ord+1) % mod;
                }
        }

        cout << ret << endl;
        return 0;
}


































Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
      char a[110],num=0,l;
      int i;
      scanf("%s",a);
      l=strlen(a);
      for(i=0;i<l/2;i++)
      {
          if(a[i]!=a[l-1-i])
            num++;
      }
      printf("%d\n",num);

}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
	int n,m;
	long long a,b,c,d;
	while(scanf("%d%d",&n,&m)==2){
		long long st[55][2];
		long long ch[55][2];
		for(int i=0;i<n;i++){
			scanf("%lld%lld",&st[i][0],&st[i][1]);
		}
		for(int i=0;i<m;i++){
			scanf("%lld%lld",&ch[i][0],&ch[i][1]);
		}
		
		for(int i=0;i<n;i++){
			long long x, min_d;
			int idx=1;
			min_d=abs(st[i][0]-ch[0][0])+abs(st[i][1]-ch[0][1]);

			for(int j=1;j<m;j++){
				x=abs(st[i][0]-ch[j][0])+abs(st[i][1]-ch[j][1]);
				if(x<min_d){
					min_d=x;
					idx=j+1;
				}
			}
			printf("%d\n",idx);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }

template<int mod> struct ModInt {
    int x;

    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt& operator+=(const ModInt& p) {
        if ((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(const ModInt& p) {
        if ((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator*=(const ModInt& p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt& operator/=(const ModInt& p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt& p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt& p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt& p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt& p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt& p) const { return x == p.x; }
    bool operator!=(const ModInt& p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }

    ModInt pow(int e) {
        long long a = 1, p = x;
        while (e > 0) {
            if (e % 2 == 0) { p = (p * p) % mod; e /= 2; }
            else { a = (a * p) % mod; e--; }
        }
        return ModInt(a);
    }

    friend ostream& operator<<(ostream& os, const ModInt<mod>& p) {
        return os << p.x;
    }
    friend istream& operator>>(istream& is, ModInt<mod>& a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};
using modint = ModInt<mod>;

int main() {
    init();

    int n;
    string s, t;
    cin >> n >> s >> t;

    vector<modint> alph(26, 0), dp(n, 0);
    dp[0] = 1;
    FOR(i, 0, n) {
        dp[i] += alph[t[i] - 'a'];
        alph[s[i] - 'a'] += dp[i];
    }
    cout << dp[n - 1] << "\n";
}



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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll INF=1000000000000;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}

//a,b x
int main(){
	ll N,T; cin>>N>>T;
    ll ans=INF;
    rep(i,N){
        ll c,t; cin>>c>>t;
        if(t<=T && c<ans) ans=c;
    }
    if(ans==INF) cout<<"TLE";
    else cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

bool isMonth(int a)
{
	if(a==0 || a>12)
	{
		return false;
	}
	return true;
}
int main()
{
	string s;
	cin>>s;
	string sf = s.substr(2);
	string sl = s.substr(0,2);
	int a = atoi(sf.c_str());
	int b = atoi(sl.c_str());

	string result;
	if(!isMonth(a) && !isMonth(b))
	{
		result = "NA";
	}
	else if(!isMonth(b))
	{
		result = "YYMM";
	}
	else if(!isMonth(a))
	{
		result = "MMYY";
	}
	else
	{
		result = "AMBIGUOUS";
	}
	cout<<result<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
 
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
 

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

double dp[301][301][301]; // 3, 2, 1

double dfs(int one, int two, int three, int n)
{
  if(dp[three][two][one] != -1)
  {
    return dp[three][two][one];
  }

  double part[3] = {};
  if(one != 0)
  {
    part[0] = dfs(one-1,two,three,n) * one;
  }

  if(two != 0)
  {
    part[1] = dfs(one+1, two-1, three, n) * two;
  }

  if(three != 0)
  {
    part[2] = dfs(one, two+1, three-1, n) * three;
  }

  dp[three][two][one] = (part[0] + part[1] + part[2] + n) / (one + two + three);
  return dp[three][two][one];
}

int main(){
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int count[3] = {};

    for(int i=0;i<301;++i)
    {
      for(int j=0;j<301;++j)
      {
        for(int k=0;k<301;++k)
        {
          dp[i][j][k] = -1;
        }
      }
    }
    dp[0][0][1] = n;
    for(int i=0;i<n;++i)
    {
      int tmp;
      cin >> tmp;
      tmp--;
      count[tmp]++;
    }

    printf("%.10lf\n", dfs(count[0], count[1], count[2], n));
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a);i>(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1000000000;
const LL MOD = 1000000007;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

int main() {
  string S;
  cin >> S;
  int N = SZ(S);
  
  VI dp(13);
  dp.at(0) = 1;
  int s=1;
  
  REP(j,N) {
    int i = N-j-1;
    VI a(13);
    REP(l,13){
    if(S.at(i) =='?') {
      REP(k,10) {
        
        a.at((s*k+l)%13) += dp.at(l);
        a.at((s*k+l)%13) %= MOD;
      }
    }
    
    else {
      
      int k = S.at(i) - '0';
      a.at((s*k+l)%13) += dp.at(l);
      a.at((s*k+l)%13) %= MOD;
      
    }
    }  
    dp = a;  
    s *= 10;
    s %= 13;
  }
  
  cout << dp.at(5) << endl;
}

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

using ll = long long int;
using P = pair<ll, ll>;
using P3 = pair<double,P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9) + 7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-8;

void chmax(int &a, int b){
    a = max(a,b);
}

bool isIn(int x, int y, int z, int n){
    return x>=0 && x<n && y>=0 && y<n && z>=0 && z<n;
}

struct Game{
    int n, m;
    int a[8][8][8], len[8][8][8][9];
    Game(int n, int m):n(n),m(m){}
    void init(){
        memset(a, -1, sizeof(a));
    }
    void put(int x, int y, int c){
        int z = n-1;
        while(z>0 && a[x][y][z-1]==-1) z--;
        a[x][y][z] = c;
    }
    bool check(){
        int maxi = 0;
        memset(len, 0, sizeof(len));
        for(int z=0;z<n;z++){
            for(int x=0;x<n;x++){
                for(int y=0;y<n;y++){
                    for(int dx=-1;dx<=1;dx++)for(int dy=-1;dy<=1;dy++){
                        int k = dx*3+dy;
                        if(z==0) len[x][y][z][k] = 1;
                        else len[x][y][z][k] = (isIn(x+dx,y+dy,z-1,n) && a[x+dx][y+dy][z-1]==a[x][y][z] && a[x][y][z] != -1 ? len[x+dx][y+dy][z-1][k]+1 : 1);
                        chmax(maxi, len[x][y][z][k]);
                    }
                }
            }
        }
        memset(len, 0, sizeof(len));
        for(int y=0;y<n;y++){
            for(int x=0;x<n;x++){
                for(int z=0;z<n;z++){
                    for(int dx=-1;dx<=1;dx++)for(int dz=-1;dz<=1;dz++){
                        int k = dx*3+dz;
                        if(y==0) len[x][y][z][k] = 1;
                        else len[x][y][z][k] = (isIn(x+dx,y-1,z+dz,n) && a[x+dx][y-1][z+dz]==a[x][y][z] && a[x][y][z] != -1 ? len[x+dx][y-1][z+dz][k]+1 : 1);
                        chmax(maxi, len[x][y][z][k]);
                    }
                }
            }
        }
        memset(len, 0, sizeof(len));
        for(int x=0;x<n;x++){
            for(int y=0;y<n;y++){
                for(int z=0;z<n;z++){
                    for(int dz=-1;dz<=1;dz++)for(int dy=-1;dy<=1;dy++){
                        int k = dz*3+dy;
                        if(x==0) len[x][y][z][k] = 1;
                        else len[x][y][z][k] = (isIn(x-1,y+dy,z+dz,n) && a[x-1][y+dy][z+dz]==a[x][y][z] && a[x][y][z] != -1 ? len[x-1][y+dy][z+dz][k]+1 : 1);
                        chmax(maxi, len[x][y][z][k]);
                    }
                }
            }
        }
        return maxi >= m;
    }
};


int solve(){
    int n, m, p;
    cin >> n >> m >> p;
    if(n == 0) return 1;
    Game game(n,m);
    game.init();
    bool end = false;
    for(int i=0;i<p;i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        game.put(x,y,i%2);
        if(!end && game.check()){
            cout << (i%2 ? "White " : "Black ") << i+1 << endl; 
            end = true;
        }
    }
    if(!end){
        cout << "Draw" << endl;
    }
    // game.print();
    return 0;
}

int main(){
    // solve();
    while(solve()==0);
    // int t; cin >> t; for(;t>0;t--) solve();
    return 0;
}


Measured memory_bytes: 3080
using System;
using System.Collections.Generic;

namespace abc140_d
{
  class Program
  {
    static void Main(string[] args)
    {
      var n = CIn.ReadInt();
      var k = CIn.ReadInt();
      var s = CIn.Read().ToCharArray();

      var sum = 0;
      var lr = 0;
      var rl = 0;

      for (var i = 1; i < n; i++)
      {
        if (s[i - 1] == s[i])
        {
          sum++;
          continue;
        }

        if (s[i] == 'R')
        {
          lr++;
        }
        else
        {
          rl++;
        }
      }

      var min = Math.Min(k, Math.Min(lr, rl));
      var ans = sum + min * 2 + (min != k ? Math.Abs(lr - rl) : 0);

      Console.WriteLine(ans);
    }
  }

  class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }

      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
      var array = new string[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }

      return array;
    }

    public static int[] ReadIntArray(long n)
    {
      var array = new int[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }

      return array;
    }

    public static long[] ReadLongArray(long n)
    {
      var array = new long[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }

      return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
      var array = new double[n];

      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }

      return array;
    }
  }
}

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

int main()
{
    int ar[5], i;
    for(i=0; i<5; i++){
        scanf("%d",&ar[i]);
    }
    for(int j=0;j<5; j++){
        if(ar[j]==0){
            printf("%d\n",j+1);
        }
    }
    return 0;
}


Measured memory_bytes: 3816
N = int(input())
A = list(map(int,input().split()))
pre=0
ans = 0
while True:
  for i in range(N):
    if(A[i]/2)%1==0:
      pre+=1
  if pre == N:
      ans+=1
      A=[x/2 for x in A]
      pre =0
  else:
      print(ans)
      exit()
    

Measured memory_bytes: 9120
n = int(input())
li = []
for i in range(n):
    s,p = input().split()
    li.append([s,-int(p)])
b = sorted(li)
for i in range(n):
    for j in range(n):
        if b[i][0] == li[j][0] and b[i][1] == li[j][1]:
            print(j+1)


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

constexpr int IINF = INT_MAX;

bool solve(){
    int N, S;
    cin >> N >> S;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    int ans = IINF, sum = 0;
    for(int left=0,right=0; left<N; left++){
        while(right<N && sum<S){
            sum += A[right];
            right++;
        }
        if(sum>=S){
            ans = min(ans, right-left);
        }
        sum -= A[left];
    }
    cout << (ans < IINF ? ans : 0) << endl;
    return true;
}

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


Measured memory_bytes: 3156
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] c = sc.next().toCharArray();
        int[] a = new int[26];

        for(char cc : c) {
            a[cc-'a']++;
        }

        long res = 1;
        long div = 1000000007;

        for(int i=0; i<26; i++) {
            res *= a[i] + 1;
            res %= div;
        }
        res += div - 1;
        res %= div;

        System.out.println(res);

    }

}


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

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

  int cnt[n+1] = {0};
  for (int i=0; i<m; i++) {
    for (int j=0; j<2; j++) {
      int num;
      cin >> num;
      cnt[num]++;
    }
  }

  for (int i=1; i<=n; i++) {
    cout << cnt[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);
int main(){
    string s,t;cin>>s>>t;
    int n=s.length();
    int ans =0;
    rep(i,n){
        if(s[i]!=t[i])ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3820
N,M,X = map(int, input().split())
C = [0]*(N+1) #C[0]は使わない
A = [[0]*(M+1) for _ in range(N+1)]
for i in range(1,N+1):
    C[i], *A[i][1:] = map(int, input().split())

MAX = 10**5 * N + 1
minprice = MAX
for b in range(2**N):
    price = 0
    abilitylist = [0]*(M+1)
    for i in range(1,N+1):
        if b >> (i-1) & 1 == 1:
            price += C[i]
            abilitylist = [x + y for x,y in zip(abilitylist, A[i])]
    
    flag = True
    for ability in abilitylist[1:]:
        if ability < X:
            flag = False
            break
    
    if flag:
        minprice = min(minprice, price)

ans = minprice if minprice != MAX else -1
print(ans)

Measured memory_bytes: 9240
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a*b, c*d);
    return 0;
}

Measured memory_bytes: 256
// Lets go to the next level 
// AIM CM at CF *__* asap 
// Hit A,B,C and D faster and reach Candidate Master
// Remember you were also a novice when you started, 
// hence never be rude to anyone who wants to learn something
// Never open a ranklist untill and unless you are done with solving problems, wastes 3/4 minuts 
// Donot treat CP as a placement thing, love it and enjoy it, you will succeed for sure.  


#include <bits/stdc++.h>
using namespace std;
#define mod (int)1000000007
#define MOD (int)10000000007
// Big two primes 
#define X 1001100011100001111ll
#define M 26388279066623ll
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for0e(i, n) for (int i = 0; i <= n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long 
#define ll long long
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define in(x) scanf("%d", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define vi vector<int> 
#define F first
#define S second
#define pi pair<int, int>
#define ppi pair<pair<int,int> , int >
#define vii vector<pi>
const int MAXN = (int)((1e5) + 100);
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int N =  (int)(1e6+5); 


signed main(){
  fio;
    int n;
    string s;
    cin>>n>>s;

    if(n%2){
        cout<<"No"<<endl;
        return 0;
    }

    string t = s.substr(n/2);
    if(t+t == s){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
  rr;
}

Measured memory_bytes: 256
#pragma region template

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

#pragma region random

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T> T randint(T a, T b) {
    return uniform_int_distribution<T>(a, b)(rng);
}

#pragma endregion

#pragma region debug
string to_string(string s) { return '"' + s + '"'; }

string to_string(const char *s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B> string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A> string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first)
            res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

#pragma endregion

#pragma endregion

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

    string A;
    cin>>A;
    int n = A.size();
    vector<int> score(n,1);
    int curr = 0; // R=0 and L=1
    for(int i=1;i<n-1;i++)
    {
        if(A[i]=='R'&&curr==0)
        {
            score[i]+=score[i-1];
            score[i-1] = 0;
        }
        else if(A[i] == 'R')
        curr = 0;
        else
        curr = 1;
    }
    curr = 1;
    for(int i=A.size()-2;i>0;i--)
    {
        if(A[i]=='L'&&curr==1)
        {
            score[i]+=score[i+1];
            score[i+1] = 0;
        }
        else if(A[i]=='L')
        curr = 1;
        else
        curr = 0;
    }
    int l,r;
    for(int i=0;i<n;i++)
    {
        if(score[i]>0)
        {
            l = score[i]/2;
            r = score[i+1]/2;
            score[i] = score[i]-l+r;
            score[i+1] = score[i+1]-r+l;
            i++;
        }
    }

    for(int i:score)
    cout<<i<<" ";

    return 0;
}

Measured memory_bytes: 1104