akhauriyash/Code-Regression huggingface dataset:
s = raw_input()
n = int(raw_input())

for i in range(n):
    message = raw_input().split(" ")
    a, b = int(message[1]), int(message[2])

    if message[0] == "print":
        print(s[a:b+1])
    elif message[0] == "reverse":
        s = s[:a] + s[a:b+1][::-1] + s[b+1:]
    elif message[0] == "replace":
        s = s[:a] + message[3] + s[b+1:]

Measured memory_bytes: 6456
/// Kazuki Hoshino


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
//#define endl '\n'
typedef tree<
int,
null_type,less<int>,
rb_tree_tag,tree_order_statistics_node_update>
ordered_set;

int n,k,mx,gc,x;

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

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

cin >> n >> k;
for(int i=0;i<n;i++){
	cin >> x;
	gc = __gcd(gc,x);
	mx = max(mx,x);
}

if(k%gc==0&&k<=mx){
	cout << "POSSIBLE" << endl;
}
else {
	cout << "IMPOSSIBLE" << endl;
}




return 0;}
///....


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

ll pw(ll x, ll y, ll mod) {
    if (y == 0) return 1;
    else if (y == 1) return x % mod;
    else if (y % 2 == 0) {
        ll p = pw(x, y / 2, mod);
        return p * p % mod;
    }
    else {
        ll p = pw(x, y / 2, mod);
        return p * p % mod * x % mod;
    }
}

ll dv(ll x, ll y, ll mod) {
    x %= mod;
    y %= mod;
    return x * pw(y, mod - 2, mod) % mod;
}
 
ll comb(ll n, ll r, ll mod) {
    ll v = 1;
    if (n < r || n < 0 || r < 0) return 0;
    for (int i = 1; i <= r; i++) {
        v = v * dv(n - i + 1, i, mod) % mod;
    }
    return v;
}

ll val(ll a, ll b, ll c, ll k, ll mod) {
    ll v = 0;
    v += comb(a+b+c, k, mod);
    v += 2*comb(a+b+c, k-1, mod) - comb(a+c, k-1, mod);
    v += comb(a+b+c, k-2, mod);
    return (v + mod * mod) % mod;
}

int main() {
    int n;
    cin >> n;
    vector<int> x(n + 1), s[n];
    for (int i = 0; i <= n; i++) {
        cin >> x[i];
        x[i]--;
        s[x[i]].push_back(i);
    }
    int a, b, c;
    for (int i = 0; i < n; i++) {
        if (s[i].size() == 2) {
            a = s[i][0];  b = s[i][1] - s[i][0] - 1;
            c = n - s[i][1];
        }
    }
    cerr << a _ b _ c << endl;

    ll mod = 1e9 + 7;
    ll p = comb(a+b+c, 1, mod), q = comb(a+b+c, 0, mod);
    ll r = comb(a+c, 0, mod), t = comb(a+b+c, -1, mod);
    for (int k = 1; k <= n + 1; k++) {
        cout << (p+q*2-r+t+mod*mod)%mod << endl;
        p = p * dv(a+b+c-k, k + 1, mod) % mod;
        q = q * dv(a+b+c-k+1, k, mod) % mod;
        r = r * dv(a+c-k+1, k, mod) % mod;
        if (k <= 2) t = comb(a+b+c, k-1, mod);
        else t = t * dv(a+b+c-k+2, k - 1, mod) % mod;
    }
}


Measured memory_bytes: 7040
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >


int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
ll po(ll b,ll p){
    ll res=1;
    while(p){
        res*=b;
        p--;
    }
    return res;
}
ll lg2(ll x){
    ll res=0;
    while(x>1){
        res++;
        x/=2ll;
    }
    return res;
}
void solve(){
    ll x;
    cin>>x;
    ll lg=lg2(x);
    //cout<<lg<<endl;
    ll sum=0;
    while(lg>=0){
        sum+=(ll)po(2ll,lg);
        lg--;
    }
    cout<<sum<<endl;
}

signed main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("data.in","r",stdin);
        freopen ("data.out","w",stdout);
    #endif*/
    int t;
    t=1;
    while(t--){
        solve();
    }

     return 0;

}
///Alhamdulillah




Measured memory_bytes: 256
/**
 * File    : A.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-10-29 17:47:21
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main()
{
  string S;
  cin >> S;
  if ((int)S.size() == 2)
  {
    cout << S << endl;
  }
  else
  {
    reverse(S.begin(), S.end());
    cout << S << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (c >= a&&c <= b) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
	static void Main(string[] args)
	{
      // 整数の入力
      int len = int.Parse(Console.ReadLine());
      int[] x = new int[10];
      int[] y = new int[10];
      for (int i = 0; i < len; i++) {
		string[] input = Console.ReadLine().Split(' ');
		x[i] = int.Parse(input[0]);
		y[i] = int.Parse(input[1]);
      }

      double sum = 0.0;
      for (int i = 0; i < len; i++) {
        double dist = 0.0;
        for (int j = 0; j < len; j++) {
        	if (i == j) {
            	continue;
            }
          	dist += Math.Sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
        }
        sum += dist / len;
      }
		Console.WriteLine(sum);
	}
}

Measured memory_bytes: 11092
#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

long long f(long long n) {
    return n <= 0 ? 0 : n / 5 + f(n / 5);
}

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

    if (N % 2 != 0) {
        cout << 0 << '\n';
        return 0;
    }

    N /= 2;
    cout << f(N) << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long 
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mkp make_pair
  #define pb push_back
  #define inf INT_MAX

  int32_t main()
  { 
  
    #ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif
    IOS
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++)
    {
      if(s[i]=='7')
      {
        cout<<"Yes"; return 0;
      }
    }
    cout<<"No";
    return 0;
   
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n,s,m,M,ans;
	while(true){
		cin>>n;
		if(n==0){
			return 0;
		}
		m = 1005;
		M= -1;
		ans=0;
		for(int i=0;i<n;i++){
			cin>>s;
			m=min(m,s);
			M=max(M,s);
			ans+=s;
		}
		n-=2;
		ans=ans-M-m;
		ans /= n;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 2984
ans :: [Integer] -> [ Maybe Integer ]
ans [] = []
ans (x1:x2:xs) =
  let t = x1 + x2
      s = if t < (10 ^ 80)
          then Just t
          else Nothing
  in
    (s:ans xs)

toStr :: (Maybe Integer) -> String
toStr Nothing = "overflow"
toStr (Just a)  = show(a)

main = do
  c <- getContents
  let i = map read $ lines c :: [Integer]
      o = ans $ drop 1 i
  mapM_ (putStrLn . toStr) o

Measured memory_bytes: 4240
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

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

    string s;
    cin >> s;
    int al[26] = {};
    for( int i = 0; i < s.size(); ++i ) {
        ++al[s[i] - 'a'];

    }

    int pos = -1;
    for( int i = 0; i < 26; ++i ) {
        if( al[i] == 0 ) { pos = i; break; }

    }
    if( pos == -1 ) cout << "None";
    else cout << (char)('a' + pos);
    cout << endl;
    return 0;
}



Measured memory_bytes: 512
/*==============================================*\
ID:          shahidul_brur

Name:     Md. Shahidul Islam
Study:      CSE, BRUR
Address:  Rangpur, Bangladesh

 mail: shahidul.cse.brur@gmail.com
 FB  : fb.com/shahidul.brur
 Blog: shahidul-brur.blogspot.com(in Bengali),
       shahidul-brur-en.blogspot.com(in English)
\*===============================================*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define all(a)  a.begin(), a.end()
#define mem(a, b)     memset(a, b, sizeof(a))
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};

const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;
const int LOGN = 20;
int dp[21][1+(1<<21)], a[21][21],n;
int cal(int pos, int mask)
{
    if(pos==n){
        if(mask+1==(1<<n))
            return 1;
        return 0;
    }
    int &ret = dp[pos][mask];
    if(ret!=-1) return ret;
    ret = 0;
    f0(i,n) if(a[pos][i] && (mask & (1<<i))==0){
        ret+=cal(pos+1, (mask|(1<<i)));
        if(ret>MOD)
            ret-=MOD;
    }
    return ret;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>n;
    f0(i,n) f0(j,n) cin>>a[i][j];
    mem(dp, -1);
    cout << cal(0,0) << "\n";
    return 0;
}


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

#define ll long long

void solve(){
    
    ll n;cin>>n;
    string s;cin>>s;
    ll pre[n+1][128];
    ll suf[n+1][128];
    
    memset(pre,0,sizeof(pre));
    memset(suf,0,sizeof(suf));
    
    for(ll i=0;i<n;i++)
    {
        // change
        pre[i+1]['R'] = pre[i]['R'];
        pre[i+1]['G'] = pre[i]['G'];
        pre[i+1]['B'] = pre[i]['B'];
        //change
        pre[i+1][s[i]]++;
    }
    
    for(ll i=n-1;i>=0;i--)
    {
        // change
        suf[i]['R'] = suf[i+1]['R'];
        suf[i]['G'] = suf[i+1]['G'];
        suf[i]['B'] = suf[i+1]['B'];
        //change
        
        suf[i][s[i]]++;
    }
    ll ans = 0;
    for(ll i=0;i<n;i++){
        if(s[i]=='R'){
            ans += suf[i+1]['G']*pre[i+1]['B'];
            ans += suf[i+1]['B']*pre[i+1]['G'];
        }
        else if(s[i]=='G')
        {
            ans += suf[i+1]['R']*pre[i+1]['B'];
            ans += suf[i+1]['B']*pre[i+1]['R'];
        }
        else{
            ans += suf[i+1]['R']*pre[i+1]['G'];
            ans += suf[i+1]['G']*pre[i+1]['R'];
        }
    }
    
    for(ll i=0;i<n;i++){
        ll j = i-1;
        ll k = i+1;
        
        while(j>=0 and k<n){
            if(s[j]!=s[k] and s[j]!=s[i] and s[k]!=s[i])    ans--;
            j--;
            k++;
        }
        
    }
    cout<<ans<<endl;
    
    
    
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    // ll tc;cin>>tc;while(tc--)
    {
        solve();
    }
    
    
}

Measured memory_bytes: 11564
# B - Balance
N = int(input())
W = list(map(int, input().split()))
sum_l = 0
sum_r = sum(W)
abs_W =[]
for i in range(N):
    sum_l += W[i]
    sum_r -= W[i]
    abs_W.append(abs(sum_r - sum_l))

print(min(abs_W))

Measured memory_bytes: 38384
function Main(input) {
  var tmp = input.trim().split('\n')
  var M = tmp[0].split(' ')[1]
  var A = tmp[1].split(' ')

  var voteCount = 0

  for (var i = 0; i < A.length; i++) {
    voteCount += parseInt(A[i])
  }

  var limit = 1 / (4 * M) * voteCount

  var choiceNum = 0
  for (var j = 0; j < limit; j++) {
    if (parseInt(A[j]) >= limit) {
      choiceNum += 1
    }
  }

  var result = ''

  if (choiceNum >= M) {
    result = 'Yes'
  } else {
    result = 'No'
  }

  console.log(result)
  return result
}

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

Measured memory_bytes: 7372
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define MAX_N 103
#define MAX_V 10
#define MAX_M 101
#define min(a,b) (a>b?b:a)
#define max(a,b) (a>b?a:b)
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")
#define pro "はいプロ　世界一○○が上手　○○界のtourist　○○時代の終焉を告げる者　実質○○　○○するために生まれてきた男"

int temp[40][400100];
signed main(){
	cout<<fixed<<setprecision(7);
	int n, C, s, t, c;
	int ma = 0;
	
	cin>>n>>C;
	
	rep(i,n){
		cin>>s>>t>>c;
		// temp[s*2+1]++;
		// temp[t*2]--;
		// temp[s*4-2]++;
		// temp[t*4]--;
		// temp[s]++;
		// temp[t]--;
		temp[c][s*4-2]=1;
		temp[c][t*4] = -1;
	}
	
	for(int i = 1; i <= 400010; i++){
		int count = 0;
		for(int j = 1; j <= C; j++){
			temp[j][i] += temp[j][i-1];
			if(temp[j][i])count++;
		}
		ma = max(count,ma);
	}
	
	cout<<ma<<endl;
	
	return 0;
}

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

#define int long long
const int MOD = 1e9+7;

int mod_pow(int x, int n) {  
  int ret = 1;  
  while ( n > 0 ) {
    if ( n & 1 ) (ret *= x) %= MOD;
    (x *= x) %= MOD;    
    n >>= 1;
  }
  return (ret);  
}

int mod_inv(int x) {
  return (mod_pow(x, MOD-2));  
}

int dp[25001][2][401];

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

  vector<int> A(M);
  for ( int i = 0; i < M; i++ ) cin >> A[i];

  int all = N-M+1;
  // カラフルとは限らない、長さ N で、各要素が 1 以上 K 以下の整数列すべてについて、A を含む個数の総和
  for ( int i = 0; i < N-M; i++ ) (all *= K) %= MOD;

  bool colorful = false;
  {
    for ( int i = 0; i <= M-K; i++ ) {
      bool used[401] = {};
      for ( int j = 0; j < K; j++ ) {
	if ( used[A[i+j]] ) break;
	used[A[i+j]] = true;
	if ( j == K-1 ) colorful = true;	
      }
    }
  }

  if ( colorful ) {
    // Aがカラフルであった場合, allが解
    cout << all << endl;
    return 0;
  }

  bool distinct = true;
  {
    bool used[401] = {};
    for ( int i = 0; i < M; i++ ) {
      if ( used[A[i]] ) {
	distinct = false;
	break;
      }
      used[A[i]] = true;      
    }
  }

  int sub = 0;
  if ( distinct ) {
    dp[0][0][0] = 1;
    for ( int i = 0; i < N; i++ ) {
      for ( int j = 0; j < 2; j++ ) {
	// j : 1 すでにMを超えた
	int cum = 0; // 累積和を取ることでオーダーを減らす	
	for ( int k = K-1; k >= 0; k-- ) {
	  (dp[i+1][j][k+1] += dp[i][j][k]*(K-k)%MOD) %= MOD;
	  if ( !j && k+1 >= M ) (dp[i+1][1][k+1] += dp[i][j][k]*(K-k)%MOD) %= MOD;
	  if ( k ) {
	    cum += dp[i][j][k];
	    (dp[i+1][j][k] += cum) %= MOD;
	    if ( !j && k >= M ) (dp[i+1][1][k] += cum) %= MOD;	    
	  }
	}
      }
    }

    for ( int i = 1; i < K; i++ ) (sub += dp[N][1][i]) %= MOD;
    for ( int i = 0; i < M; i++ ) (sub *= mod_inv(K-i)) %= MOD;    
  } else {
    int l, r;
    {
      bool used[401] = {0};
      for ( l = 0; l < M; l++ ) {
	if ( used[A[l]] ) break;
	used[A[l]] = true;
      }
    }
    {
      bool used[401] = {0};
      for ( r = 0; r < M; r++ ) {
	if ( used[A[M-r-1]] ) break;
	used[A[M-r-1]] = true;
      }
    }

    dp[0][0][l] = dp[0][1][r] = 1;
    for ( int i = 0; i < N; i++ ) {
      for ( int j = 0; j < 2; j++ ) {
	int cum = 0; // 累積和を取ることでオーダーを減らす	
	for ( int k = K-1; k >= 0; k-- ) {
	  (dp[i+1][j][k+1] += dp[i][j][k]*(K-k)%MOD) %= MOD;
	  if ( k ) {
	    cum += dp[i][j][k];
	    (dp[i+1][j][k] += cum) %= MOD;
	  }
	}
      }
    }

    for ( int i = 0; i <= N-M; i++ ) {
      int sum_l = 0, sum_r = 0;
      for ( int j = 1; j < K; j++ ) {
	(sum_l += dp[i][0][j]) %= MOD;
	(sum_r += dp[N-M-i][1][j]) %= MOD;	
      }
      (sub += sum_l*sum_r%MOD) %= MOD;      
    }    
  }

  cout << (all+MOD-sub)%MOD << endl;
  
  return 0;
}


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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

int N;
ll A[200000];
map<ll, int> mp;

int main(){
  scanf("%d", &N);
  REP(N)scanf("%lld", &A[i]);
  ll sum = 0;
  ll ans = 0;
  mp[0]++;
  REP(N){
    sum+=A[i];
    ans+=mp[sum];
    mp[sum]++;
  }

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



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

int main(){
	int h,a;
	cin >> h >> a;
	
	int count = 0;
	while(h>0){
		h -= a;
		count++;
	}
	
	cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i, j;
	int n;
	double y;
	double r;
	int b, t;
	double m;
	double max;
	int ans;
	
	while (scanf("%d", &n), n != 0){
		scanf("%lf", &y);
		max = 0;
		for (i = 0; i < n; i++){
			scanf("%d %lf %d", &b, &r, &t);
			r /= 100;
			if (t == 1){
				m = 1 + (y * r);
//				printf("%lf\n", m);
			}
			if (t == 2){
				m = 1 + r;
//				printf("%lf\n", m);
				for (j = 0; j < y - 1; j++){
					m *= 1 + r;
//					printf("%lf\n", m);
				}
			}
			if (max < m){
				max = m;
				ans = b;
			}
		}
		printf("%d\n", ans);
	}
	return (0);
}

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

int main(int argc, char **argv) {
#ifdef LOCAL
  freopen("in.txt", "r", stdin);
#endif

  int n; cin >> n;
  vector<int> a(n);
  for(int i=0; i<n-1; i++) cin >> a[i];

  int res = 0;
  for(int i=0; i<n; i++) {
    if(i == 0) res += a[0];
    else if(i == n-1) res += a[n-2];
    else res += min(a[i], a[i-1]);
  }

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		int a=nextInt();
		int b=nextInt();
		int c=nextInt();
		int d=nextInt();
		for(int i=1;;i=i==1?2:1)
		{
			if(i==1)
			{
				c=c-b;
				if(c<=0)
				{
					out.println("Yes");
					return;
				}
			}
			else
			{
				a=a-d;
				if(a<=0)
				{
					out.println("No");
					return;
				}
			}
		}
	}

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

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 32736
def main():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    MOD = 10 ** 9 + 7
    sm1 = [0] * n
    sm2 = [0] * n
    for i in range(n):
        now = a[i]
        for j in range(i+1,n):
            if now > a[j]:
                sm1[i] += 1
    for i in range(n):
        now = a[i]
        for j in range(i):
            if now > a[j]:
                sm2[i] += 1
    a1 = sum(sm1) % MOD
    d = (sum(sm2) + a1) % MOD

    ans = k * (2*a1 + (k-1)*d)
    ans %= MOD
    inv_2 = power_func(2,MOD-2,MOD)
    ans = ans *inv_2
    print(ans%MOD)

def power_func(a,n,m):
  bi=str(format(n,"b"))#2進表現に
  ans=1
  for i in range(len(bi)):
    ans=(ans*ans) %m
    if bi[i]=="1":
      ans=(ans*a) %m
  return ans

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define f first
#define s second
#define mk make_pair
using namespace std;
typedef pair<int,int>P;
int main(){
  string s;
  cin>>s;
  r(i,s.size()){
    if(s[i]=='9'){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#00:45
import sys

sys.setrecursionlimit(10000000)


dx = [1, 0, -1, 0,-1,-1,1,1]
dy = [0, 1, 0, -1,-1,1,-1,1]



#左上からせめて深さ優先で探索する問題
while True:
    # 地図作る
    count = 0
    width,hight = map(int,input().split())
    if width ==0 :
        break
    d =[]
    for _ in range(hight):
        d.append(list(map(int,input().split())))
    
    def dfs(x, y):
    # いまたどり着いたはずなので1に塗りつぶす
        d[y][x]=0

    #4方向ループ
    #あくまで方向の表し方dxは
        for i in range(8):
            ny = y + dx[i]
            nx = x + dy[i]

        #行ったことがなくって、迷路の範囲内で、障害物がなければ、進む
            if 0 <= ny and ny < hight \
              and 0 <= nx and nx < width \
              and d[ny][nx] == 1:
                dfs(nx,ny) 

    

    for y in range(hight):
        for x in range(width):            
            if d[y][x] == 1:
                count = count + 1
                dfs(x,y)
    print(count)








Measured memory_bytes: 7948
N, M, X = map(int, input().split())
lst = []
for i in range(N):
    lst.append(list(map(int, input().split())))

cost = []
for i in range(2**N):
    cst = 0
    alg = [0 for _ in range(M)]
    Flg = True
    for j in range(N):
        if((i >> j) & 1):
            cst += lst[j][0]
            for k in range(1, M+1):
                alg[k-1] += lst[j][k]
    
    for a in alg:
        if(a < X):
            Flg = False
    if(Flg):
        cost.append(cst)
    
if(len(cost) > 0):
    print(min(cost))
else:
    print(-1)

Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a[200005],b[200005]={0};
ll ans=0;
int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        b[a[i]]++;
    }
    for(int i=1;i<=n;i++){
        ans+=b[i]*(b[i]-1)/2;
    }
    ll x;
    for(int i=1;i<=n;i++){
        x=ans-b[a[i]]*(b[a[i]]-1)/2+(b[a[i]]-1)*(b[a[i]]-2)/2;
        cout<<x<<"\n";
    }
    return 0;
}

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

int main(){
   while(true){
       int n;
       cin>>n;

       if(n==0) break;

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

        int cnt[26]={0};

        for (int i = 0; i < n; i++) {
            cnt[(int)(c[i]-'A')]++;
            int max1=-1;
            int max2=-1;

            for (int j = 0; j < 26; j++) {
                if(cnt[j]>max1){
                    max2=max1;
                    max1=cnt[j];
                }
                else if(cnt[j]>max2){
                    max2=cnt[j];
                }
            }

            if(max1-max2>n-(i+1)){
                for (int j = 0; j < 26; j++) {
                    if(cnt[j]==max1){
                        cout<<(char)(j+'A')<<' ';
                        break;
                    }
                }
                cout<<(i+1)<<endl;
                break;
            }

            if(i==n-1){
                    cout<<"TIE"<<endl;
                    break;
            }
        }
    }
    return 0;
}



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

int main() {
    ll N;
    cin >> N;
    vector<int> P(N);
    rep(i,N) cin >> P.at(i);
    int minimum = P.at(0);
    int ans = 0;
    rep(i,N) {
        if (P.at(i) <= minimum) ++ans;
        minimum = min(minimum, P.at(i));
    }
    cout << ans << endl;
}


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

#define vi vector<int>
#define all(v) v.begin(),v.end()
#define ll long long int
#define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll MOD=1e9+7;

void solve(){
   ll a,b,c;
   cin >> a >> b >> c;

   ll ans = b/c - a/c;
   if(a%c==0)ans++;
   cout << ans;
}


int main(){
  IOS
     solve();
}
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid


Measured memory_bytes: 256
#include <bits/stdc++.h>  
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
#define REP(i, a, op1, n, op2) for(int i=a; i op1 (int)(n); op2 ## op2 i)
#define cout(val) cout << (val) << endl

using namespace std;  

int main(){
    int d, g, sum, count, min=1001;
    cin >> d >> g;
    vector<int> p(d);
    vector<int> c(d);
    rep(i, d){
        cin >> p[i] >> c[i];
    }

    rep(i, 1<<d){
        sum = 0;
        count = 0;
        rep(j, d){
            if(i&1<<j){
                sum += 100 * (j+1) * p[j] + c[j];
                count += p[j];
            }
        }
        if(sum < g){
            for(int j=d-1; j>=0; j--){
                if(sum >= g) break;
                if(i&1<<j) continue;
                rep(k, p[j]){
                    sum += 100 * (j+1);
                    count++;
                    if(k-1 == p[j]) sum += c[j];
                    if(sum >= g) break;
                }
            }
        }
        if(min > count){
            min = count;
        }
    }
    cout(min);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N;
  long long int cnt=0;
  cin >> N;
  long long int A[N+1], B[N];
  for(int i=0; i<N+1; i++) cin >> A[i];
  for(int i=0; i<N; i++) cin >> B[i];
  for(int i=0; i<N; i++){
    if(A[i] >= B[i]){
      cnt += B[i];
      B[i] = 0;
    }else{
      cnt += A[i];
      B[i] -= A[i];
    }

    if(A[i+1] >= B[i]){
      cnt += B[i];
      A[i+1] -= B[i];
    }else{
      cnt += A[i+1];
      A[i+1] = 0;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<string.h>
using namespace std;
#define ull unsigned long long int
#define ll long long int

int main(){
    int t,k;
    cin>>t>>k;
    string s;
    cin>>s;
    s[k-1] = s[k-1] + 32;
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AOZ
{
	class MainClass
	{
		static void Main(string[] args)
		{
			var input_arr = Console.ReadLine().Split(' ');
			int a = int.Parse(input_arr[0]); int b = int.Parse(input_arr[1]); int c = int.Parse(input_arr[2]);
			int cnt = 0;
			for (int i = a; i <= b; i++)
			{
				if (c % i == 0) cnt++;
			}
			Console.WriteLine(cnt);
		}
	}
}



Measured memory_bytes: 17976
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

ll dp[55][55][2505];

int main(void) {
  int i,j,k;
  int n,a;
  cin>>n>>a;
  vi x(n);
  rep(i,n)cin>>x[i];

  dp[1][0][0]=1;
  dp[1][1][x[0]]=1;

  for(i=2;i<=n;i++){
    rep(j,i)rep(k,50*j+1)
      if(dp[i-1][j][k]>0){
	dp[i][j][k]+=dp[i-1][j][k];
	dp[i][j+1][k+x[i-1]]+=dp[i-1][j][k];
      }
  }
  ll ans=0;
  for(i=1;i<=n && i*a<2505;i++)
    if(dp[n][i][i*a]>0)ans+=dp[n][i][i*a];
  cout<<ans<<endl;
}



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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

int main(){
	int a,b;
	cin >> a >> b;
	cout << (((a*b)%2)?"Yes":"No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <set>
using namespace std;
int main()
{
  set<int> nums;
  int n;
  for (int i=1; i<=9; ++i)
    for(int j=1; j<=9; ++j)
     nums.insert(i*j);
  
  scanf("%d",&n);
  
  if (nums.find(n) == nums.end())
   printf("No\n");
  else
    printf("Yes\n");
  
  return 0;
}


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

int values[1001];
int diff[1001];

int main() {
	
	int v = 1;
	int n = 2;
	values[0] = 1;
	for(int i = 1; i < 1000; i++) {
		
		v = v + n;
		values[i] = v;	
		n++;

	}

	for(int i = 0; i < 1000; i++) {
		diff[i] = abs(values[i+1] - values[i]);
	}

	int n1, n2, index;
	cin >> n1 >> n2;

	int diff1 = n2 - n1;

	for(int i = 0; i < 1000; i++) {
		if(diff1 == diff[i]) {
			index = i;
			break;
		}
	}

	cout << values[index] - n1 << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

# 整数の入力
a = int(input())
# スペース区切りの文字列の入力
st = input().split()
st_list = []
st_list = [int(st) for st in st]

num = 0
flg = 0
for num in range(len(st_list)):
  if(st_list[num] % 2 == 0):
    if(st_list[num] % 5 != 0 and st_list[num] % 3 != 0):
      flg = 1
if(flg == 0):
  print("APPROVED")
else:
  print("DENIED")




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

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

    int ans = 1, order = 0;
    for (int i = 1; i < n; i++) {
        if (order == 0) {
            if (arr[i-1] < arr[i]) order = 1;
            else if (arr[i-1] > arr[i]) order = 2;
            else order = 0;
        } else if ((order == 1 && arr[i-1] <= arr[i]) || (order == 2 && arr[i-1] >= arr[i])) {
            continue;
        } else {
            ans++;
            order = 0;
        }
    }
    cout << ans << '\n';
}


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

int main(){
  string S;
  cin >> S;
  long long sum=0;
  for(int i=0;i<S.size();i++){
    int A=S.at(i)-'0';
    sum+=A;
  }
  if(sum%9==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3720
import collections
N,M=map(int,input().split())

counter=collections.defaultdict(int)
for _ in range(N):
  text = list(input().split())
  for x in text[1:]:
    counter[x]+=1
ans=0
for x in counter:
  if counter[x]== N:
    ans+=1
print(ans)

Measured memory_bytes: 3316
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N; i64 A[101010], B[101010];

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%lld%lld", A + i, B + i);

	vector<pair<i64, i64>> st;
	for (int i = 0; i < N; ++i) st.push_back({A[i] + B[i], A[i]});
	sort(st.begin(), st.end());
	reverse(st.begin(), st.end());

	i64 ret = 0;
	for (int i = 0; i < N; ++i) {
		if (i % 2 == 0) ret += st[i].second;
		else ret += st[i].second - st[i].first;
	}
	printf("%lld\n",  ret);

	return 0;
}


Measured memory_bytes: 3956
/*
 * Created By : pash123
 * 2020-08-23-18.46
*/


#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

const int M=1e9+7;

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

    int dp[n]={INT_MAX};  // dp[i] means min. cost to reach stone i.
    dp[0]=0;

    for(int i=1;i<n;++i)
    {
        int ans=INT_MAX;
        for(int j=1;j<=k && (i-j)>=0;++j)
            ans=min(ans,dp[i-j]+abs(h[i]-h[i-j]));
        dp[i]=ans;
    }

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


Measured memory_bytes: 4380
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <vector>

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

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define TRUE (0)
#define FALSE (1)

// This value shold be close to used maximum value.  
#define NUM_MAX 20000000005

// void sort(uint32_t *num, uint32_t size);

int main()
{
    vector<vector<uint64_t>> arr(0);
    vector<uint64_t> temp_vec(0);
    vector<uint64_t> num_vec(0), red_vec(0), green_vec(0), white_vec(0);
    // string result;
    // vector<long long> res_vec(0);
    // uint64_t res_arr[NUM_MAX];
    // uint32_t sum = 0;
    uint64_t num1, white;
    uint64_t num, result2;
    // uint64_t result;
    double length, mass, result;

    // uint32_t res_i = 0;
    // string str_temp, str_temp2;
    int64_t temp, temp2, temp3;
    int64_t i, j, k, l, count, n, x, y, o, size, a, b, c;
    // uint32_t count = 0;
    // string str;
    // uint8_t k_flag;
    
    cin >> count >> j;
    for (k = 0; k < j; k++) {
        cin >> temp;
        count -= temp;
    }

    if (count >= 0) {
        cout << count << endl;
    } else {
        cout << "-1" << endl;
    }

    return 0;
}

// void sort(uint32_t *num, uint32_t size) {
//     uint32_t i, j, k;
//     uint32_t sorted_num;
//     uint32_t array[NUM_MAX] = {0};

//     for (i = 1; i < size + 1; i++) {
//         array[num[i - 1]]++;
//     }

//     sorted_num = 0;

//     for (i = 0; i < NUM_MAX; i++) {
//         for (j = 0; j < array[i]; j++) {
//             num[j + sorted_num] = i;
//         }
//         sorted_num += j;
//         j = 0;
//     }

//     return;
// }


Measured memory_bytes: 3612
mod = 10**9+7
s=int(input())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

t = 0
ans = 0
while(True):
    a = t*3
    b = s - a
    if(b < 0):
        break
    ans = (ans + cmb(b+t-1,b,mod))%mod
    t += 1

print(ans)

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

int main(){
    string S;
    cin >> S;
    if(S.at(5) == '0' && (S.at(6) == '1'|| S.at(6) == '2'||S.at(6) == '3'||S.at(6) == '4')){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;

class Program
{
	//Main
	static void Main(string[] args)
	{
		//読み込む
		ulong X = ulong.Parse(Console.ReadLine());

		ulong current = 100;
		ulong cnt = 0;

		while(current < X){
				current += (current/100);
				cnt ++;
		}

		Console.WriteLine(cnt);

	}
}



Measured memory_bytes: 17560
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);


    int t;
    cin >> t;
    while (t-- > 0) {
        int n;
        cin >> n;
        vector<int> K(n);
        vector<int> L(n);
        vector<int> R(n);
        for (int i = 0; i < n; ++i) {
            cin >> K[i] >> L[i] >> R[i];
        }


        vector<pair<int,int>> A;
        vector<pair<int,int>> B;

        long long res = 0;
        for (int i = 0; i < n; ++i) {
            if (L[i] < R[i]) {
                res += L[i];
                A.emplace_back(n - K[i], R[i] - L[i]);
            } else if (L[i] > R[i]) {
                res += R[i];
                B.emplace_back(K[i], L[i] - R[i]);
            } else {
                res += L[i];
            }
        }

        auto calc = [&](vector<pair<int,int>>& A) {
            auto cmp = [&](const pair<int,int>& l, const pair<int,int>& r) {
                if (l.first == r.first) {
                    return l.second > r.second;
                }
                return l.first < r.first;
            };
            sort(A.begin(), A.end(), cmp);

            priority_queue<int, vector<int>, greater<int>> pq;
            long long res = 0;
            for (auto& p : A) {
                int k = p.first;
                int v = p.second;
                pq.push(v);
                while (pq.size() > k) {
                    pq.pop();
                }
            }

            while (!pq.empty()) {
                res += pq.top();
                pq.pop();
            }
            return res;
        };

        res += calc(A);
        res += calc(B);

        cout << res << '\n';

    }

    return 0;
}

Measured memory_bytes: 7896
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define f first 
# define s second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define pqueue priority_queue

using namespace std;

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

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

const int mod=1e9+7,N=1e6+3;



void solve(){	
	string s;
	cin>>s;
	ll k;
	cin>>k;
	for(ll i=0;i<sz(s);++i){
		if(i+1==k){
			cout<<s[i];
			return;
		}
		if(s[i]!='1'){
			cout<<s[i];
			return;
		}
	}


}

int main(){
 	ios_base::sync_with_stdio(0);
 	cin.tie(0);cout.tie(0);
	int T=1; 
	//cin>>T;	
	while(T--)solve();
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		long lcm = c * d / gcd(c , d);

		long u = b - a + 1;
		long cs = b / c - (a - 1) / c;
		long ds = b / d - (a - 1) / d;
		long lcms = b / lcm - (a - 1) / lcm;
		sc.close();
		System.out.println(u - cs - ds + lcms);

	}
	public static long gcd(long num1,long num2) {
        if(num2 == 0) return num1;
        else return gcd(num2 , num1 % num2 );
 }
}



Measured memory_bytes: 35708
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	int ans = a[n - 1];
	int ans1 = -1;
	int best = 1e9;
	rep(i, n - 1){
		int diff = abs(a[i] - (ans - a[i]));
		if(diff < best) best = diff, ans1 = a[i];
	}
	cout << ans << " " << ans1 << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 640
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int comp(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return (*(int*)a<*(int*)b)-(*(int*)a>*(int*)b);}

#define putchar(c) putc_unlocked((c), stdout);
uint32_t nextpint(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint64_t nextplong(void){ char c=getc_unlocked(stdin); while(c<'0'||'9'<c) c=getc_unlocked(stdin); uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getc_unlocked(stdin); } return x; }
uint32_t nextstr(char *s){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getc_unlocked(stdin); } *s='\0'; return len; }
uint32_t nextstrln(char *s){ char c=getc_unlocked(stdin); while(c==' '||c=='\n') c=getc_unlocked(stdin); uint32_t len=0; while(c!='\n'){ *s++=c; len++; c=getc_unlocked(stdin); } *s='\0'; return len; }

void printint(int x){ if(x<0){x=-x; putc_unlocked('-', stdout);}else if(x==0){putc_unlocked('0', stdout);} int d=0; char s[10]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putc_unlocked(s[i], stdout); putc_unlocked('\n', stdout); }
void printlong(long x){ if(x<0){x=-x; putc_unlocked('-', stdout);}else if(x==0){putc_unlocked('0', stdout);} int d=0; char s[20]; while(x){ s[d]='0'+x%10; x/=10; d++; } for (int i=d-1; i>=0; i--) putc_unlocked(s[i], stdout); }

inline int max2(const int a, const int b){return a>b?a:b;}
inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}
inline int abs2(const int a){return a>=0?a:-a;}

char s[200001];
int l[200001];
int r[200001];
int main(void){
	int n=nextpint();
	int k=nextpint();
	int c=nextpint();
	nextstr(s);
	int h=0;
	for(int i=0; i<n; i++){
		if(s[i]=='o'){
			h++;
			l[h]=i;
			i+=c;
		}
	}
	h=0;
	for(int i=n-1; i>=0; i--){
		if(s[i]=='o'){
			h++;
			r[h]=i;
			i-=c;
		}
	}
	for(int i=max2(1,k-h+1), j=min2(h,k); i<=j; i++){
		if(l[i]==r[k-i+1]){
			printint(l[i]+1);
		}
	}
}



Measured memory_bytes: 3200
n=input()
s=raw_input()

if s.count('W')==0 or s.count('R')==0:
    print 0
    exit(0)
ans=-1
for i in xrange(n-1, -1, -1):
    if s[i]=='R':
        ans=s[:i].count('W')
        break
w=[]
r=[]
for i in xrange(n):
    if s[i]=='W':
        w.append(i)
for i in xrange(n-1,-1,-1):
    if s[i]=='R':
        r.append(i)

for i in xrange(min(len(w), len(r))):
    if w[i]>r[i]:
        ans=min(ans, i)

print ans

Measured memory_bytes: 84396