akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  int a=m-n+1;
  n*=2;
  n--;
  while(n){
    n--;
    cout<<a;
    if(n!=0) cout<<" ";
    a++;
  }
  cout<<endl;

  return 0;
}


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

const int MAXN = 2020;
int nodeDep[MAXN];
int _size[MAXN];
long long all[MAXN];
long long dp[MAXN];
vector <int> adj[MAXN];
char A[MAXN];
long long ans = -1;
int n;

void getAns(int u, int fa) {
	int maxSon = -1;
	_size[u] = A[u] - '0',
	all[u] = 0;
	
	for (int v : adj[u]) {
		if (v == fa)
			continue;
		getAns(v, u),
		_size[u] += _size[v];
		all[u] += (all[v] += _size[v]);
		if (!~maxSon || all[maxSon] < all[v])
			maxSon = v;
	}
	
	if (!~maxSon)
		return void(dp[u] = 0);
	if (all[u] >= (all[maxSon]<<1))
		dp[u] = all[u] >> 1;
	else
		dp[u] = all[u] - all[maxSon] + (min((all[maxSon]<<1) - all[u], dp[maxSon] << 1) >> 1);
}

int main(void) {
	ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
	
	cin >> n;
	cin >> (A + 1);
	for (int i = 1, u = 0, v = 0;i < n; ++i) {
		cin >> u >> v;
		adj[u].push_back(v), adj[v].push_back(u);
	}
	
	for (int i = 1;i <= n; ++i) {
		getAns(i, 0);
		if (dp[i] * 2 == all[i])
			ans = (!~ans || ans > dp[i]) ? dp[i] : ans;
	}
	
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3944
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n;
   string s;
   cin >> s;
   int count =0,a=0;
   for (int i=0;i<s.length()-1;i++)
   {
       if (s[i]==s[i+1])
       {
           if(s[i]=='0')
           {
               s[i+1]='1';
               count ++;
           }
           else
           {
               s[i+1]='0';
               count ++;
           }

       }
       else
       {
        count+=a;
       }
   }
   cout << count << endl;

    return 0;
}





Measured memory_bytes: 512
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};


int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  ll t;cin>>t;
  vl a(t),b(t),c(t),d(t);
  rep(i,t)cin>>a[i]>>b[i]>>c[i]>>d[i];
  rep(i,t){
    if(a[i]<b[i]||d[i]<b[i]){
      cout<<"No"<<endl;
      continue;
    }
    ll g=__gcd(b[i],d[i]);
    if(a[i]%g==c[i]%g){
      if(c[i]+g>=b[i]){
        cout<<"Yes"<<endl;
      }
      else {
        cout<<"No"<<endl;
      }
    }
    else {
      ll key=((a[i]%g+g)-c[i]%g)%g+c[i];
      if(key>=b[i]){
        cout<<"Yes"<<endl;
      }
      else {
        cout<<"No"<<endl;
      }
    }
  }
}
    
  

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    A = [int(a) for a in input().split()]

    prefix = [0]
    for i in range(N):
        v = prefix[-1]+A[i]
        prefix.append(v % M)

    d = dict()
    for a in prefix:
        d[a] = d.get(a, 0) + 1

    ans = 0
    for a in d:
        ans += d[a] * (d[a]-1) //2
    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 63256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <functional>
#pragma warning(disable : 4996)

using namespace std;

void solve_case();

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

	solve_case();

	return 0;
}

void solve_case() {
	int n, m, k, ans = 0, like[31] = { 0, }, food;

	cin >> n >> m;

	for (int i = 0; i < n; i++) {
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> food;
			like[food] ++;
		}
	}

	for (int i = 1; i <= m; i++) {
		if (like[i] == n)
			ans++;
	}

	cout << ans << "\n";
}

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

int main(){
    int *A, *B;
    int VMAX = 10000;
    int MAX = 2000001;
    vector<int> C(VMAX+1);
    int n;
    cin >> n;
    A = new int[n+1];  
    B = new int[n+1];    
    for (int i = 0; i <= VMAX; i++) C[i] = 0;
    for (int i = 0; i < n; i++){
        cin >> A[i+1];
        C[A[i+1]]++;
    }
    for (int i = 1; i <= VMAX; i++) C[i] = C[i] + C[i-1];
    for (int j = 1; j <= n; j++) {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }
    
    for (int i = 1; i <= n; i++){
        if (i > 1)  cout << " ";
        cout << B[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 18676
#include <stdio.h>


int main(void) {
    char tile[100][101];
    int H, W, visited[100][100];
    int i, j, x, y;

    while (scanf("%d%d", &H, &W) == 2 && H) {
        for (i = 0; i < H; i++) {
            scanf("%s", tile[i]);
            for (j = 0; j < W; j++) {
                visited[i][j] = 0;
            }
        }
        x = y = 0;
        while (1) {
            if (tile[y][x] == '.') {
                printf("%d %d\n", x, y);
                break;
            }
            else if (visited[y][x]) {
                puts("LOOP");
                break;
            }
            visited[y][x] = 1;
            switch (tile[y][x]) {
                case '>': x++; break;
                case '<': x--; break;
                case '^': y--; break;
                case 'v': y++; break;
                default: break;
            }
        }
    }
    return 0;
}

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

char buf[100];
char mot[100];
int cnt;
int N;

int calc_n(int a){
  if( a == 0 ) return 2;
  else if( a == 1 ) return 1;
  else return 0;
}

int calc_x(int a,int b){
  if( a==0 || b==0 ) return 0;
  if( a==1 || b==1 ) return 1;
  return 2;
}

int calc_p(int a,int b){
  if( a==2 || b==2 ) return 2;
  if( a==1 || b==1 ) return 1;
  return 0;
}

int formula(){
  // cout << cnt << " " << buf[cnt] << endl;
  if( buf[cnt] == '-' ){
    cnt++;
    return calc_n(formula());
  } else if( buf[cnt] == '(' ){
    cnt++;
    int a = formula();
    if( buf[cnt] == '*' ) {
      cnt++;
      int b = formula();
      cnt++;
      // cout << "calc_x(" << a << " , " << b << ") = " << calc_x(a,b) << endl;
      return calc_x(a,b);
    } else {
      cnt++;
      int b = formula();
      cnt++;
      //cout << "calc_p(" << a << " , " << b << ") = " << calc_p(a,b) << endl;
      return calc_p(a,b);
    }
  } else {
    return buf[cnt++]-'0';
  }
}

int main(){
  while( cin >> buf ){
    if( buf[0] == '.' ) break;
    N = strlen(buf);
    for(int i=0;i<N;i++) mot[i] = buf[i];
    int res = 0;

    for(int p=0;p<3;p++){
      for(int q=0;q<3;q++){
	for(int r=0;r<3;r++){
	  for(int i=0;i<=N;i++){
	    if( mot[i] == 'P' ) buf[i] = p+'0';
	    else if (mot[i] == 'Q' ) buf[i] = q+'0';
	    else if (mot[i] == 'R' ) buf[i] = r+'0';
	    else buf[i] = mot[i];
	  }
	  cnt = 0;
	  if( formula() == 2 ){
	    res++;
	    //	    cout << buf << endl;
	    //cout << cnt << " " << N <<endl;
	  }
	}
      }
    }
    cout << res << endl;

  }

}

Measured memory_bytes: 1140
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

int main(){
  int n; cin >> n;
  int sum = 0;
  int x = n;
  while(x > 0){
    sum = sum + (x %10);
    x = x/10;
  }
  if(n %sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int h, w, num[26];
char s[110];
int main(void) {
    while(~scanf("%d%d", &h, &w)) {
        memset(num, 0, 26 << 2);
        for(int i = 0; i < h; ++i) {
            scanf("%s", s);
            for(int j = 0; j < w; ++j)
                num[s[j] - 'a']++;
        }
        int c4 = (h >> 1) * (w >> 1);
        int c2 = (h & 1) * (w >> 1) + (w & 1) * (h >> 1);
        int c1 = (h & 1) * (w & 1);
        for(int i = 0; c4 && i < 26; ) {
            if(num[i] >= 4) { c4--, num[i] -= 4; }
            else i++;
        }
        for(int i = 0; c2 && i < 26; ) {
            if(num[i] >= 2) { c2--, num[i] -= 2; }
            else i++;
        }
        for(int i = 0; c1 && i < 26; ) {
            if(num[i] >= 1) { c1--, num[i] -= 1; }
            else i++;
        }
        puts(c1 + c2 + c4 ? "No" : "Yes");
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main() {
	int i;
	char S[101];
	scanf("%s", S);

	for (i = 0; S[i] != EOF; i++) {
		if (i % 2 == 0 && S[i] == 'L') {
			printf("No");
			return 0;
		} else if (i % 2 == 1 && S[i] == 'R') {
			printf("No");
			return 0;
		}
	}

	printf("Yes");

	return 0;
}

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







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

int main(){
    int N,X;
    cin>>N>>X;
    vector<int> L(N);

    int cnt = 1;
    rep(i,N){cin>>L[i];}

    int res = 0;
    for(int i=0;i<N;i++){
        res += L[i];
        if(res>X){
            break;
        }
        cnt++;
    }
    cout<<cnt;
}

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


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

    int cou=0;
    int N;
    cin >> N;
    int a[N];
    int B[9];
    rep(i,9) B[i]=0;
    rep(i,N) cin >> a[i];
    rep(i,N){
        int y=a[i]/400;
        int x=min(y,8);
        B[x]++;
    }
    rep(i,8){
        if(B[i]>0) cou++;
    }
    int ans=max(1,cou);
    cout << ans <<endl;
    ans=cou+B[8];
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <iomanip>

const int MAX_N = 300;

int n;
double f[MAX_N + 1][MAX_N + 1][MAX_N + 1];

double dp(int b, int c, int d) {
  if (b < 0 || c < 0 || d < 0 || b > n || c > n || d > n) return 0;
  double &ret = f[b][c][d];
  if (ret >= 0) return ret;
  const double s = b + c + d;
  return ret = n / s + b / s * dp(b - 1, c, d) + c / s * dp(b + 1, c - 1, d) +
               d / s * dp(b, c + 1, d - 1);
}

int main() {
  std::cin >> n;
  memset(f, -0x3f, sizeof(f));
  f[0][0][0] = 0;
  int cnt[4]{};
  for (int i = 0, v; i < n; ++i) {
    std::cin >> v;
    cnt[v]++;
  }
  std::cout << std::fixed << std::setprecision(12)
            << dp(cnt[1], cnt[2], cnt[3]);
  return 0;
}

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


int main(){
  int N; cin>>N;
  int check=0;
  if(N%4==0||N%7==0){  check=1;
                    }else{
   for(int i=7;i<100;i+=7){
      if((N-i)%4==0&&N-i>0){
        check=1;
        break;
        }
     }
  }
    if(check==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int h,n,a[1001],b[1001],dp[10001],ans=1e9;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>h>>n;
	for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
	for(int i=1;i<=h;i++) dp[i]=1e9;
	for(int i=0;i<=h;i++)
		for(int j=1;j<=n;j++){
			if(i+a[j]>=h){ ans=min(ans,dp[i]+b[j]); continue; }
			dp[i+a[j]]=min(dp[i+a[j]],dp[i]+b[j]);
		}
	cout<<ans;
}

Measured memory_bytes: 256
### subroutines

def roll_n(d)
  [7 - d[1], d[0], d[2]]
end

def roll_s(d)
  [d[1], 7 - d[0], d[2]]
end

def roll_e(d)
  [d[2], d[1], 7 - d[0]]
end

def roll_w(d)
  [7 - d[2], d[1], d[0]]
end

### main

loop do
  n = gets.to_i
  break if n == 0

  d = [1, 2, 3]

  n.times do
    cmd = gets.strip
    case cmd
    when 'north'
      d = roll_n(d)
    when 'south'
      d = roll_s(d)
    when 'east'
      d = roll_e(d)
    when 'west'
      d = roll_w(d)
    end
  end

  puts d[0]
end

Measured memory_bytes: 6100
#include <stdio.h>

int main(void){

	int i=1,x,n;

	scanf("%d",&n);

	for(;;){

		x=i;

		if(x%3==0){
			printf(" %d",i);
		}

		else { 	
			for(;;){
				if(x%10==3){
					printf(" %d",i);
					break;
				}

				else{
					x /= 10;
					if(!x){
						break;
					}
				}
			}
		}
		if(++i > n){
			break;
		}

	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
# 解説を見た
# コメントに嘘ばかり書いたので、訂正

def main():
    S_MAX = 10 ** 9

    n, k, s = map(int, input().split())
    fill = (1) if (s == S_MAX) else (s + 1)
    # fill=1でよい理由は、N項すべて1でも、1の区間和がS_MAXに達しないため
    # fillがsと互いに素であれば、fillを何倍してもsにならない(正しいはず)ので、
    # s==S_MAXのとき、sは偶数であることに注目して、fillを奇数にしてもよい
    # (わけはなく、奇数でもS_MAXの素因数になっている5はダメ, 5のp倍は10**qになりえる)
    # 素因数を列挙して、総積から互いに素な値を作るのは正しいはず...

    ret = [s] * k + [fill] * (n - k)
    print(*ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 6524
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for l in range(0, a+1):
    for m in range(0, b+1):
        for n in range(0, c+1):
            if(500*l+100*m+50*n == x):
                count+=1
print(count)


Measured memory_bytes: 3060
n=int(input())
DP=[0 for _ in range(n+1)]

for i in range(1,n+1):
    for j in range(i,n+1,i):
        DP[j] +=1

cnt=0
for i in range(1,n+1):
    cnt +=i*DP[i]
print(cnt)

Measured memory_bytes: 219180
fn read_number() -> Result<usize, String> {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    let n = try!(line.trim().parse::<usize>().map_err(|err| err.to_string()));
    Ok(n)
}

fn read_number_each_line(n: usize) -> Result<Vec<i32>, String> {
    (0..n)
        .map(|_| read_number().map(|x| x as i32))
        .collect::<Result<Vec<i32>, String>>()
}

fn read_numbers() -> Result<Vec<i32>, String> {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    let numbers = line.split_whitespace()
        .map(|x| x.parse::<i32>().ok().unwrap())
        .collect();
    Ok(numbers)
}

fn gcd(x: u32, y: u32) -> u32 {
    if x == y {
        x
    } else {
        let (x, y) = if x < y { (y, x) } else { (x, y) };

        if x % y != 0 {
            gcd(y, x % y)
        } else {
            y
        }
    }
}

fn main() {
    match read_numbers() {
        Ok(numbers) => println!("{:?}", gcd(numbers[0] as u32, numbers[1] as u32)),
        Err(err) => panic!("{:?}", err),
    }
}



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

using namespace std;
int arr[4];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;

    cout<<a[k-1];

    return 0;
}


Measured memory_bytes: 256
# 入力
N = int(input())
A = list(map(int, input().split()))

# 正-負をなるべく多く達成するように操作する
P = sorted((a for a in A if a >= 0), reverse=True)
Q = sorted(a for a in A if a < 0)

x, y = [], []
if len(P) == 2 and not Q:
    Y, X = P.pop(), P.pop()
    x.append(X)
    y.append(Y)
    P.append(X - Y)
if len(P) >= 3 and not Q:
    X, Y = P.pop(), P.pop()
    x.append(X)
    y.append(Y)
    Q.append(X - Y)
if not P and len(Q) >= 2:
    X, Y = Q.pop(), Q.pop()
    x.append(X)
    y.append(Y)
    P.append(X - Y)
while len(P) >= 2 and Q:
    X, Y = Q.pop(), P.pop()
    x.append(X)
    y.append(Y)
    Q.append(X - Y)
while Q:
    X, Y = P.pop(), Q.pop()
    x.append(X)
    y.append(Y)
    P.append(X - Y)

ans = (
    '{}\n{}'.format(
        P[0],
        '\n'.join(
            '{} {}'.format(X, Y)
            for X, Y in zip(x, y)
        )
    )
)

# 出力
print(ans)


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

int main() {
    int n, x;
    cin >> n >> x;
    int a[n];
    for (int i = 0; cin >> a[i]; i++) {
    }
    long long result = 0;
    for (int i = 1; i < n; i++) {
        int t = max(0, a[i] + a[i - 1] - x);
        result += t;
        a[i] -= min(t, a[i]);
    }
    cout << result;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<numeric>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const ll MOD = 1000000007;
 
using namespace std;

void solve(int N){
    vector<int> dp(100001,1000000);
    dp[0] = 0;
    dp[1] = 1;
    int tmp;
    for(int i=2; i<100001; i++){
        tmp = 1;
        for(int j=0; j<6; j++){
            if(tmp <= i)    dp[i] = min(dp[i], dp[i-tmp]+1);
            tmp *= 9;
        }
        tmp = 1;
        for(int j=0; j<9; j++){
            tmp *= 6;
            if(tmp <= i)    dp[i] = min(dp[i], dp[i-tmp]+1);
        }
    }
    cout << dp[N] << endl;
}

int main(){
    int N;  cin >> N;
    solve(N);
    return 0;
}

Measured memory_bytes: 3788
n = input()
plst = list(map(int, input().split()))

anscnt = 0
for i in range(1, len(plst) - 1):
    if plst[i - 1] < plst[i] and plst[i] < plst[i + 1]:
        anscnt += 1
    elif plst[i + 1] < plst[i] and plst[i] < plst[i - 1]:
        anscnt += 1

print(anscnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    ll g[15][15];
    for(ll i=0;i<n;i++){
        for(ll j=0;j<n;j++)g[i][j]=-1;
    }
    for(ll i=0;i<n;i++){
        ll m;
        cin >> m;
        for(ll j=0;j<m;j++){
            ll a,x;
            cin >> a >> x;
            a--;
            g[i][a]=x;
        }
    }
    ll ans=0;
    for(ll i=0;i<(1<<n);i++){
        vector<ll>d(n);
        ll cnt=0;
        for(ll j=0;j<n;j++){
            if((i>>j)&1){
                d[j]=1;
                cnt++;
            }
        }
        bool judge=true;
        for(ll j=0;j<n;j++){
            if(d[j]){
                for(ll k=0;k<n;k++){
                    if(g[j][k]==-1)continue;
                    if(g[j][k]!=d[k]) judge=false;
                }
            }
        }
        if(judge){
            ans=max(ans,cnt);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3600
#include <stdio.h>

#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define STR(i,str) for(int i=0;(str)[i];i++)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX3(a,b,c) ((a)>(b)?(a)>(c)?(a):(c):(b)>(c)?(b):(c))
#define MIN3(a,b,c) ((a)<(b)?(a)<(c)?(a):(c):(b)<(c)?(b):(c))
#define MED(a,b,c) ((a)<(b)?(a)>(c)?(a):(b)<(c)?(b):(c):(a)>(c)?(b)<(c)?(c):(b):(a))
#define RNG(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define RNG3(a,b,c) ((a)>(b)?(b)>(c)?(a)-(c):(c)>(a)?(c)-(b):(a)-(b):(b)>(c)?(c)>(a)?(b)-(a):(b)-(c):(c)-(a))
#define MAXS(a,b) {if((a)<(b))(a)=(b);}
#define MINS(a,b) {if((a)>(b))(a)=(b);}
#define BEGINFOR(a,b,c,d,e,f,g,h,i) a;goto i##_6;i##_2:c;goto i##_6;i##_3:h;goto i##_7;i##_4:d;goto i##_8;i##_5:f;goto i##_8;i##_6:if(b)goto i##_4;else goto i##_9;i##_7:if(g)goto i##_5;else goto i##_1;i##_8:if(e)goto i##_2;else goto i##_3;i##_9:
#define ENDFOR(i) goto i##_3;i##_1:0

int main(){
	int n, z, w, ans;
	int a[2100];
	int x[2100], y[2100];
	scanf("%d%d%d", &n, &z, &w);
	REP(i, n) scanf("%d", a + i);
	for(int i = n - 2; i >= 0; i--){
		x[i] = y[i] = RNG(a[n - 1], a[i]);
		for(int j = i + 1; j < n - 1; j++){
			MINS(x[i], y[j]);
			MAXS(y[i], y[j]);
		}
	}
	ans = RNG(w, a[n - 1]);
	for(int i = 0; i < n - 1; i++) MAXS(ans, x[i]);
	printf("%d\n", ans);
}

Measured memory_bytes: 128
S = list(input())
a = [0] * len(S)
for i in range(len(S)):
    if S[i] in ['A','T','G','C']:
        a[i] += 1

ans = [0]
cnt = 0
for i in range(len(S)):
    if a[i] == 1:
        cnt += 1
        ans.append(cnt)
    else:
        ans.append(cnt)
        cnt = 0
print(max(ans))


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin>>a>>b;
    
    if(a<b)cout<<"a < b"<<endl;
    if(a>b)cout<<"a > b"<<endl;
    if(a==b)cout<<"a == b"<<endl;
    
    return 0;
    
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    set<string> st;

    rep(i,n) {
        string s; cin>>s;
        st.insert(s);
    }

    cout << st.size() << '\n';
    return 0;
}

Measured memory_bytes: 19180
#include<stdio.h>

int two(int A) {
    int count=0;
    
    while (A%2 == 0){
        A=A/2;
        count = count +1;
    }
    return count;
}


int main(){
    int N,i,ans;
    ans=0;

        scanf("%d",&N);
    
    int a[N];

    for (i=0;i<N;i++) {
        scanf("%d",&a[i]);
        ans = ans + two(a[i]);
    }

    
    
    printf("%d\n",ans);
   
    return 0;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;

vector<pair<long, long>> ab;
priority_queue<pair<long, int>> pq;
long T, A;
int main() {
    int N; cin >> N;
    long a, b;
    for(int i=0; i<N; ++i){
        cin >> a >> b;
        ab.push_back(make_pair(a, b));
        pq.push(make_pair(a+b, i));
    }
    for(int i=0; i<N; ++i){
        if(i%2<1) T += ab[pq.top().second].first;
        else A += ab[pq.top().second].second;
        pq.pop();
    }
    cout << T-A << endl;
	return 0;
}


Measured memory_bytes: 3564
//package hiougyf;
import java.io.*;
import java.util.*;

public class Main {
	  public static void main(String[] args) throws IOException
	    {
		 Scanner sc =new Scanner(System.in);
		int n=sc.nextInt();
		int a[]=new int[n];
		int mod = 1000000007;
		long cs=0;
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
			cs+=a[i];
			//cs%=mod;
			//cs=(cs+(a[i])%mod)%mod;
			
		}
		long ans=0;
		for(int i=0;i<n;i++) {
			cs-=a[i];
			ans+=(cs%mod*(a[i]%mod))%mod;
			//ans=((ans)%mod+((((a[i])%mod)*cs)%mod))%mod;
//			if(cs < 0){
//				cs += mod;
//			}
//			ans+=(cs*a[i])%mod;
//			ans%=mod;
			
			
		}
		System.out.println((long)ans%(mod));
	
	    }
		static int div(int n,int b) {
			int g=-1;
			for(int i=2;i<=Math.sqrt(n);i++) {
				if(n%i==0&&i!=b) {
					g=i;
					break;
				}
			}
			return g;
		}
	 
	  
	  public static int gcd(int a, int b) 
	    { 
	        if (a == 0) 
	            return b; 
	          
	        return gcd(b%a, a); 
	    } 
	   public static int lcm(int a, int b)  
	  {  
	     return (a*b)/gcd(a, b);  
	  }  
	   public static boolean isPrime1(int n) {
           if (n <= 1) {
               return false;
           }
           if (n == 2) {
               return true;
           }
           for (int i = 2; i <= Math.sqrt(n) + 1; i++) {
               if (n % i == 0) {
                   return false;
               }
           }
           return true;
       }
       public static boolean isPrime(int n) {
           if (n <= 1) {
               return false;
           }
           if (n == 2) {
               return true;
           }
           if (n % 2 == 0) {
               return false;
           }
           for (int i = 3; i <= Math.sqrt(n) + 1; i = i + 2) {
               if (n % i == 0) {
                   return false;
               }
           }
           return true;
       }
	      
	
}

  


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

using namespace std;

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

#define endl "\n"

const ll INF = 1e15;
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
const double PI = acos(-1.0);

const int N = 3e3 + 5;;

ll n, a[N], dp[N][N][2];

ll solve(int l, int r, int p) {
    if (l > r) return 0;
    ll& ret = dp[l][r][p];
    if (~ret) return ret;
    if (p) ret = min(solve(l + 1, r, 1 - p) - a[l], solve(l, r - 1, 1 - p) - a[r]);
    else   ret = max(solve(l + 1, r, 1 - p) + a[l], solve(l, r - 1, 1 - p) + a[r]);
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin >> n;

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

    memset(dp, -1, sizeof(dp));
    cout << solve(0, n - 1, 0) << endl;
}


Measured memory_bytes: 141568
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
 
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int n;
  cin >> n;

  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  sort(a.begin(), a.end());
  vec b(2);
  b[0] = a[a.size() - 1];

  double tmp = b[0] / 2.0;

  double min = INF;
  REP(i, n - 1){
    if(min > abs(a[i] - tmp)){
      b[1] = a[i];
      min = abs(a[i] - tmp);
    }
  }

  cout << b[0] SP b[1] << endl;

  return 0;
}


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

using namespace std;

bool check(string str) {
    int n = (int) str.size();
    char c = str[0];
    for (int i = 0; i < n; ++i) {
        if (str[i] != c) return false;
    }
    return true;
}

int main() {
    string s;
    cin >> s;
    int ans = 110;
    for (char tar = 'a'; tar <= 'z'; ++tar) {
        string t = s;
        while (!check(t)) {
            int n = (int) t.size();
            for (int i = 0; i < n - 1; ++i) {
                if (t[i + 1] == tar) t[i] = t[i+1];
            }
            t.pop_back();
        }
        ans = min(ans, (int)(s.size() - t.size()));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
opArray = []
answers = []

a, op, b = input().split()

while op != '?':
    opArray.append([a, op, b])
    a, op, b = input().split()

for i in range(len(opArray)):
    if opArray[i][1] == "+":
        answers.append(int(opArray[i][0]) + int(opArray[i][2]))
    elif opArray[i][1] == "-":
        answers.append(int(opArray[i][0]) - int(opArray[i][2]))
    elif opArray[i][1] == "/":
        answers.append(int(int(opArray[i][0]) / int(opArray[i][2])))
    elif opArray[i][1] == "*":
        answers.append(int(opArray[i][0]) * int(opArray[i][2]))
    else:
        break

for i in answers:
    print(i)

Measured memory_bytes: 7672
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
#![macro_use]

use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::mem::*;
use std::num::*;
use std::slice::*;

fn main() {
    let (r, w, e) = (stdin(), stdout(), stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    // =============================================== //
    let n: usize = io.read();
    let s = io.chars();
    let mut ans = 0i64;
    let mut dp = vec![vec![0; n + 1]; n + 1];
    for i in (0..n).rev() {
        for j in (i + 1..n).rev() {
            if s[i] == s[j] {
                dp[i][j] = dp[i + 1][j + 1] + 1;
                ans = max(ans, min(dp[i][j], j as i64 - i as i64));
            }
        }
    }
    io.writeln(ans);
}

// IO
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug ) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
}


Measured memory_bytes: 231676
function Main(inputs) {
  var board = inputs.replace(/\n/g,' ').split(/ /).slice(0,9).map(v=>+v)
  var vals = inputs.split('\n').slice(4).map(v=>+v).filter(v=>v>0)

  var rb = vals.reduce((board,val)=>{
    return board.map(v=> v == val ? 'x' : v)
  },board)

  var bingo = 0;

  [rb[0],rb[1],rb[2]].every(v=>v=='x') && bingo++;
  [rb[3],rb[4],rb[5]].every(v=>v=='x') && bingo++;
  [rb[6],rb[7],rb[8]].every(v=>v=='x') && bingo++;

  [rb[0],rb[3],rb[6]].every(v=>v=='x') && bingo++;
  [rb[1],rb[4],rb[7]].every(v=>v=='x') && bingo++;
  [rb[2],rb[5],rb[8]].every(v=>v=='x') && bingo++;

  [rb[0],rb[4],rb[8]].every(v=>v=='x') && bingo++;
  [rb[2],rb[4],rb[6]].every(v=>v=='x') && bingo++;

  //console.log(rb.join(' ').replace(/(([^ ]+ ){3})/g,'$1\n'))
  //console.log({bingo})
  console.log(bingo > 0 ? 'Yes' : 'No')
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 21064
//Jay Shree Krishna

#include"bits/stdc++.h"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long int
#define inf 1e18+5
#define sr string
#define M 1000000007
#define start int t;cin>>t;while(t--)
#define db(x) cout<<#x<<"="<<x<<"\n"
#define db2(a,b)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<< endl;
#define db3(a,b,c)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<<" , "<<#c<<": "<<c<<endl;
#define forr(i, n) for (int i = 0; i < n; i++)
#define fr(i, n) for (int i = 1; i <= n; i++)
#define rep(i,j,k) for(int i = j; i < k; i++)
#define rp(i,j,k) for(int i = j; i <=k; i++)
#define nn "\n"
#define en "\n"
#define vvi vector<vector<int>>
#define vi vector<int>
#define si set<int>
#define mlsi multiset<int>
#define vc vector<char>
#define vli vector<long long int>
#define vpii vector<pair<int,int>>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umci unordered_map<char,int>
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sortv(x) sort(x.begin(),x.end())
#define sorta(x,n) sort(x,x+n)
#define sorted(x) is_sorted(x.begin(),x,end())
#define print_all(x) for(auto t:x) cout<<t<<" ";cout<<en;
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define ub upper_bound
#define lb lower_bound
#define go(x) for(auto &[u,v]:x)
#define in(x) cin>>x
#define in2(x,y) cin>>x>>y
#define in3(x,y,z) cin>>x>>y>>z
#define in4(x,y,z,v) cin>>x>>y>>z>>v
#define oo(x) cout<<x<<endl
#define oo2(x,y) cout<<x<<" "<<y<<endl
#define oo3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define ood(n,x) cout<<fixed<<setprecision(n)<<x<<"\n"
#define sz(x) x.size()
#define ff first
#define ss second
#define ooy cout<<"Yes\n"
#define oon cout<<"No\n" 
#define rr return
#define cc continue

using namespace std;

template<class T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
void read(vli &a,int n){
    a.resize(n);
    forr(i,n) cin>>a[i];
}

bool fine=0;
vli a;
ll n,m;


void solve(){
    in(n);
    vpii a(n);
    bool ok=false;
    forr(i,n){
        cin>>a[i].ff>>a[i].ss;
        if(i>1){
            if(a[i].ff==a[i].ss && a[i-1].ff==a[i-1].ss && a[i-2].ff==a[i-2].ss ){
                ok=true;
            }
        }
    }
    if(ok) ooy;
    else oon;


}

int main(){
   #ifndef ONLINE_JUDGE 
    freopen("input1.txt", "r", stdin); 
    freopen("error.txt", "w", stderr); 
    freopen("output1.txt", "w", stdout); 
    #endif
    fast;
   if(fine){
        start{
            solve();
        }
   }
   else solve();
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define all(v) (v).begin(),(v).end()

#define PII pair<int,int>
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define lint long long int
#define VI vector<int>

#define debug(x) {cout <<#x <<" = " <<x <<endl; }
#define debug2(x,y) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y <<endl; } 
#define debug3(x,y,z) {cerr <<#x <<" = " <<x << ", "<<#y<<" = "<< y << ", " << #z << " = " << z <<endl; } 
#define debugv(x) {{cout <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<endl; }}
#define debugt(t,n) {{cerr <<#t <<" = "; FOR(it,0,(n)) cerr <<t[it] <<", "; cerr <<endl; }}

#define make( x) int (x); scanf("%d",&(x));
#define make2( x, y) int (x), (y); scanf("%d%d",&(x),&(y));
#define make3(x, y, z) int (x), (y), (z); scanf("%d%d%d",&(x),&(y),&(z));
#define make4(x, y, z, t) int (x), (y), (z), (t); scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define makev(v,n) VI (v); FOR(i,0,(n)) { make(a); (v).pb(a);} 
#define IOS ios_base::sync_with_stdio(0)
#define HEAP priority_queue

#define read( x) scanf("%d",&(x));
#define read2( x, y) scanf("%d%d",&(x),&(y));
#define read3(x, y, z) scanf("%d%d%d",&(x),&(y),&(z));
#define read4(x, y, z, t) scanf("%d%d%d%d",&(x),&(y),&(z),&(t));
#define readv(v,n) FOR(i,0,(n)) { make(a); (v).pb(a);}
#define jeb() fflush(stdout);

using namespace std;

const int max_n = 12345;
const int mod = 1e9 + 7;
char s[max_n];

int n, d;
int dp[max_n][105][2];



int main () {
	scanf("%s", s);
	read(d); n = strlen(s);
	FOR(j,0,10) dp[n-1][j%d][0] += 1;
	FOR(j,0,s[n-1]-'0'+1) dp[n-1][j%d][1] += 1;

	FORD(i,n-2,0) {
		FOR(j,0,d) {
			dp[i][j][0] = dp[i][j][1] = 0;
			FOR(u,0,10) {
				dp[i][j][0] += dp[i+1][(j+10*d-u)%d][0];
				dp[i][j][0] %= mod;
			}
			FOR(u,0,s[i]-'0') {
				dp[i][j][1] += dp[i+1][(j+10*d-u)%d][0];
				dp[i][j][1] %= mod;
			}
			dp[i][j][1] += dp[i+1][(j+10*d-(s[i]-'0'))%d][1];
			dp[i][j][1] %= mod;

		}
	}
	printf("%d\n", (dp[0][0][1]+mod-1)%mod);
}	





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

int main() {
    int N, K,ans = 0;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h.at(i);
        if (h.at(i) >= K) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
import numpy as np

a,b,x = list(map(int,input().split()))


l = x/(a*a)

if l<=b/2.0:
    f = b**2.0/(2.0*a*l)
else:
    f = 2.0*(b-l)/a
ans = np.rad2deg(np.arctan(f))
print(ans)

Measured memory_bytes: 12488
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    string S;
    cin >> S;
    int N = S.size();
    if (S[0] != 'A' || S[1] < 'a' || S[N - 1] < 'a') {
        cout << "WA" << endl;
        return 0;
    }
    int c = 0;
    FOR(i, 2, N - 1, 1) {
        if (S[i] == 'C') {
            c++;
        } else if (S[i] < 'a') {
            cout << "WA" << endl;
            return 0;
        }
    }
    if (c == 1) {
        cout << "AC" << endl;
    } else {
        cout << "WA" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <cstdlib>

int main() {
  std::int_fast64_t x, y;
  std::cin >> x >> y;
  if (x > 0) {
    if (y > 0) {
      if (std::abs(x) < std::abs(y)) {
        // e.g. 20 -> 30
        std::cout << y - x << std::endl;
      } else if (std::abs(x) == std::abs(y)) {
        // e.g. 20 -> 20
        std::cout << 0 << std::endl;
      } else {
        // e.g. 20 -> 10
        std::cout << x - y + 2 << std::endl;
      }
    } else if (y == 0) {
      // e.g. 20 -> 0
      std::cout << x + 1 << std::endl;
    } else {
      if (std::abs(x) > std::abs(y)) {
        // e.g. 20 -> -10
        std::cout << x + y + 1 << std::endl;
      } else if (std::abs(x) == std::abs(y)) {
        // e.g. 20 -> -20
        std::cout << 1 << std::endl;
      } else {
        // e.g. 20 -> -30
        std::cout << 1 - (x + y) << std::endl;
      }
    }
  } else if (x == 0) {
    if (y > 0) {
      // e.g. 0 -> 10
      std::cout << y << std::endl;
    } else if (y == 0) {
      // e.g. 0 -> 0
      std::cout << 0 << std::endl;
    } else {
      // e.g. 0 -> -10
      std::cout << 1 - y << std::endl;
    }
  } else {
    if (y > 0) {
      if (std::abs(x) < std::abs(y)) {
        // e.g. -20 -> 30
        std::cout << x + y + 1 << std::endl;
      } else if (std::abs(x) == std::abs(y)) {
        // e.g. -20 -> 20
        std::cout << 1 << std::endl;
      } else {
        // e.g. -20 -> 10
        std::cout << 1 - (x + y) << std::endl;
      }
    } else if (y == 0) {
      // e.g. -20 -> 0
      std::cout << -x << std::endl;
    } else {
      if (std::abs(x) > std::abs(y)) {
        // e.g. -20 -> -10
        std::cout << y - x << std::endl;
      } else if (std::abs(x) == std::abs(y)) {
        // e.g. -20 -> -20
        std::cout << 0 << std::endl;
      } else {
        // e.g. -20 -> -30
        std::cout << x - y + 2 << std::endl;
      }
    }
  }
  return 0;
}

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

int main(void){
    int n,m;
    int ans;
    cin >> n >> m;
    int a = m-n;
    int b = a*(a+1)/2;
    ans = b -m;
    cout << ans << endl;
    return 0;
}

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

using namespace __gnu_pbds;
using namespace std;

const long long llINF = 9223372036854775807;
const int INF = 2147483647;
const int maxn = 2e5 + 7;
const int maxm = 1e6 + 7;
const int ALP = 26;
const long long mod = 1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-10;

int n;
vector<string> ans[20];


int main()
{
    ans[1].push_back("a");
    ans[2].push_back("aa");
    ans[2].push_back("ab");
    for (int len = 3; len <= 10; len++)
    {
        for (string s:ans[len - 1])
        {
            char c = 'a';
            for (char cc:s)
            {
                c = max(c, cc);
            }
            for (char tmp = 'a'; tmp <= min((char) (c + 1), 'z'); tmp++)
            {
                ans[len].push_back(s + tmp);
            }
        }
        sort(ans[len].begin(), ans[len].end());
    }
    cin >> n;
    for (auto s:ans[n])
        cout << s << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll x, a, b;
    cin >> x >> a >> b;

    ll n;
    cin >> n;
    while(n--) {
        string s;
        cin >> s;
        if(s == "nobiro") {
            x += a;
            chmax(x, 0LL);
        } else if(s == "tidime") {
            x += b;
            chmax(x, 0LL);
        } else {
            x = 0;
        }
    }
    cout << x << endl;

    return 0;
}



Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
long long int f(long long int a,long long int b)
{
  return max(log10(a),log10(b))+1;
}
int main()
{
  long long int n,ans=(long long)1e11;
  cin>>n;
  for(long long int i=1;i*i<=n;i++)
  {
    if(n%i==0)
      ans= min(ans,f(i,n/i));
  }
  cout<<ans;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf (int)1e16
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
int n;
int sum = 0;
vector<int>g[114514];
priority_queue<int>cnt;
queue<int>que;
int ans[114514];
signed main() {
	cin >> n;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	rep(i, n) {
		int c;
		cin >> c;
		cnt.push(c);
		sum += c;
	}
	cout << sum - cnt.top() << endl;
	que.push(0);
	rep(i, n) ans[i] = inf;
	while (!que.empty()) {
		int p = que.front(); 
		que.pop();
		ans[p] = cnt.top();
		cnt.pop();
		rep(i, g[p].size()) {
			int np = g[p][i];
			if (ans[np] == inf) {
				que.push(np);
			}
		}
	}
	rep(i, n) cout << ans[i] << " ";
}


Measured memory_bytes: 3712