akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	int np = n, sum = 0, ndigits = 0;
	while(np / 10 != 0)
	{
		sum += (np % 10);
		//printf("%d\t", sum);
		np /= 10;
		//printf("%d\n", np);
	}
	sum += np;
	//printf("%d\n", sum);
	if(n % sum == 0)
		printf("Yes");
	else
		printf("No");
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cassert>
#include <bitset>

//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

//std::cout << std::fixed << std::setprecision(10)
//std::ios::sync_with_stdio(false);
//constexpr long long MOD = 1000000007;

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

int main()
{
  int N;
  std::cin >> N;
  std::vector<int> X(N);
  for(auto& val: X)
    std::cin >> val;
  int ans = INT_MAX;
  for(int i = 1; i <= 100; ++i)
  {
    int x = 0;
    for(auto val: X)
    {
      x += (val-i)*(val-i);
    }
    ans = std::min(ans, x);
  }
  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <sstream>
 
using namespace std;

vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while(!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss; ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
 
#define MOD 1000000007
#define A first
#define B second
#define all(x) (x).begin(), (x).end

typedef long long ll;
 
inline int mulmd(ll a, ll b){
  ll ret = (a * b) % MOD;
  return (int) ret;
}
 
inline int power(ll x, ll y, int m){
  ll res = 1;
  x = x % m;
  while(y > 0){
    if(y & 1){
      res = mulmd(res, x);
    }
    y = y >> 1;
    x = mulmd(x, x);
  }
  return (int) res;
}
 
inline int submd(ll a, ll b){
  ll ret = (a - b);
  if(ret < 0) ret += MOD;
  return (int) ret;
}
 
inline int addmd(ll a, ll b){
  ll ret = (a + b) % MOD;
  return (int) ret;
}
 
inline int invPow(ll a){
  return power(a, MOD - 2, MOD);
}
 
inline int divmd(ll a, ll b){
  ll ret = mulmd(a, invPow(b));
  return (int) ret;
}
 
const int N = 1e5 + 5;

int arr[N];

void solve(){
  int h, w, r;
  cin >> h >> w >> r;
  vector<string> a(h);
  int ans = 0;
  for(int i = 0; i < h; i++) cin >> a[i];
  for(int i = 0; i < (1 << h); i++){
    for(int j = 0; j < (1 << w); j++){
      int cnt = 0;
      for(int k = 0; k < h; k++){
        for(int l = 0; l < w; l++){
          if((((1 << k) & i) == 0) && (((1 << l) & j) == 0)){
            if(a[k][l] == '#') cnt++;
          }
        }
      }
      if(cnt == r) ans++;
    }
  }
  cout << ans;

}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
}



Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
#include <bitset>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
using namespace std;
typedef long long ll;



int main(){
  int x;
  cin >> x;
  vector<bool> n(100004, true);
  for(int i=2; i<320; i++){
    if(n[i]){      
      for(int j=2; j<100004/i+1; j++){
        n[i*j] = false;
      }
    }
  }
  for(int i=0; i<100004; i++){
    if(i>=x and n[i]){
      cout << i << endl;
      exit(0);
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iomanip>
using namespace std;
int main(){
	int N,sum=0,nisesum;
	cin >> N;
	int t[N];
	for(int i=0;i<N;i++){
		cin >> t[i];
	}
	int M;
	cin >> M;
	int p[M],x[M];
	for(int j=0;j<M;j++){
		cin >> p[j] >> x[j];
	}

	for(int k=0;k<N;k++){
		sum = sum + t[k];
	}
	for(int y=0;y<M;y++){
		nisesum = sum;
		nisesum = nisesum - t[p[y]-1] + x[y];
		cout << nisesum << endl;
	}

	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

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

	int n, k;
	cin>>n>>k;
	map<int, int> mp;
	for(int i = 0; i < n; i++){
		int x; cin>>x;
		mp[x]++;
	}
	vector<int> v;
	for(auto x : mp){
		v.push_back(x.second);
	}
	sort(v.rbegin(), v.rend());
	int ans = 0;
	while(v.size() > k){
		ans += v.back(); v.pop_back();
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 10744
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>
#include <iomanip>
#include <functional>
#include <array>
#include <memory>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#undef NDEBUG
#include <assert.h>

using namespace std;
typedef long long ll;

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

	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> v(m);
	for (int i = 0; i < m; ++i)
		cin >> v[i].first >> v[i].second;

	sort(v.begin(), v.end());
	int end = n + 1, ans = 0;
	for (auto &&x : v) {
		if (x.first >= end) {
			ans++;
			end = x.second;
		}
		else {
			end = min(end, x.second);
		}
	}
	cout << ++ans;
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

public class Prog
{
    public static void Main()
    {
        string input = Console.ReadLine();
        string output = "";
        int all = int.Parse(input);
        int a = all / 1000;
        int b = (all - 1000 * a) / 100;
        int c = (all - 1000 * a - 100 * b) / 10;
        int d = all % 10;
        int[] y = new int[4];
        y[0] = a;
        y[1] = b;
        y[2] = c;
        y[3] = d;
        for(int i = 0; i < 8; i++)
        {
            int sum = a;
            output = input;
            string x = Convert.ToString(i, 2).PadLeft(3,'0');
            for (int j = 2; j >= 0; j--)
            {
                if (x[j] == '1')
                {
                    output = output.Insert(j + 1, "+");
                    sum = sum + y[j + 1];
                }
                else
                {
                    output = output.Insert(j + 1, "-");
                    sum = sum - y[j + 1];
                }
            }
            if(sum == 7)
            {
                output = output + "=7";
                Console.WriteLine(output);
                break;
            }
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
const int MAX = 5600000;
const int MOD = 1000000007;
//O(k)愚直,nは大きいがkがそうでもないときに思い出す
long long modpow(long long x,long long n,long long mod){
    long long res = 1;
    while(n>0){
        if(n&1)(res*=x)%=mod;
        (x*=x)%=mod;
        n>>=1;
    }
    return res;
}
long long modinv(long long x,long long mod){
    return modpow(x,mod-2,mod);
}
long long modcomb(long long n,long long r,long long mod){
    long long numerator=1;
    for(long long i=0;i<r;i++){
        (numerator*=(n-i))%= mod;
    }
    long long denominator=1;
    for (long long i=1;i<=r;i++){
        (denominator*=i) %= mod;
    }
    denominator=modinv(denominator,mod);
    return numerator*denominator%mod;
}
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(long long n, long long k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
long x,y;
cin >> x >> y;
if((x+y)%3==0){
long long aa,bb;
aa=(2*y-x)/3;
bb=(2*x-y)/3;


if(aa>=0 && bb>=0){

 cout << modcomb(aa+bb,aa,MOD) << endl;
 return 0;
}
  else cout << "0";
  return 0;
}
else cout << "0" <<endl;

}


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

using namespace std;

const int INF = 1e9 + 5;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> v(n);
    for(int i = 0;i<n;i++)
        cin >> v[i];
    vector<int> dp(n + 1,INF);
    dp[0] = 0;
    for(int i = 0;i<n-1;i++){
        for(int j = i + 1;j<=i+k;j++){
            if(j < n){
                dp[j] = min(dp[j],dp[i] + abs(v[i] - v[j]));
            }
        }
    }
    cout << dp[n - 1] << "\n";
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 200009 /// Still trying to be normal
#define MOD  998244353
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e9 + 15;
ll mult(ll a,ll b){
    return a*b%MOD;
}
ll fastpow(ll a, ll b){
    ll ans=1;
    for(;b>=1LL;b/=2LL){
        if((b&1LL))ans=mult(ans,a);
        a=mult(a,a);
    }
    return ans;
}
ll soma(ll a,ll b){
    if(a+b>MOD)return a+b-MOD;
    else return a+b;
}
ll subt(ll a,ll b){
    if(a-b<0)return a-b+MOD;
    else return a-b;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll ans=0;
    ll n,m,k;
    cin>>n>>m>>k;
    ll fact[maxn];
    fact[0]=1;
    rep(i,1,maxn){
        fact[i]=mult(fact[i-1],i);
    }
    rep(i,0,k+1){
        if(i==0){
            ans=soma(ans,mult(fastpow(m-1,n-1),m));
        }
        else{
            ll s1=mult(fact[n-1],fastpow(mult(fact[i],fact[n-1-i]),MOD-2)); 
            ans=soma(ans,mult(mult(fastpow(m-1,n-1-i),m),s1));
        }
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 5200
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int y = sc.nextInt();
    Boolean finded = false;
    out: for (int a = n; a >= 0; a--) {
      for (int b = n - a; b >= 0; b--) {
        int c = n - a - b;
        if (a * 10000 + b * 5000 + c * 1000 == y) {
          finded = true;
          System.out.println(String.format("%d %d %d", a, b, c));
          break out;
        }
      }
    }
    if (!finded) System.out.println("-1 -1 -1");
  }
}


Measured memory_bytes: 21972
package main

import(
    "fmt"
)



func main() {
    var n int
    fmt.Scan(&n)
    var w = make([]int, n)
    for i:=0; i<n; i++{
        fmt.Scan(&w[i])
    }
    ans := 100000000
    for i:=0; i<n-1; i++{
        s1 := 0
        s2 := 0
        for j:=0; j<=i; j++{
            s1 += w[j]
        }
        for j:=i+1; j<n; j++{
            s2 += w[j]
        }
        ans = min32(ans,abs32(s1-s2))
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

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

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


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

using namespace std;


typedef long long ll;
ll mod=1e9+0LL;
ll MOD=1e18+0LL;
#define line printf("\n")
double pi=acos(-1);
ll md=1000000007;
ll gcd(ll a,ll b){
    //if(b>a) swap(a,b);
    return b==0?abs(a):gcd(b,a%b);
}
ll poW(ll a ,ll n)
{
    if(n==0) return 1;
    if(n%2==0)
    {
        ll b=poW(a,n/2);
        return (b*b)%md;
    }
    return (poW(a,n-1)*a)%md;
}

char gap=' ';






















//vector<int>v[200100];
//bool visit[200100]={0};
//int vc[200100]={0};
//
//
//int cnt;
//void dfs(int s,int c=0)
//{
//    if(visit[s]) return;
//    cnt++;
//        visit[s]=1;
//
//        for(int i=0;i<v[s].size();i++) {
//                dfs(v[s][i]);
//        }
//
//}


int main()
{
    int cs=1;
    //scanf("%d",&cs);
    while(cs--)
    {
       ll n,i,j;
       cin>>n;
       ll a[n]={0};
        for(i=0;i<n;i++) cin>>a[i];
        sort(a,a+n);
        bool used[a[n-1]+1]={0};
        ll cnt=0,t=a[n-1];
        for(i=0;i<n;i++)
        {
            if(used[a[i]]) continue;

            for(j=a[i];j<=t;j+=a[i]) used[j]=1;
            if(a[i]!=a[i+1]) cnt++;
        }
        cout<<cnt;
    }
}


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

int a[100], dp[100][100];
int calc(int l, int r, int n){
	int ans = 0;
	for(int i = l;i <= r;i++)ans += dp[n][i];
	return ans;
}

void init(){
	dp[0][0] = 1;
	for(int i = 1;i <= 51;i++){
		dp[i][0] = 1;
		for(int j = 1;j <= 51;j++)
		dp[i][j] = dp[i-1][j-1]+dp[i-1][j];
	}
}

signed main(){
	init();
	int n, l, r;
	scanf("%lld%lld%lld", &n, &l, &r);
	for(int i = 1;i <= n;i++)scanf("%lld", &a[i]);
	sort(a+1, a+n+1, greater<int>());
	
	int sum = 0, s1 = 0, s2 = 0;
	for(int i = 1;i <= n;i++){
		if(i <= l)sum += a[i];
		if(a[i] > a[l])s1++;
		if(a[i] == a[l])s2++;
	}
	
	printf("%lf\n", (double)sum/l);
	if(s1 == 0)printf("%lld\n", calc(l, r, s2));
	else printf("%lld\n", dp[s2][l-s1]);
	return 0;
}

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

using namespace std;

typedef long long ll;

using edge = pair<int, int>;

const int max_n = 55;
int n, m;
vector<edge> g[max_n];
vector<int> us, vs;

bool rec(int v, int p, int target, ll &path){
	if(v == target){
		path = 0;
		return true;
	}

	for(auto e : g[v]){
		if(e.first == p) continue;
		if(rec(e.first, v, target, path)){
			path |= (1ll << e.second);
			return true;
		}
	}

	return false;
}

ll solve(){
	vector<ll> paths(m, 0);
	rep(i, m) rec(us[i], -1, vs[i], paths[i]);

	ll res = 0;
	for(ll bit = 0; bit < (1 << m); bit++){
		ll val = 0;
		rep(i, m) if((bit >> i) & 1ll) val |= paths[i];
		ll remnum = n - 1 - __builtin_popcountl(val);
		if(__builtin_popcountl(bit) % 2 == 0) res += (1ll << remnum);
		else res -= (1ll << remnum);
	}

	return res;
}

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

	cin >> n;

	rep(i, n-1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back({b, i});
		g[b].push_back({a, i});
	}

	cin >> m;
	us.resize(m);
	vs.resize(m);
	rep(i, m){
		cin >> us[i] >> vs[i];
		us[i]--; vs[i]--;
	}

	cout << solve() << endl;
}


Measured memory_bytes: 3568
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){


			int N = scan.nextInt();
			int K = scan.nextInt();
			long[]h = new long[N];
			for(int i = 0;i<N;i++)h[i] =scan.nextLong();

			long[]dp = new long[N+1];

			for(int i = 1;i<N;i++) {
				if(i-K>=0){
					long dpcost = Long.MAX_VALUE;
					int dpnum = 0;
					for(int j = 1;j<=K;j++) {
						if(dpcost>dp[i-j]+Math.abs(h[i]-h[i-j])) {
							dpcost = dp[i-j]+Math.abs(h[i]-h[i-j]);
							dpnum = j;
						}
					}

					dp[i] =dpcost;

				}else {
					long dpcost = Long.MAX_VALUE;
					int dpnum = 0;
					for(int j = 1;j<=i;j++) {
						if(dpcost>dp[i-j]+Math.abs(h[i]-h[i-j])) {
							dpcost = dp[i-j]+Math.abs(h[i]-h[i-j]);
							dpnum = j;
						}

					}


					dp[i] =dpcost;

				}
			}

			System.out.println(dp[N-1]);





		}


	}


}


Measured memory_bytes: 60296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const string yes = "Yes";
const string no = "No";

int main()
{
  int n; cin >> n;
  int m = 0;
  multiset<int> st;
  for (int i=0; i<pow(2,n); i++) {
    int tmp; cin >> tmp;
    st.insert(tmp);
    m = max(m, tmp);
  }

  vector<int> v;
  v.push_back(m);
  for (int i=0; i<n; i++) {
    sort(v.begin(),v.end());
    int len = v.size();
    for (int j=0; j<len; j++) {
      auto itr = st.lower_bound(v[j]);
      if (itr == st.begin()) {
        cout << "No" << endl;
        return 0;
      }
      itr--;
      v.push_back(*itr);
      st.erase(itr);
    }
  }
  cout << "Yes" << endl;

  // vector<int> s;
  // int m = 0;
  // for (int i=0; i<pow(2,n); i++) {
  //   int t; cin >> t;
  //   s.push_back(t);
  //   m = max(m, t);
  // }
  // sort(s.begin(),s.end());
  // vector<int> t;
  // t.push_back(m);
  // for (int i=0; i<n; i++) {
  //   int len = (int)(t.size());
  //   for (int j=0; j<len; j++) {
  //     auto it = upper_bound(s.begin(), s.end(), t[j]-1);
  //     if (it == s.begin()) {
  //       cout << "No" << endl;
  //       return 0;
  //     }
  //     int tmp = *(it-1);
  //     t.push_back(tmp);
  //   }
  // }
  // sort(t.begin(),t.end());
  // for (int i=0; i<pow(2,n); i++) {
  //   if (s[i] > t[i]) {
  //     cout << "No" << endl;
  //     return 0;
  //   }
  // }
  // cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 13820
$N=<>;
@a=glob<>;
($m,$M)=(inf,-inf);
for(@a){
	++$i;
	if($_<$m){
		$m=$_;
		$mi=$i
	}
	if($_>$M){
		$M=$_;
		$Mi=$i
	}
}
$,=$";$\=$/;
if($M>=-$m){
	print$N*2-2;
	print$Mi,2;
	print$Mi,2;
	for(3..$N){
		print$_-1,$_;
		print$_-1,$_
	}
}else{
	print$N*2-2;
	print$mi,$N-1;
	print$mi,$N-1;
	for(2..$N-1){
		print$N-$_+1,$N-$_;
		print$N-$_+1,$N-$_
	}
}


Measured memory_bytes: 768
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	std::string s;
	in >> s;
	rep(i, s.length())
	{
		if (s[i] == '1') s[i] = '9';
		else s[i] = '1';
	}
	out << s << std::endl;
}


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

int func(long long j) {
    if (j < 10) return 1;
 
    for (int i=1;;i++) {
        j/=10;
        if (j==0) return i;
 
    }
}
 
int main(){
    long long i,j;
    int ans = (1<<29);
    long long N;
    cin >> N;
 
    for (i = 1; i*i <= N; i++) {
        if (N%i == 0) {
            j = N / i;
            ans = min(ans, func(j));
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
function main(input) {
  input = input.trim();
  const [a,b,c] = input.split(" ");
 
  if(a.slice(-1)==b.slice(0,1) && b.slice(-1)==c.slice(0,1)){
    console.log("YES");
  }else{
    console.log("NO");
  }
 
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

string table[8];
bool range(int y,int x)
{
	if (y < 0 || x < 0 || y >= 8 || x >= 8)return false;
	return true;
}
bool A(int y, int x)
{
	int dx[] = {0,1,1,0};
	int dy[] = {0,0,1,1};
	for (int i = 0; i < 4; i++)
	{
		int ny = y + dy[i];
		int nx = x + dx[i];
		if (range(ny, nx) && table[ny][nx] == '1')continue;
		return false;
	}
	return true;
}
bool B(int y, int x)
{
	int dx[] = { 0, 0, 0, 0 };
	int dy[] = { 0, 1, 2, 3 };
	for (int i = 0; i < 4; i++)
	{
		int ny = y + dy[i];
		int nx = x + dx[i];
		if (range(ny, nx) && table[ny][nx] == '1')continue;
		return false;
	}
	return true;
}
bool C(int y, int x)
{
	int dx[] = { 0, 1, 2, 3 };
	int dy[] = { 0, 0, 0, 0 };
	for (int i = 0; i < 4; i++)
	{
		int ny = y + dy[i];
		int nx = x + dx[i];
		if (range(ny, nx) && table[ny][nx] == '1')continue;
		return false;
	}
	return true;
}
bool D(int y, int x)
{
	int dx[] = { 0, 0, -1, -1 };
	int dy[] = { 0, 1,1, 2 };
	for (int i = 0; i < 4; i++)
	{
		int ny = y + dy[i];
		int nx = x + dx[i];
		if (range(ny, nx) && table[ny][nx] == '1')continue;
		return false;
	}
	return true;
}
bool E(int y, int x)
{
	int dx[] = { 0, 1, 1, 2 };
	int dy[] = { 0, 0, 1, 1 };
	for (int i = 0; i < 4; i++)
	{
		int ny = y + dy[i];
		int nx = x + dx[i];
		if (range(ny, nx) && table[ny][nx] == '1')continue;
		return false;
	}
	return true;
}
bool F(int y, int x)
{
	int dx[] = { 0, 0, 1, 1 };
	int dy[] = { 0, 1, 1, 2 };
	for (int i = 0; i < 4; i++)
	{
		int ny = y + dy[i];
		int nx = x + dx[i];
		if (range(ny, nx) && table[ny][nx] == '1')continue;
		return false;
	}
	return true;
}
bool G(int y, int x)
{
	int dx[] = { 0, 1, 0, -1 };
	int dy[] = { 0, 0, 1, 1 };
	for (int i = 0; i < 4; i++)
	{
		int ny = y + dy[i];
		int nx = x + dx[i];
		if (range(ny, nx) && table[ny][nx] == '1')continue;
		return false;
	}
	return true;
}
char check(int y, int x)
{
	if (A(y, x))return 'A';
	else if (B(y, x))return 'B';
	else if (C(y, x))return 'C';
	else if (D(y, x))return 'D';
	else if (E(y, x))return 'E';
	else if (F(y, x))return 'F';
	else if (G(y, x)) return 'G';
	else return 0;
}
int main()
{
	while (true)
	{
		for (int i = 0; i < 8; i++)
		{
			if (!(cin >> table[i]))return 0;
		}
		bool find = false;
		for (int i = 0; i < 8; i++)
		{
			for (int j = 0; j < 8; j++)
			{
				int ret = check(i,j);
				if (ret > 0)
				{
					find = true;
					cout << ((char)ret) << endl;
					break;
				}
			}
			if (find)break;
		}
	}
	return 0;
}

Measured memory_bytes: 1180
n, m = map(int, input().split())
kaidan = [0]*(n+1)
for i in range(m):
    kaidan[int(input())-1] = 1

a = 1; b = 0
for i in range(n):
    if kaidan[i]:
        a, b = 0, a
    else:
        a, b = a+b, a

mod = 10**9+7
print(a%mod)


Measured memory_bytes: 3828
#include <iostream>
#include <string>
using namespace std;
using llong = long long;

llong ans;

llong c2ll(int i, const string &s) { return s[i] - '0'; }

void func(int i, llong tmp, llong sum, const string &s) {
    if (i + 1 == s.length()) {
        ans += tmp + sum;
        return;
    }

    llong tmp1 = tmp * 10 + c2ll(i + 1, s);
    func(i + 1, tmp1, sum, s);

    sum += tmp;
    tmp = c2ll(i + 1, s);
    func(i + 1, tmp, sum, s);
}

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

    func(0, c2ll(0, s), 0LL, s);
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N;
  cin >>N;
  vector<int> p(N),q(N);
  for(int i=0; i<N;i++)
    cin >>p[i];
  for(int i=0; i<N;i++)
    q[i]=p[i];
  sort(p.begin(),p.end());
  int b=0;
  for(int i=0; i<N;i++){
    if( q[i] != p[i] )
      b++;
  }
  if(b<=2)
    cout <<"YES";
  else
    cout <<"NO";
}

Measured memory_bytes: 256
N, K = map(int, input().split())
D = list(map(int, input().split()))

p = N
flag = True
while flag:
  pnum = list(map(int, str(p)))
  bp = [(i in D) for i in pnum]
  flag = sum(bp)
  if flag:
    p += 1
  
print(p)

Measured memory_bytes: 3060
n = int(input())
h = [int(_) for _ in input().split()]
count = 0
maxcount = 0
if n == len(h) and 1 <= n <= 10 ** 5 and all(1 <= i <= 10 ** 9 for i in h):
    for i in range(n - 1):
        if h[i] >= h[i + 1]:
            count += 1
            if count > maxcount:
                maxcount = count
        else:
            count = 0
    print(maxcount)
else:
    print('hoge!')

Measured memory_bytes: 14252
import java.util.*;

public class Main {
	static final long MOD = 998244353;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int S = sc.nextInt();
		int[] A = new int[N];
		for(int i=0; i<N; i++) {
			A[i] = sc.nextInt();
		}
		
		long[][] dp = new long[N+1][S+1];
		dp[0][0] = 1;
		for(int i=0; i<N; i++)
			dp[0][0] = (dp[0][0]*2)%MOD;
		
		long rev2 = rev(2);
		for(int i=0; i<N; i++) {
			for(int j=0; j+A[i]<=S; j++) {
				dp[i+1][j+A[i]] = (dp[i+1][j+A[i]] + dp[i][j]*rev2)%MOD;
			}
			for(int j=0; j<=S; j++) {
				dp[i+1][j] = (dp[i+1][j] + dp[i][j])%MOD;
			}
		}
		
		System.out.println(dp[N][S]);

		sc.close();
	}
	
	static long rev(long n) {
		return pow(n, MOD-2);
	}
	
	static long pow(long n, long p) {
		long ans = 1;
		while(p>0) {
			if((p&1)==1)
				ans = (ans * n)%MOD;
			p>>=1;
			n = (n * n)%MOD;
		}
		
		return ans;
	}


}


Measured memory_bytes: 100576
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
typedef long long ll;

using namespace std;

std::string megalomania(std::vector<ll> a, std::vector<ll> b) {
  using Pair  = std::pair<ll, ll>;
  vector<Pair> works;
  for(ll i = 0;i<a.size();i++) {
    works.push_back(Pair(b.at(i), a.at(i)));
  }
  sort(works.begin(), works.end());

  ll consumption = 0;
  
  for(ll i =0;i<works.size();i++) {
    ll estimation = works.at(i).second;
    ll limit = works.at(i).first;
    consumption += estimation;
    if(consumption > limit) {
      return "No";      
    }
  }
  
  return "Yes";
}

int main() {
  ll n;
  cin  >> n;
  vector<ll> a(n);
  vector<ll> b(n);

  for(ll i = 0; i< n;i++) {
    cin >> a[i];
    cin >> b[i];
  }

  cout << megalomania(a, b);
}

Measured memory_bytes: 13712
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
ll N, M;
int main(){
   cin >> N;
   ll ans = 0; 
   while(ans*(ans+1)/2 < N) ++ans; // 1 ~ ansがN以下だと辿り着けない
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int isValid(int nr) {
	if (nr >= 1 && nr <= 9)
		return 1;
		return 0;
}
int main()
{
	int a, b;
	cin >>a >>b;
	if (isValid(a) && isValid(b)) {
		cout << a * b;
	}
	else cout << -1;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int n, k;
int p[5001];
ll c[5001];
ll score[5001][5001];
ll sum[5001];
int cycle_len[5001];

int main() {
    cin >> n >> k;
    reps(i, n) { scanf("%d", &p[i]); }
    reps(i, n) { scanf("%lld", &c[i]); }
    ll ans = c[1];
    reps(i, n) {
        if (cycle_len[i] == 0) {
            vector<int> v{i};
            ll s = c[i];
            int cur_pos = p[i], cnt = 1;
            while (cur_pos != i) {
                v.push_back(cur_pos);
                s += c[cur_pos];
                cur_pos = p[cur_pos];
                cnt++;
            }
            for (int j : v) {
                cycle_len[j] = cnt;
                sum[j] = s;
            }
        }
    }
    reps(i, n) {
        int cur_pos = i;
        reps(j, k) {
            if (j == n) break;
            cur_pos = p[cur_pos];
            score[i][j] = score[i][j - 1] + c[cur_pos];
            ans = max(ans, score[i][j]);
        }
    }
    if (k >= n && sum > 0) {
        reps(i, n) {
            rep(j, n) { ans = max(ans, score[i][j] + sum[i] * ((k - j) / cycle_len[i])); }
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

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

	int n, k;
	bool hate[10];
	cin >> n >> k;

	for(int i=0; i<10; i++){
		hate[i] = true;
	}

	for(int i=0; i<k; i++){
		int d;
		cin >> d;
		hate[d] = false;
	}

	for(long long num = n;; num++ ){
		string num_s = to_string(num);
		bool f = true;
		for(int i=0; i<num_s.size(); i++){
			if(hate[num_s[i] - '0'] == false){
				f = false;
				break;
			}
		}
		if(f){
			cout << num << endl;
			break;
		}
	}


	

	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

class Mod
{
private:
    static const int MOD = 1000000007;
    long long a;
public:
    Mod(){
        a = 0;
    }
    Mod(long long x){
        a = (x % MOD + MOD) % MOD;
    }
    const Mod operator+(const Mod& x) const{
        return Mod(a + x.a);
    }
    const Mod operator-(const Mod& x) const{
        return Mod(a - x.a);
    }
    const Mod operator*(const Mod& x) const{
        return Mod(a * x.a);
    }
    const Mod operator/(const Mod& x) const{ // フェルマーの小定理、MODが素数である場合のみ有効
        int b = MOD - 2;
        long long c = x.a;
        long long ret = 1;
        while(b > 0){
            if(b & 1){
                ret *= c;
                ret %= MOD;
            }
            c *= c;
            c %= MOD;
            b >>= 1;
        }
        return Mod(a * ret);
    }
    long long getValue(){
        return a;
    }
};

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

    vector<Mod> dp(2*n+2, 0);
    dp[0] = 1;
    dp[1] = -1;
    Mod ans = 0;
    for(int i=0; i<n; ++i){
        Mod x = dp[i];
        if(i < n - 1){
            Mod tmp = (n - 1LL) * (n - 1LL);
            ans = ans + x * tmp;
        }
        dp[i+1]   = dp[i+1]   + x;
        dp[i+2]   = dp[i+2]   - x;
        dp[i+3]   = dp[i+3]   + x;
        dp[i+n+2] = dp[i+n+2] - x;

        dp[i+1] = dp[i+1] + dp[i];
    }

    for(int i=n; i<=2*n; ++i){
        ans = ans + dp[i];
        dp[i+1] = dp[i+1] + dp[i];
    }
    cout << ans.getValue() << endl;

    return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

vector<vector<int>> a(555, vector<int>(555, 0));
vector<pair<int, int>> odr;
vector<string> ans;

int main()
{
    int h, w;
    cin>>h>>w;
    REP(i,h) {
        REP(j,w) {
            cin>>a[i+1][j+1];
        }
    }
    FOR(i,1,h+1) {
        if (i % 2 == 0) {
            RFOR(j,w+1,1) {
                odr.push_back(make_pair(i,j));
            }
        } else {
            FOR(j,1,w+1){
                odr.push_back(make_pair(i,j));
            }
        }
    }

    int size = odr.size();
    REP(i,size - 1) {
        if (a[odr[i].first][odr[i].second] % 2 == 1) {
            string tans = to_string(odr[i].first) + " "
                    + to_string(odr[i].second) + " "
                    + to_string(odr[i+1].first) + " "
                    + to_string(odr[i+1].second);
            ans.push_back(tans);
            a[odr[i].first][odr[i].second]--;
            a[odr[i+1].first][odr[i+1].second]++;
        }
    }
    cout<<ans.size()<<endl;
    REPALL(i,ans)
        cout<<ans[i]<<endl;

    return 0;
}


Measured memory_bytes: 14072
#include <bits/stdc++.h>
	using namespace std;
	#define IOS ios::sync_with_stdio(false), cin.tie(0)
	#define REP(i, n) for (int i = 0; i < n; i++)
	#define FOR(i, a, b) for (int i = a; i < b; i++)
	#define ALL(x) (x).begin(), (x).end()
	#define dump(x) cout << (x) << endl
	#define LMAX 9223372036854775807LL
	#define LMIN -9223372036854775807LL

	using ll = long long;
	template<typename T>
	using vec = vector<T>;
	using P = pair<ll, ll>;

	template <typename A, size_t N, typename T>
	void Fill(A (&array)[N], const T &val)
	{
		fill((T *)array, (T *)(array + N), val);
	}

	const ll INF = 1e18;
	const ll mod = 1e9 + 7;

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

	int main(){
		IOS;
	int n;
	double t, a;
	cin >> n >> t >> a;
	vec<pair<double,int>> v(n);
	REP(i,n){
		double x;
		cin >> x;
		v[i].second = i + 1;
		x = t - x * 0.006;
		v[i].first = fabs(x - a);
	}
		sort(ALL(v));
		dump(v[0].second);
	}

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

int i,j,n;
int ans=100000;

int main(){
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        ans*=1.05;
        if(ans%1000!=0)ans-=ans%1000,ans+=1000;
    }
    printf("%d\n",ans);
    
    return 0;
}		



Measured memory_bytes: 2064
#include <iostream>
#include <string>
#include <cmath>
#include<iomanip>
#include<algorithm>
#include<list>
using namespace std;

bool prime(int a){
	for (int i = 2; i <= sqrt(a); i++){
		if (a % i == 0){
			return false;
		}
	}

	return true;
}


int main()
{
	int n, count = 0;
	cin >> n;
	for (int i = 0; i < n; i++){
		int a;
		cin >> a;
		if (prime(a)){
			count++;
		}
	}
	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 1164
#define LOCAL
#include <bits/stdc++.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 rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	vector<int> v(3);
	rep(i, 3) cin >> v[i];
	int k = 1;
	int cnt = 0;
	while(1){
		if(k == 3) break;
		if(v[k-1] >= v[k]) {
			v[k] *= 2;
			cnt++;
		}
		else k++;
	}

	// print(cnt);
	int d; cin >> d;
	if(cnt <= d){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3620
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
# pragma GCC optimize "-O3"
# define int long long
  
using namespace std;
  
const int N = 1e5 + 7;
const int mod = 1e9 + 7;

vector < int > adj[N];

void solve() {
	int n, m;
	cin >> n >> m;
	vector < int > a(n);
	for ( int i = 0; i < n; i++ ) {
		cin >> a[i];
	}
	for ( int i = 0; i < m; i++ ) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}  
	int ans = 0;
	for ( int i = 0; i < n; i++ ) {
		int ok = 1;
		for ( auto u: adj[i] ) {
			if ( a[i] <= a[u] ) {
				ok = 0;
				break;
			}
		}
		if ( ok ) {
			ans++;
		}
	}
	cout << ans;
}

int32_t main() {
	speed;
	int T = 1;
	// cin >> T;
	while ( T-- ) {
		solve();
	}
}

Measured memory_bytes: 9800
n = int(input())
cnt = 0
ans = 0
for i in range(1,n+1):
  if i % 2 != 0:
    for j in range(1,i+1):
      if i % j == 0:
        cnt += 1
    if cnt == 8:
      ans += 1
  cnt = 0

print(ans)

Measured memory_bytes: 3316
// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
    "4\n10\n8\n8\n6\n" => "3",
    "3\n15\n15\n15\n" => "1",
    "7\n50\n30\n50\n100\n50\n80\n30\n" => "4"
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: u32,
        v: [u32; n]
    }

    let mut v = v;
    v.sort();
    v.dedup();

    v.len().to_string()
}

Measured memory_bytes: 4352
'''input
44852
'''
cur6 = [6]
cur9 = [9]
cur1 = [1]
for i in range(7):
	cur6.append(6*cur6[-1])
	cur9.append(9*cur9[-1])
n = input()
dp = [-1]*(n+1)
dp[0] = 0
dp[1] = 1
for i in range(7):
	if cur6[i] <= n:
		dp[cur6[i]] = 1
	if cur9[i] <= n:
		dp[cur9[i]] = 1
for i in range(2,n+1):
	if dp[i] == 1:
		continue
	else:
		# currency 1
		dp[i] = dp[i-1]+1
		# currency 6,9
		for j in range(7):
			if i-cur6[j] >= 0:
				dp[i] = min(dp[i],dp[i-cur6[j]]+1)
			if i-cur9[j] >= 0:
				dp[i] = min(dp[i],dp[i-cur9[j]]+1)
print dp[n]

Measured memory_bytes: 33896
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    x = int(input())
    now = 100
    cnt = 0
    while now < x:
        now = now * 101 // 100
        cnt += 1
    print(cnt)
resolve()

Measured memory_bytes: 63248
n = STDIN.gets.to_i

n1 = STDIN.gets.to_i
n2 = STDIN.gets.to_i

max = n1
min = n1

if n1 > n2 then
  min = n2
  diff = n2 - n1
  max = n2
else
  max = n2
  diff = n2 - n1
end


(3..n).each { |i|
  x = STDIN.gets.to_i

  if x > max then
    diff = x - min if x - min > diff
    max = x
  elsif x <= min then
    diff = x - max if x - max > diff
    min = x
    max = x
  end
}
puts diff

Measured memory_bytes: 8764
/*
 *  Created on: 2 / 5 / 2020
 *  Author:     Eslam Waheed
 */
#include <bits/stdc++.h>
//#include <bits/BIGINT.h>
//#include <bits/Int128.h>
using namespace std;

//#define _CRT_SECURE_NO_WARNINGS
//#define __USE_MINGW_ANSI_STDIO
#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define dd   double
#define ld   long dd
#define ss   string

#define pb      push_back
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stp(n)  cout << fixed << setprecision(n)
#define iq(v)   v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)   (ll)(s.size())
#define endl    '\n'

#define loop(i,m,n)  for(ll i=m;i<n;i++)

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

//const ll mod = 1e9 + 7;
//__int128
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
    //stp(0);
    Eslam__Waheed
    string s; cin >> s;
    ll c = 0;
    for (int i = 0; i < sz(s) - 1; i++)
    {
        if (s[i] == 'h' && s[i + 1] == 'i')
        {
            c++;
        }
    }
    if ((c * 2) == sz(s))
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

Measured memory_bytes: 256
(N, K), As = readlines.map{|l| l.split.map(&:to_i)}

require 'prime'

ds = As.inject(:+).prime_division.inject([1]){|a, (p, e)| (0 .. e).map{|f| p**f}.product(a).map{|a, b| a*b}}.sort.reverse
puts (ds.find do |d|
  ms = As.map{|a| a % d}.sort.reverse
  ms.take(ms.inject(:+)/d).inject(0){|s, m| s + d - m} <= K
end)

Measured memory_bytes: 12152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int maru = 0;
		for (int i=0;i<s.length();i++) {
			if (s.charAt(i)=='o') {
				maru++;
			}
		}
		maru +=15-s.length();
		if (maru>=8) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 35680
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;
ll n;
vi A;
bool check(ll mid){
  ll now = A[mid];
  for(int i=0;i<mid;i++){
    now += A[i];
  }
  for(int i=mid+1;i<n;i++){
    if(now*2 < A[i])return false;
    now += A[i];
  }
  return true;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  A.resize(n);
  for(auto &a:A)cin>>a;
  sort(ALL(A));
  ll le = -1,ri = n-1;
  while(ri-le > 1){
    ll mid = (ri+le)/2;
    if(check(mid)){
      ri = mid;
    }else{
      le = mid;
    }
  }
  cout<<n-ri<<endl;
  return 0;
}


Measured memory_bytes: 1024
def resolve():
    a, b = [int(i) for i in input().split()]
    if a <= 0 and 0 <= b:
        print("Zero")
    else:
        if a > 0:
            print("Positive")
        else:
            if (abs(b - a) + 1) % 2 == 0:
                print("Positive")
            else:
                print("Negative")


resolve()


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

struct Benri {
    Benri() {
        std::cin.tie(0); ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
    }
} benri;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007
#define MOD2 998244353




int main() {
    double t,x; cin >> t >> x;
    cout << t / x << endl;
}




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

using namespace std;
using ll = long long;

int kaijo(int n) {
    if(n <= 1) {
        return 1;
    }
    return kaijo(n-1)*n;
}


int nom(vector<int> A) {
    int ans = 0;
    int N = A.size();
    vector<int> a(N,1);

    for(int i = 0; i < N; i++) {
        a.at(A.at(i) - 1) = 0;
        for(int j = 0; j < A.at(i); j++) {
            ans += a.at(j)*kaijo(N - 1 - i);
        }
    }


    return ans;
}

int main() {
    int N = 0;
    cin >> N;
    vector<int> P(N);
    for(int i = 0; i < N; i++) {
        cin >> P.at(i);
    }
    vector<int> Q(N);
    for(int i = 0; i < N; i++) {
        cin >> Q.at(i);
    }
    cout << abs(nom(P) - nom(Q)) << endl;



    return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
	int n; cin >> n;
	double sum = 0;
	double add = 0;
	for(int i = 1; i <= n; i++){
		if(i % 2 != 0) sum++;
		add++;
	}
		
		cout << sum / add << endl;
}

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

#define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())

using namespace std;

int d[3],i,j;
int main()
{
    for (i=0;i<3;++i) scanf("%d",&d[i]);
    sort(d,d+3);
    if (d[0]-5||d[1]-5||d[2]-7) j=1;
    if (j) printf("NO\n");
    else printf("YES\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>//头文件
using namespace std;
long long Q,H,S,D,N,ans;//一定要long long
int main(){
    cin>>Q>>H>>S>>D>>N;
    ans=(N%2==0)?(min(min(min(Q*8,H*4),S*2),D)*N/2):(min(min(Q*4,H*2),S)+min(min(min(Q*8,H*4),S*2),D)*(N-1)/2);//为什么不能直接输出，是我的问题吗
    cout<<ans<<endl;//可以不打回车
    return 0;
}

Measured memory_bytes: 256
/****************************************************************************************************
                                        SUBMITTED BY-

                                                AISH_07

****************************************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ll long long
#define sl set<ll>
#define vs vector<string>
#define pb push_back
#define vl vector<ll>
#define vi vector<int>
#define PI  3.14159265
#define mod 998244353
void solve(int a[],int st,int anth)
{
    for(int i=st;i<anth;i++)
    {
        if(a[i]==0)
            return ;
        a[i]--;
    }
    return ;
}
int dh_zero(int a[],int st,int anth)
{
    for(int i=st;i<anth;i++)
    {
        if(a[i]!=0)
            return i;
    }
    return anth;
}
int main()
{
   int n;
   cin>>n;

   int a[n];

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

   int ans=0;
   int shuru=0;

   while(1)
   {
       shuru=dh_zero(a,shuru,n);
       if(shuru==n)
        break;
       ans++;
       solve(a,shuru,n);
   }
   cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main() {
    int A[4]; cin >> A[0] >> A[1] >> A[2] >> A[3];
    int cnt_1 = 0, cnt_9 = 0, cnt_7 = 0, cnt_4 = 0;
    for (int x : A) {
        if (x == 1) cnt_1++;
        if (x == 9) cnt_9++;
        if (x == 7) cnt_7++;
        if (x == 4) cnt_4++;
    }
    if (cnt_1 == 1 && cnt_1 == cnt_9 && cnt_9 == cnt_7 && cnt_7 == cnt_4) printf("%s\n", "YES");
    else printf("%s\n", "NO");
}

Measured memory_bytes: 3632