akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}



const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
    int N,M,K;
    cin >> N >> M >> K;
    combination n(N);
    mint m1 = M;
    mint m2 = M-1;
    mint ans = 0;
    rep(i,K+1) {
        ans += m1*n(N-1,i)*m2.pow(N-i-1);
    }
    cout << ans << endl;
}

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

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } 
template <typename A>
string to_string(A v) {
    bool first = true; 
    string res = "{";
    for (const auto &x : v) {
        if (!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}"; 
    return res;
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    dbg_out(T...);
}
#ifdef LOCAL
    #define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", dbg_out(__VA_ARGS__)
#else
    #define dbg(...) 42
#endif

#define int long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define MP make_pair
#define sz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)
#define nl "\n"
typedef pair<int, int> pii;
typedef vector <int> vi;

pii dir[8] = { {-1, 0}, {1, 0}, {0, -1}, {0, 1}, {1, 1}, {-1, -1} , {-1, 1}, {1, -1} };

const int inf = (1LL << 60), mod = 1e9+7, nn = 2e5+5;

void solve(){
    string s;
    cin >> s;
    string t(sz(s), 'x');
    cout << t;
}

int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++){
        // cout << "Case #" << tc << ": ";
        solve();
    }
    return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n; cin>>n;
	vector<pair<int,int>> v;
	for(int x,y,i=0;i<n;i++)
	{
	    cin>>x>>y;
	    v.push_back({x,y});
	}
	int flag=0;
	for(int i=0;i<n-2;i++)
	{
	    if((v[i].first==v[i].second) && (v[i+1].first==v[i+1].second) && (v[i+2].first==v[i+2].second))
	    {
	        flag=1;
	        break;
	    }
	}
	if(flag==1)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define maxn 5005
using namespace std;
const int mod = 1e9+7;
int n,coef[maxn],ans,siz[maxn],f[maxn][maxn],g[maxn];
vector<int>G[maxn];
void dfs(int u,int ff){
	siz[u]=f[u][1]=1;
	for(int v:G[u]) if(v!=ff){
		dfs(v,u);
		memset(g,0,(siz[u]+siz[v]+1)<<2);
		for(int i=1;i<=siz[u];i++)
			for(int j=1;j<=siz[v];j++){
				if(!(j&1)) g[i]=(g[i]-1ll*f[u][i]*f[v][j]%mod*coef[j])%mod;
				g[i+j]=(g[i+j]+1ll*f[u][i]*f[v][j])%mod;
			}
		siz[u]+=siz[v];
		memcpy(f[u],g,(siz[u]+1)<<2);
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1,x,y;i<n;i++) scanf("%d%d",&x,&y),G[x].push_back(y),G[y].push_back(x);
	coef[0]=1;
	for(int i=2;i<=n;i++) coef[i]=1ll*coef[i-2]*(i-1)%mod;
	dfs(1,0);
	for(int i=1;i<=n;i++) ans=(ans+1ll*f[1][i]*coef[i])%mod;
	printf("%d\n",(ans+mod)%mod);
}

Measured memory_bytes: 58556
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>

// std::vector<size_t> const neko{
//   0,
//   5, 2, 3, 2, 5, 2, 7, 2, 3, 2,
//   11, 2, 13, 2, 3, 2, 17, 2, 19, 2,
//   3, 2, 23, 2
// };

int testcase_ends() {
  size_t n;
  scanf("%zu", &n);
  if (n == 0) return 1;

  std::vector<std::vector<intmax_t>> dp(5, std::vector<intmax_t>(1, 0));
  dp[0].resize(2*2*2*2*3*3*5*7*11);
  dp[1].resize(13);
  dp[2].resize(17);
  dp[3].resize(19);
  dp[4].resize(23);

  for (size_t i = 0; i < n; ++i) {
    size_t d, t;
    scanf("%zu %zu", &d, &t);
    std::vector<intmax_t> q(d);
    for (auto& qi: q) scanf("%jd", &qi);

    size_t ind = 0;
    if (d == 13) {
      ind = 1;
    } else if (d == 17) {
      ind = 2;
    } else if (d == 19) {
      ind = 3;
    } else if (d == 23) {
      ind = 4;
    }
    size_t m = dp[ind].size();
    for (size_t j = 0; j < m; ++j)
      dp[ind][j%m] += q[(j+t)%d];
  }

  intmax_t res = 0;
  for (auto d: dp)
    res += *std::max_element(d.begin(), d.end());

  printf("%jd\n", res);
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int a, b, c;
    cin >> a >> b >> c;
    int res = 0;
    for (int i = a; i <= b; i++)
        if (c % i == 0)
            res++;
    cout << res << endl;
}



Measured memory_bytes: 3208
N = int(input())
A = list(map(int,input().split()))
flag = False
sum = 1

for i in A:
    if not flag:
        if sum*i > 10**18:
            flag = True
        else:
            sum *= i
    else:
        if i == 0:
            print(0)
            exit()
if flag:
    print(-1)
else:
    print(sum)


Measured memory_bytes: 21784
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}



template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WG = vector< Edges< T > >;
using UG = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;


template< typename T >
struct StronglyConnectedComponents {
  const WG<T> &g;
  UG gg, rg;
  vector< int > comp, order, used;

  StronglyConnectedComponents(WG<T> &g) : g(g), gg(g.size()), rg(g.size()), comp(g.size(), -1), used(g.size()) {
    for(int i = 0; i < g.size(); i++) {
      for(auto e : g[i]) {
        gg[i].emplace_back((int) e.to);
        rg[(int) e.to].emplace_back(i);
      }
    }
  }

  int operator[](int k) {
    return comp[k];
  }

  void dfs(int idx) {
    if(used[idx]) return;
    used[idx] = true;
    for(int to : gg[idx]) dfs(to);
    order.push_back(idx);
  }

  void rdfs(int idx, int cnt) {
    if(comp[idx] != -1) return;
    comp[idx] = cnt;
    for(int to : rg[idx]) rdfs(to, cnt);
  }

  void build(UG &t) {
    for(int i = 0; i < gg.size(); i++) dfs(i);
    reverse(begin(order), end(order));
    int ptr = 0;
    for(int i : order) if(comp[i] == -1) rdfs(i, ptr), ptr++;

    t.resize(ptr);
    for(int i = 0; i < g.size(); i++) {
      for(auto &to : g[i]) {
        int x = comp[i], y = comp[to];
        if(x == y) continue;
        t[x].push_back(y);
      }
    }
  }
};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,m;
  cin>>n>>m;
  WG<int> es(n);
  rep(i,m){
    int x,y;
    cin>>x>>y;
    es[x].PB(edge<int>(y,1));
  }
  UG v;
  StronglyConnectedComponents<int> scc(es);
  scc.build(v);
  int q;
  cin>>q;
  while(q--){
    int a,b;
    cin>>a>>b;
    cout<<(scc[a]==scc[b])<<endl;
  }


}


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

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

    int n, m, ans = 0;
    string str;
    unordered_map<string, int> s;

    cin >> n;

    while(n--){
        cin >> str;
        s[str]++;
    }

    cin >> m;

    while(m--){
        cin >> str;
        s[str]--;
    }

    pair<string, int> p;
    for(auto p : s)
        ans = max(p.second, ans);
    
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    #ifdef TarekHasan
        freopen("input.txt","r",stdin);
    #endif // TarekHasan
    int n,x,y;  cin >> n >> x >> y;

    unordered_map< int , vector< int > > adjacentList;

    for(int i=1;i<n;i++)
    {
        adjacentList[i].push_back(i+1);
        adjacentList[i+1].push_back(i);
    }
    adjacentList[x].push_back(y);
    adjacentList[y].push_back(x);

    unordered_map< int , int > mp;

    for(int i=1;i<n;i++)
    {
        int dist[n+1]={0};
        int visited[n+1]={0};
        queue< int > q;
        q.push(i);
        dist[i]=0;
        visited[i]=1;

        while(!q.empty())
        {
            int top = q.front();
            q.pop();

            for(int x : adjacentList[top])
            {
                if(visited[x]==0)
                {
                    visited[x]=1;
                    dist[x]=dist[top]+1;
                    q.push(x);
                }
            }
        }

        for(int j=i+1;j<=n;j++)
            mp[dist[j]]++;
    }

    for(int i=1;i<n;i++)
        cout << mp[i] << endl;


    return 0;
}


Measured memory_bytes: 3892
import java.util.*

fun main(args : Array<String>) {
    println(inOutExec(Scanner(System.`in`)))
}

fun inOutExec(scanner: Scanner): String {
    val a = scanner.nextInt()
    val b = scanner.nextInt()

    return when {
        (a > b) -> "a > b"
        (a == b) -> "a == b"
        (a < b) -> "a < b"
        else -> ""
    }
}


Measured memory_bytes: 25616
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    k = II()
    a, b = MI()

    for n in range(a, b+1):
        if n % k == 0:
            print('OK')
            return
    print('NG')


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9188
n = int(input())
s = list(str(input()))

ans = 0
for i in range(1,n-1):
    sr = 0
    sg = 0
    sb = 0
    er = 0
    eg = 0
    eb = 0

    for j in range(i):
        if s[j] != s[i]:
            if s[j] == "R":
                sr += 1
            elif s[j] == "G":
                sg += 1
            else:
                sb += 1
        pass
    for j in range(i+1,n):
        if s[j] != s[i]:
            if s[j] == "R":
                er += 1
            elif s[j] == "G":
                eg += 1
            else:
                eb += 1
    ans += sr*eb + sr*eg + sg*eb + sg*er + sb*er + sb*eg
    for j in range(min(i,n-i-1)):
        if s[i+j+1] != s[i-j-1] and s[i+j+1] != s[i] and s[i] != s[i-j-1]:
            ans -= 1
    # print(i,ans)

print(ans)

Measured memory_bytes: 69416
#include <stdio.h>
#include <stdlib.h>
int c(const void *v1,const void *v2){
    return *(int *)v1-*(int *)v2;
}

int main(void){
    int i,n,line[10000];
    long long sum;
    for(;sum=0,scanf("%d",&n),n;){
        for(i=0;i<n;i++)
            scanf("%d",&line[i]);
        qsort(line,n,sizeof(int),c);
        for(i=0;i<n;i++){
            sum+=line[i]*(n-i-1);
        }
        printf("%lld\n",sum);
    }
    return 0;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> 
#include<ext/pb_ds/tree_policy.hpp> 
#define int long long int
#define all(v) v.begin(),v.end() 
#define rev(v) v.rbegin(),v.rend()
#define ssd ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define inp 100005
#define en "\n"
using namespace std;
using namespace __gnu_pbds;

signed main() 
{
    ssd
    int n,i,j,k;
    cin>>n>>k;
    vector<int> v(n+5), dp(n+5,INT_MAX);
    for(i=1; i<=n; i++) cin>>v[i];
    
    dp[1] = 0;
    for(i=2;i<=n;i++)
    {
        for(j=1;j<=k;j++)
        {
            if(i-j>0)
            {
                dp[i] = min(dp[i], dp[i-j]+abs(v[i]-v[i-j]));
            }
            else break;
        }
    }
    cout<<dp[n];
    return 0;           
}

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

#define MAX 100010

int dp[MAX][3];

int a[MAX][3];

int main(){
	int n;	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++)cin>>a[i][j];
		// a[i], b[i], c[i] をa[i][0], a[i][1], a[i][2] とする。
	}

	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(j==k)continue;
				dp[i+1][k]=max(dp[i+1][k],  dp[i][j] + a[i][k]);
			}
		}
	}

	int ans=0;
	for(int i=0;i<3;i++){
		ans=max(ans, dp[n][i]);
	}

	cout<<ans<<endl;

	

	return 0;
}


Measured memory_bytes: 2560
using System;
using System.Linq;

class F
{
	static void Main()
	{
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int m = a[0], k = a[1], pm = (int)Math.Pow(2, m);

		if (k >= pm) { Console.WriteLine(-1); return; }
		if (m == 1) { Console.WriteLine(k == 0 ? "0 0 1 1" : "-1"); return; }
		var ek = new[] { k };
		var er = Enumerable.Range(0, pm).Where(x => x != k);
		Console.WriteLine(string.Join(" ", ek.Concat(er).Concat(ek).Concat(er.Reverse())));
	}
}


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

using namespace std;

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int s, w;
    cin >> s >> w;
    if(s > w)
    {
        cout << "safe\n";
    }
    else
    {
        cout << "unsafe\n";
    }
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <functional>
#include <typeinfo>
#include <utility>
#include <tuple>
#include <queue>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define yn(formula) (formula) ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(formula) (formula) ? (cout << "YES" << endl) : (cout << "NO" << endl)

#define PI 3.14159265358979323846
#define INF 1050000000
#define MOD 1000000007
#define EPS (1e-10)

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pii> vp;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vp> vvp;

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

/*<ここから>***********************************************************/






int main()
{
	int N;
	cin >> N;
	vi C(N - 1), S(N - 1), F(N - 1);
	rep(i, N - 1) cin >> C[i] >> S[i] >> F[i];

	rep(i, N) {

		int time = 0;

		repr(j, i, N - 1) {
			if (time < S[j]) time = S[j];
			else if (time % F[j] != 0) time = time + F[j] - time % F[j];
			time += C[j];
		}

		cout << time << 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++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int a,b,c,x,y;cin>>a>>b>>c>>x>>y;
  int ans=1e9;
  for(int i=0;i<=max(x,y);i++){
    int cnt=2*i*c+max(x-i,0)*a+max(y-i,0)*b;
    ans=min(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

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

  vector<int> a(n);
  a[0] = b[0];
  FOR(i, 1, n - 1) {
    a[i] = min(b[i - 1], b[i]);
  }
  a[n - 1] = b[n - 2];

  int ans = 0;
  rep(i, n) ans += a[i];
  cout << ans << endl;

  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using Complex = complex<double>;


int D, G;
int p[20], c[20];
int dp[20][105510];


signed main(){
    cin >> D >> G, G/=100;
    rep(i, 0, D) cin >> p[i] >> c[i], c[i]/=100;

    repe(i, 0, D) fill(RNG(dp[i], 0, 105510), INF);

    dp[0][0] = 0;
    rep(i, 0, D){
        repe(j, 0, G){
            if(dp[i][j] == INF) continue;
            rep(k, 0, p[i]) chmin(dp[i+1][min(j+(i+1)*k, G)], dp[i][j]+k);
            chmin(dp[i+1][min(j+(i+1)*p[i]+c[i], G)], dp[i][j]+p[i]);
        }
    }

    int ans = INF;
    repe(i, 0, D) chmin(ans, dp[i][G]);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 10496
import sys
from io import StringIO
import unittest


def resolve():
    a, b = map(int, input().split())

    ans = 0
    tmp = 1

    while tmp < b:
        ans += 1
        tmp += a - 1

    print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """4 10"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """8 9"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """8 8"""
        output = """1"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

int main()
{
	int n;
	cin>>n;
	int m;
	cin>>m;
	vector<int> a(n);
	long long sum=0;
	for(int i=0;i<n;i++) 
	{
		cin>>a[i];
		sum+=a[i];
	}
	int MIN = *min_element(a.begin(),a.end());
	cout<< n + (m-sum)/MIN;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i,j) for(int i=0;i<j;i++)
int dp[1000][4][4];int yotei[101][3]={{0},{0}};
const int INF=454354643;
	int n,k;
	
	int dfs(int day,int now,int mae){
		if(dp[day][now][mae]!=0)return dp[day][now][mae];
		if(day==n){return 1;}
		int sum=0;
		if(yotei[day+1][1]==1||yotei[day+1][2]==1||yotei[day+1][3]==1){
			for(int i=1;i<=3;i++){
				if(yotei[day+1][i]==1){
					if(mae!=i||now!=i){
						sum+=dfs(day+1,i,now);
					}
					else now= 0;
				}
			}
		}
		else {
		if(mae!=1||now!=1&&yotei[day+1][1]!=1)sum+=dfs(day+1,1,now);
		if(mae!=2||now!=2&&yotei[day+1][2]!=1)sum+=dfs(day+1,2,now);
		if(mae!=3||now!=3&&yotei[day+1][3]!=1)sum+=dfs(day+1,3,now);
		}
		return dp[day][now][mae]=sum%10000;
	}
	
int main(){
	cin>>n>>k;
	REP(i,1000)REP(j,4)REP(k,4)dp[i][j][k]=0;
	for(int i=0;i<k;i++){
		int a,b;
		cin>>a>>b;
		yotei[a][b]=1;
	}
	cout<<dfs(0,0,0)%10000<<endl;
	return 0;
}

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

int n;
int ans = 0;
void dfs(string s){
	int three = 0;
	int five = 0;
	int seven = 0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='3') three++;
		if(s[i]=='5') five++;
		if(s[i]=='7') seven++;
	}
	if(three>0 && five>0 && seven>0 && stoll(s)<=n) ans++;
	if(s.size()==9) return;
	dfs('3'+s);
	dfs('5'+s);
	dfs('7'+s);
}
int main() {
	cin >> n;
	dfs("");
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  int query;
  cin>>query;
  for(auto&& cs:irange(0,query)) {
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    --a;--b;--c;--d;
    ll p3 = 1;
    ll mx = 0;
    for(auto&& i:irange(0,30)) {
      ll l = min(a, c) / (p3*3);
      ll m = min(b, d) / (p3*3);
      ll ofs1 = l*3*p3 + p3;
      ll ofs2 = m*3*p3 + p3;
      if (ofs1 <= min(a,c) && max(a,c) < ofs1+p3 && (min(b,d) + 2*p3) / (3*p3) < (max(b,d) + 2*p3) / (3*p3)) {
        mx = max(mx, p3);
      }
      if (ofs2 <= min(b,d) && max(b,d) < ofs2+p3 && (min(a,c) + 2*p3) / (3*p3) < (max(a,c) + 2*p3) / (3*p3)) {
        mx = max(mx, p3);
      }
      p3 *= 3;
    }
    ll ans = abs(a-c) + abs(b-d);
    if (mx == 0) {
      cout<<ans<<'\n';
      continue;
    }
    p3 = mx;
    ll l = min(a, c) / (p3*3);
    ll m = min(b, d) / (p3*3);
    ll ofs1 = l*3*p3 + p3;
    ll ofs2 = m*3*p3 + p3;
    if (ofs1 <= min(a,c) && max(a,c) < ofs1+p3 && (min(b,d) + 2*p3) / (3*p3) < (max(b,d) + 2*p3) / (3*p3)) {
      ll x = a-ofs1+1+c-ofs1+1;
      ll y = ofs1+p3-a+ofs1+p3-c;
      ans = max(ans, min(x,y)+abs(b-d));
    }
    if (ofs2 <= min(b,d) && max(b,d) < ofs2+p3 && (min(a,c) + 2*p3) / (3*p3) < (max(a,c) + 2*p3) / (3*p3)) {
      ll x = b-ofs2+1+d-ofs2+1;
      ll y = ofs2+p3-b+ofs2+p3-d;
      ans = max(ans, min(x,y)+abs(a-c));
    }
    cout<<ans<<'\n';
  }
  cout<<flush;
  return 0;
}


Measured memory_bytes: 384
/*
 * src.cpp
 *
 *  Created on: 2016/09/07
 *      Author: joi
 */

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

const int MAX_W=500,MAX_H=500;

int W,H;
char a[MAX_H][MAX_W+1],b[MAX_H][MAX_W+1],c[MAX_H][MAX_W+1];

int main(){
	scanf("%d %d",&H,&W);
	REP(i,H){
		scanf("%s",a[i]);
	}
	REP(i,H){
		REP(j,W){
			b[i][j]=c[i][j]='.';
		}
	}
	REP(i,H){
		b[i][0]=c[i][W-1]='#';
	}
	REP(i,H){
		FOR(j,1,W-1){
			if (i%2==0){
				b[i][j]='#';
			}else{
				c[i][j]='#';
			}
		}
	}
	REP(i,H){
		REP(j,W){
			if (a[i][j]=='#'){
				b[i][j]=c[i][j]='#';
			}
		}
	}
	REP(i,H){
		printf("%s\n",b[i]);
	}
	printf("\n");
	REP(i,H){
		printf("%s\n",c[i]);
	}
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

vs input(string& s)
{
	int t = s.find('-');
	string l = s.substr(0, t);
	string r = s.substr(t + 1);
	vs res;
	res.push_back(l); res.push_back(r);
	return res;
}

int main()
{
	int n;
	while (cin >> n, n)
	{
		vector<vs> v(n);
		map<string, int> mp;
		REP(i, n)
		{
			string s; cin >> s;
			v[i] = input(s);
		}
		int p = 0;
		REP(i, n)REP(j, 2)
		{
			string tmp = v[i][j];
			if (mp.count(tmp)) continue;
			mp[tmp] = p;
			p++;
		}
		cout << p << endl;
		Graph g(p);
		Matrix dist(p, Array(p));
		REP(i, n)
		{
			int l = mp[v[i][0]], r = mp[v[i][1]];
			add_edge(g, l, r, 1);
			add_edge(g, r, l, 1);
			dist[r][l] = 1;
		}
		vector<pii> same;
		REP(i, p)REP(j, i)
		{
			bool f1 = false, f2 = true;
			REP(k, p)
			{
				if ((dist[i][k] || dist[k][i]) && (dist[j][k] || dist[k][j])) f1 = true;
				if ((dist[i][k] && dist[k][j]) || (dist[k][i] && dist[j][k])) f2 = false;
			}
			if (f1&&f2) same.emplace_back(i, j);
		}
		for (auto i : same)
		{
			dist[i.first][i.second] = 1;
			dist[i.second][i.first] = 1;
		}
		REP(k, p)REP(i, p)REP(j, p)
		{
			if (dist[i][k] && dist[k][j]) dist[i][j] = 1;
		}
		vi color(p);
		int col = 1;
		REP(i, p)
		{
			if (color[i]) continue;
			queue<int> que;
			que.push(i);
			int c = col, d = -col;
			color[i] = c;
			while (que.size())
			{
				int t = que.front();
				que.pop();
				int nx = (color[t] == c ? d : c);
				REP(j, g[t].size())
				{
					if (color[g[t][j].to]) continue;
					color[g[t][j].to] = nx;
					que.push(g[t][j].to);
				}
			}
			col++;
		}
		int q;
		cin >> q;
		REP(i, q)
		{
			string s; cin >> s;
			vs t = input(s);
			if (!mp.count(t[0]) || !mp.count(t[1]))
			{
				puts("NO");
				continue;
			}
			int l = mp[t[0]], r = mp[t[1]];
			if (color[l] == -color[r] && dist[r][l])
			{
				puts("YES");
			}
			else
			{
				puts("NO");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3304
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    string s;
    string t;
    cin >> s;
    cin >> t;
    int slen = s.length();
    int tlen = t.length();
    int count = 0;
    for(int i = i; i < slen; i++){
        if(s[i] != t[i]){
            count++;
        }
        else{
            continue;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3916
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(c,i) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	int r_count=0,d_count=0;
	for(int a,b,c;scanf("%d,%d,%d",&a,&b,&c)==3;){
		bool rectangle=a*a+b*b==c*c;
		bool diamond=a==b;
		if(rectangle && diamond)
			;
		else if(rectangle)
			r_count++;
		else if(diamond)
			d_count++;
	}
	cout<<r_count<<endl;
	cout<<d_count<<endl;
	
	return 0;
}

Measured memory_bytes: 0
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    List<Integer> list = new LinkedList<>();
    for (int i = 0; i < N; i++) {
      list.add(scan.nextInt());
    }
    int maxHeight = 0;
    int count = 0;
    for (int h : list) {
      if (h >= maxHeight) {
        count++;
        maxHeight = h;
      }
    }

    System.out.println(count);
  }
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,29)-1;


int main() {
  int N; cin >> N;
  int d[N]; rep(i,N) cin >> d[i];
  sort(d,d+N);
  int result = d[N/2] - d[N/2-1];
  cout << result << endl;
  return 0;
}

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

using namespace std;

int main(){
	int r,w,c,rx;
	while(cin >> r >> w >> c >> rx,r){
		int add_base = 0;
		while((r+rx*add_base)/w < c){
			add_base++;
		}
		cout << add_base << endl;
	}
	
	return 0;
}

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

W = [0]*N
B = [0]*N
white = 0
black = 0

for i in range(N):
    if S[i] == '.':
        white += 1
    if S[-i-1] == '#':
        black += 1

    W[i] = white
    B[-i-1] = black

ans = N - max(white, black)
for i in range(N-1):
    tmp = abs((i+1)-W[i]) + abs((N-i-1)-B[i+1])
    if tmp < ans:
        ans = tmp

print(ans)

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

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    long long int ans = 0;
    for(long long int i=0; i<s.length(); i++){
        ans += (s[i]-'0');
    }
    if(ans%9==0) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int x, y;
  cin >> x >> y;
  rep(i, 101){
    int j = x - i;
    if(j < 0) continue;
    int ii = i * 2;
    int jj = j * 4;
    if(ii + jj == y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
int main(void){

 int a,b;
 scanf("%d%d",&a,&b);
 if(a < b){
 printf("a < b\n");
 }else if(a > b){
 printf("a > b\n");
 }else{
 printf("a == b\n");
}

 return 0;

} 

Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
int n;
double d;
long long x[200010];
long long y[200010];
int main(){
	cin>>n>>d;
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i];
	}
	int cnt=0;
	for(int i=0;i<n;i++){
		double k=sqrt(x[i]*x[i]+y[i]*y[i]);
		if(k<=d){
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 6876
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 300003
#define MOD 1000000007
#define INF 1000000000000000000
using Graph=vector<vector<int>>;

int main(){
  string S;
  cin>>S;
  if(S=="ABC"){
    cout<<"ARC"<<endl;
  }else{
    cout<<"ABC"<<endl;
  }
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<vector>
#include<cstdio>
#define MAXN 2555
#define INF 0x3f3f3f3f
#define v first
#define b second
using namespace std;
int fp[15][15];
int m;
void floyd()
{
   for(int i=0;i<m;i++)
      for(int j=0;j<m;j++)
      for(int k=0;k<m;k++)
   {
      fp[j][k]=min(fp[j][k],fp[j][i]+fp[i][k]);
   }
}
int main()
{
   int n;
   while(scanf("%d",&n),n)
   {
      m=0;
      memset(fp,INF,sizeof(fp));
      for(int i=0;i<n;i++)
      {
         int a,b,c;
         scanf("%d%d%d",&a,&b,&c);
         fp[a][b]=fp[b][a]=c;
         m=max(m,max(a,b)+1);
      }
      for(int i=0;i<m;i++)
         fp[i][i]=0;
      floyd();
      int ans,sum=INF;
      for(int i=0;i<m;i++)
      {
         int res=0;
         for(int j=0;j<m;j++)
         {
            res+=fp[i][j];
         }
         if(res<sum)
         {
            sum=res;
            ans=i;
         }
      }
      cout<<ans<<" "<<sum<<endl;
   }
}

Measured memory_bytes: 3152
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n, ti = 0;
    scanf("%d", &n);
    vector<vector<int>> a(n);
    vector<int> vis(n, 0), lea(n, 0), sea(n, 0);
    for (int i = 0, u, k; i < n; i++)
    {
        scanf("%d %d", &u, &k);
        u--;
        for (int j = 0, v; j < k; j++)
        {
            scanf("%d", &v);
            v--;
            a[u].push_back(v);
        }
    }
    for (int i = 0; i < n; i++)
    {
        if (!vis[i])
        {
            stack<int> b;
            b.push(i);
            for (int t; !b.empty(); )
            {
                t = b.top();
                if (!vis[t])
                {
                    vis[t] = ++ti;
                }
                for (; sea[t] < a[t].size(); sea[t]++)
                {
                    if (!vis[a[t][sea[t]]])
                    {
                        b.push(a[t][sea[t]]);
                        break;
                    }
                }
                if (sea[t] >= a[t].size())
                {
                    b.pop();
                    lea[t] = ++ti;
                }
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        printf("%d %d %d\n", i + 1, vis[i], lea[i]);
    }
}


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

int main(void){
    string w;
    vector<int> cnt(26, 0);
    cin >> w;
    for (int i=0; i<w.size(); i++) cnt[w[i]-'a']++;
    for (int i=0; i<26; i++){
        if (cnt[i]%2 != 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3504
#include <stdio.h>

int main(void)
{
 unsigned long long N,M;
 scanf("%llu %llu",&N,&M);
 if(N>1&&M>1){

 printf("%llu\n",(N-2)*(M-2));

 }else{
 	
 	if(N==1&&M==1){
 		printf("1\n");
 	}else{
 	
 	if(N==1){
 		 printf("%llu\n",M-2);
 	}else{
 		 printf("%llu\n",N-2);
 	}
 	}
 }
	return 0;
}

Measured memory_bytes: 128
N, M = map(int, input().split())
Vs = [ list(map(int, input().split())) for _ in range(M)]

d = dict()

for v in Vs:
    if v[0] in d:
        d[v[0]].append(v[1])
    else:
        d[v[0]] = [v[1]]

for k, v in d.items():
    s = sorted(v)
    d[k] = s


ans = dict()
for k, v in d.items():
    for i in range(len(v)):
        a = v[i]
        ans[(str(k)+'-'+str(a))]  = i+1

for v in Vs:
    a = ans[(str(v[0])+'-'+str(v[1]))]
    print(str(v[0]).zfill(6) + str(a).zfill(6))

Measured memory_bytes: 57764
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

// Pfs :　素因数分解し、スライスを作成
func Pfs(n int) (pfs []int) {
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

// PfsMap : 素因数分解し、マップを作成
func PfsMap(n int) map[int]int {
	pfs := make(map[int]int)
	for n%2 == 0 {
		pfs[2] = pfs[2] + 1
		n = n / 2
	}

	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs[i] = pfs[i] + 1
			n = n / i
		}
	}

	if n > 2 {
		pfs[n] = pfs[n] + 1
	}

	return pfs
}

func solve(N int) int {
	ans := 1000000000
	for i := 1; i <= N; i++ {
		for j := 1; j <= N; j++ {
			if i*j == N {
				ans = min(ans, i+j-2)
			}
		}
	}
	return ans
}

// 約数を列挙
func divisor(n int) []int {
	ret := []int{}
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			ret = append(ret, i)
			// if i*i != n {
			ret = append(ret, n/i)
			// }
		}
	}
	return ret
}

func solve2(N int) int {
	x := divisor(N)
	n := len(x)
	a := x[n-1]
	b := x[n-2]
	return a + b - 2
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	ans2 := solve2(N)
	out(ans2)
}


Measured memory_bytes: 896
a=int(input())
n_l=list(map(int,input().split()))
m_l=[]
i=0
for n in range(0,a-1):
    if n_l[n]>=n_l[n+1]:
        i+=1
    else:
        m_l.append(i)
        #print(i)
        i=0
m_l.append(i)



print(max(m_l))

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#define ll long long
#define s string
#define d double
using namespace std;
int main()
{
  ios_base::sync_with_stdio (false);
  cin.tie (NULL);
  int a, b;
  cin>>a>>b;
  if(a>b)
  {
      int c = 2*b;
      int e = a-c;
      if(e<0) cout<<"0"<<endl;
      else cout<<e<<endl;
  }
  else cout<<"0"<<endl;



  return 0;
}


Measured memory_bytes: 256
k,x = gets.split.map(&:to_i)
arr = [x]
counter_plus = 0
counter_minus = 0

if k == 1
  puts x
else
  (k-1).times do
    counter_plus += 1
    counter_minus -=  1
    arr << (x+counter_plus)
    arr << (x+counter_minus)
end

arr.sort.each{|v|
p v}
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define ll  long long
#define endl '\n'
const ll N=1e5+7;
void solve()
{
  ll n, a,m=0,b=-1, c=0,k=0, i, j,l=1e9+7;
  string s;
  cin>>n;
  ll ar[n+1];
  rep(i,1,n+1)
    {
      cin>>ar[i];
      if(i%2 && ar[i]%2) c++;
    }
    cout<<c<<endl;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
  //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
typedef pair<int, int> P;

class stack{
  public:
  P v[22222];
  int t;
  stack(){
    t = 0;
    v[0] = P(-1, -1);
  }
  stack(P zero){
    t = 0;
    v[0] = zero;
  }
  void push(P a){
    t++;
    v[t] = a;
  }
  void pop(){
    t--;
  }
  P top(){
    return v[t];
  }
  void pr(){
    for(int i = 1; i <= t; i++){
      cout << v[i].second << " ";
    }
    cout << endl;
  }
  bool empty(){
    return t == 0;
  }
};

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string str; cin >> str;
  vector<int> height(str.length()+1);
  vector<int> lmax(str.length()+1), rmax(str.length()+1);
  height[0] = 0;
  for(int i=1; i <= str.length(); i++){
    if(str[i-1] == '\\'){
      height[i] = height[i-1] - 1;
    }
    if(str[i-1] == '/'){
      height[i] = height[i-1] + 1;
    }
    if(str[i-1] == '_'){
      height[i] = height[i-1];
    }
  }
  int mv = INT_MIN;
  for(int i = 0; i < height.size(); i++){
    mv = max(mv, height[i]);
    lmax[i] = mv;
  }
  mv = INT_MIN;
  for(int i = height.size()-1; i >= 0; i--){
    mv = max(mv, height[i]);
    rmax[i] = mv;
  }

  stack s;
  vector<int> l;
  int ans = 0;
  int anstmp = 0;
  P now(0, 0); //x, height
  for(int i = 0; i < str.length(); i++){
    now.first++;
    if(str[i] == '\\'){
      s.push(now);
      now.second--;
    }
    if(str[i] == '/'){
      now.second++;
      if(s.empty()) continue;
      if(s.top().second == now.second){
        int d = now.first - s.top().first;
        s.pop();
        ans += d;
        anstmp += d;
        if(!(lmax[now.first] > now.second && rmax[now.first] > now.second)){
          l.push_back(anstmp);
          anstmp = 0;
        }
      }
    }
    if(str[i] == '_'){
      if(s.empty()) continue;
      if(s.top().second == now.second){
        int d = now.first - s.top().first;
        s.pop();
        ans += d;
        anstmp += d;
        if(!(lmax[now.first] > now.second && rmax[now.first] > now.second)){
          l.push_back(anstmp);
          anstmp = 0;
        }
      }
    }
  }
  cout << ans << endl;
  if(l.size() == 0){
    cout << l.size() << endl;
  }else{
    cout << l.size() << " ";
    for(int i = 0; i < l.size(); i++){
      if(i == l.size()-1){
        cout << l[i] << endl;
      }else{
        cout << l[i] << " ";
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1628
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main() {
    string s, t;
    cin >> s >> t;
    sort(all(s));
    sort(rall(t));

    Yn(s < t);

    return 0;
}


Measured memory_bytes: 256
/*
Author : N_o_o_B
Created : May 02 2020 17:44:05 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

    ll x;
    cin >> x;
    ll lo = 1,hi = 3760;
    ll ans=-1;
    while(lo <= hi){
        ll mid = (lo+hi)/2;
        ll can = 100;
        rep(i,1,mid){
            can += can/100;
        }
        if(can >= x){
            ans = mid;
            hi = mid-1;
        }
        else{
            lo = mid+1;
        }
    }
    cout << ans << endl;




    time_taken();
    return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N;
    string S;
    cin >> N >> S;

    if(N%2) cout << "No" << endl;
    else {
        string l="", r="";
        rep(i, S.size()/2) l+=S[i];
        FOR(i, S.size()/2, S.size()) r+=S[i];
        if(l==r) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
a = int(input())

b = [0 for _ in range(10050)]
for x in range(1,105):
  for y in range(1,105):
    for z in range(1,105):
      n = x**2+y**2+z**2+x*y+y*z+x*z
      if n<10050:
        b[n] += 1
      
for i in range(a):
  print(b[i+1])
  

Measured memory_bytes: 9320
#include <bits/stdc++.h>
using namespace std;
using vec2div = vector<vector<long long>>;

int main(){
	long long x,y,z;
	cin >> x >> y >> z;
	cout << z << ' '<< x <<' '<< y << endl;

	long long i;
	for(i=0;i<1;i++){
		
	}
	

}

Measured memory_bytes: 3624