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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


typedef pair<ii, int> Edge;

vector<ii> to3(int x) {
    vector<ii> res;
    for (int i=0; x>0; ++i) {
        res.pb(ii(i, x%3));
        x /= 3;
    }
    return res;
}
vi pow3;

vector<Edge> edges;


inline void add_edge(int u, int v, int w) {
    edges.push_back(Edge(ii(u, v), w));
}

void solve(int L) {
    pow3.clear();
    for (int i=0,p=1; p<=1000000; ++i,p*=3) pow3.pb(p);

    edges.clear();

    vector<ii> x = to3(L);
    reverse(ALL(x));
#ifdef DEBUG
    // cerr << L << " " << x << endl;
#endif

    int M = x.size();

    int last = 0;
    for (int node=0,w=1; node<M-1; ++node,w*=3) { // 12, 12*2
        rep(j, 3) {
            add_edge(node, node+1, w*j);
        }
        last = node+1;
    }
    assert(last == M-1);

    if (x[0].second == 1) --M;

    int ofs = 0;
    for (ii xi : x) {
        int i=xi.first, p=pow3[i], n=xi.second;
        if (n == 0) continue;
        if (ofs == 0 && n == 1) {
            ofs += p; continue;
        }
        for (int j=0; j<n; ++j) {
            add_edge(i, M, ofs + p*j);
        }
        ofs += p*n;
    }

    printf("%d %d\n", M+1, (int)edges.size());
    for (Edge e : edges){
        int u = e.first.first, v = e.first.second, w = e.second;
        printf("%d %d %d\n", 1+u, 1+v, w);
    }
}

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


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[1000][1000];
const int t=2927;
int main(int argc, char** argv) {
	int n,m,h,w,sum=0;
	cin >> n >> m >> h >> w;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			sum+=t,a[i][j]=t;
	for(int i=h;i<=n;i+=h)
		for(int j=w;j<=m;j+=w)
			a[i][j]=-t*h*w-1+t,sum+=a[i][j],sum-=t;
	if(sum<0)
	{
		puts("No");
		return 0;
	}
	puts("Yes");
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
			cout << a[i][j] << " ";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3584
N = int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

X = factorization(N)
#print(X)
ans = 0
for a,b in X:
    tmp = 0
    for i in range(1,100):
        if b < i:
            break
        else:
            b -= i
            ans += 1
if N == 1:
    ans = 0
print(ans)

Measured memory_bytes: 9492
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
#define ll long long

signed main() {
  int n;
  cin >>n;
  vector<int> a(n+1);
  rep(i,n+1) cin >> a[i];
  vector<pair<int,int>> p(n+1);
  p[n] = {a[n],a[n]};
    //cout << n<<" "<<a[n]<<" "<<a[n] << endl;
  rrep(i,n) {
    p[i] = {(p[i+1].first+1)/2+a[i], p[i+1].second+a[i]};
    //cout << i<<" "<<(a[i+1]+1)/2+a[i]<<" "<<a[i+1]+a[i] << endl;
  } 
  if(p[0].first!=1) {
    cout << -1 << endl;
    return 0;
  }
  int ans = 0;
  int now = 1;
  rep(i,n+1) {
    ans += min(p[i].second,now);
    now =2*(min(p[i].second,now)-a[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5616
a,b,c = map(int, input().split())

ans_set = set()
a,b,c = sorted([a,b,c])
ans_set.add((a,b,c))

ans = 0
for i in range(10**6):
    # 奇数の数確かめる
    odd = sum([i%2 == 1 for i in [a,b,c]])
    
    if odd > 0:
        print(ans)
        break
        
    else:
        a,b,c = a//2, b//2, c//2
        a,b,c = b+c, c+a, a+b
        a,b,c = sorted([a,b,c])
        
        if (a,b,c) in ans_set:
            print(-1)
            break
            
        else:
            ans_set.add((a,b,c))
            
            ans += 1

Measured memory_bytes: 3064
str1 = input()
if str1 == 'RRR':
    print(3)
elif str1 == 'SSS':
    print(0)
else:
    for i in range(len(str1) - 1):
        if str1[i] == str1[i+1] == 'R':
            flag = 0
            break
        else:
            flag = 1
    if flag == 0:
        print(2)
    else:
        print(1)

Measured memory_bytes: 8904
#include<cstdio>
#include<cmath>
#define reg register

const double PI=acos(-1);

double a,b,x;

inline void Read(void);

int main(void){
	reg double y,ans;
	scanf("%lf%lf%lf",&a,&b,&x);
	if(a*b/2.0*a>=x){
		y=((2.0*x)/(a*b));
		ans=atan(b/y)/PI*180.0;
	}
	else{
		y=2*x/(a*a)-b;
		ans=atan((b-y)/a)/PI*180;
	}
	printf("%.10f\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using P=pair<int, int>;
#define ll long long
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int main(){
    fast_io

    string s, t;
    cin>>s>>t;
    int ans=0;
    rep(i, s.size()){
        if(s[i]==t[i]) continue;
        ans++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define lint long long
#define int long long
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
const int N=2e5+5, MOD=1e9+7;
using namespace std;
using namespace __gnu_pbds;
template <typename T> 
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int n, p[N], lst[N], mxd[N], mxd2[N], d[N];
vector<int> dp[N][2], cnt[N], adj[N];
inline int modpow(lint base, int exp, int modulo) {
  base %= modulo;  lint result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulo;
    base = (base * base) % modulo; exp >>= 1;
  }
  return result;
}
void dfsinit(int u)
{
    vector<int> depths;
    depths.pb(d[u]);
    for(auto v: adj[u])
    {
        d[v]=d[u]+1;
        dfsinit(v);
        depths.pb(mxd[v]);    
    }
    sort(depths.begin(), depths.end());
    mxd[u] = depths.back();
    if(depths.size() > 1) mxd2[u] = depths[depths.size()-2];
    else mxd2[u] = d[u];
}
void dfs(int u)
{
    dp[u][1].pb(1);
    cnt[u].pb(1);
    vector<int> p0;
    for(int i = 0; i <= mxd2[u]-d[u]; i++)
    {
        p0.pb(1);
        if(i) cnt[u].pb(0);
        if(i) dp[u][1].pb(0);
    }
    vector<int> lsts;
    for(auto v: adj[u])
    {
        dfs(v);
        for(int i = d[u]+1; i <= min(mxd2[u], mxd[v]); i++)
        {
            lsts.pb(lst[i]);
            p0[i-d[u]]*=dp[lst[i]][0][i - d[lst[i]]];
            p0[i-d[u]]%=MOD;
            cnt[u][i-d[u]]+=cnt[lst[i]][i - d[lst[i]]];
        }
    }
    int itr=0;
    for(auto v: adj[u])
    {
        for(int i = d[u]+1; i <= min(mxd[v], mxd2[u]); i++)
        {
            int curr = p0[i-d[u]];
            curr*=dp[lsts[itr]][1][i - d[lsts[itr]]];
            curr%=MOD;
            curr*=modpow(dp[lsts[itr]][0][i - d[lsts[itr]]], MOD-2, MOD);
            curr%=MOD;
            dp[u][1][i-d[u]]+=curr;
            dp[u][1][i-d[u]]%=MOD;
            itr++;
        }
    }
    for(int i = d[u]; i <= mxd2[u]; i++)
    {   
        dp[u][0].pb((modpow(2, cnt[u][i-d[u]], MOD) - dp[u][1][i-d[u]] + MOD)%MOD); 
        lst[i]=u;
        // cout << u << " " << cnt[u][i-d[u]] << endl;
      //  cout << i << " - " << dp[u][0][i] << " " << dp[u][0][i] << endl;
    }
}
signed main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> p[i];
        adj[p[i]].pb(i);
    }
    d[0]=0;
    dfsinit(0);
    dfs(0);
    int ans = 0;
    for(int i = 0; i <= mxd[0]; i++)
    {
     //   cout << i << " - " << " " << dp[lst[i]][1][i - d[lst[i]]] << " " << n+1 - cnt[lst[i]][i - d[lst[i]]] << endl;
        ans+=dp[lst[i]][1][i - d[lst[i]]]*modpow(2, n+1 - cnt[lst[i]][i - d[lst[i]]], MOD);
        ans%=MOD;
    }
    //cout << cnt[0][4] << endl;
    cout << ans;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;

// ====================================================================

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

  // 可能か判定する
  bool can = true;
  for (int i = 0; i < n; i++) {
    if (v[i] > i + 1) can = false;
  }
  if (!can) {
    cout << -1 << endl;
    return 0;
  }

  // 左から逆算していく
  vector<int> ans;
  int now;
  while (v.size()) {
    for (int i = v.size() - 1; i >= 0; i--) {
      if (v[i] == i + 1) {
        now = i;
        break;
      }
    }
    ans.push_back(v[now]);
    v.erase(v.begin() + now);
  }

  // 答えを出力
  reverse(ans.begin(), ans.end());
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <deque>
#include <functional>
#include <initializer_list>
#include <math.h>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <queue>
#include <vector>

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); --(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define SORT(A) std::sort((A).begin(), (A).end())
#define ALL(A) (A).begin(), (A).end()
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())

using lli = long long int;
using pii = std::pair<int, int>;

void VintOut(std::vector<int>& A){
    const int n = A.size();
    if(n == 0){putchar('\n'); return;}
    printf("%d", A[0]);
    for(int i = 1; i < n; ++i) printf(" %d", A[i]);
    putchar('\n');
}
void VintOut(std::vector<long long int>& A){
    const int n = A.size();
    if(n == 0){ putchar('\n'); return;}
    printf("%lld", A[0]);
    for(int i = 1; i < n; ++i) printf(" %lld", A[i]);
    putchar('\n');
}

template <typename T>
inline bool chmin(T& a, T b){
    if(b < a){ a = b; return true;}
    return false;
}

template <typename T>
inline bool chmax(T& a, T b){
    if(a < b){ a = b; return true;}
    return false;
}

inline bool bitUP(int state, int k){ return (state >> k) & 1; }
inline bool bitUP(long long int state, int k){ return (state >> k) & 1;}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


int main(void){
    int n, a, b; scanf("%d%d%d", &n, &a, &b);
    if(not (a + b <= n + 1 and n <= lli(a) * lli(b))){ puts("-1"); return 0;}
    std::stack<int> A; std::stack<int> Stk;
    for(int y = b - 1; y >= 0; --y) A.push(n - y);
    for(int z = a; z <= n - b; ++z) Stk.push(z);
    int x = a - 1;
    while(x >= 1){
        A.push(x--);
        int cnt = 0; std::stack<int> T;
        while((not Stk.empty()) and cnt < b - 1){
            T.push(Stk.top()); Stk.pop(); cnt++;
        }
        while(not T.empty()){ A.push(T.top()); T.pop();}
    }
    std::vector<int> P(n);
    REP(i, n) P[i] = A.top(), A.pop();
    VintOut(P);    
    return 0;
}

Measured memory_bytes: 4588
#include <bits/stdc++.h>
using namespace std;
const int INF=1001001001;
int main() {
    string s;cin>>s;
    if(s[0]=='A'&s[1]=='B'|s[1]=='A'&s[2]=='B')cout<<"Yes"<<endl;
    else if(s[0]=='B'&s[1]=='A'|s[1]=='B'&s[2]=='A')cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
ll a,b,c,d,e,i,j;
    char g,h;
vector<ll>v;
 queue<char>q;
string s;
cin>>s;
  for(i=0;i<s.size();i++)
  {
   if(q.empty())
   {
   q.push(s[i]);
   }
    else
    {
    g=q.front();
if(g!=s[i])q.pop();
else q.push(s[i]);
    }
  }
cout<<s.size()-q.size()<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <algorithm>
#include <cctype>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=4e8;
const double pi=acos(-1);

ll n,ans;
vector<ll> dp,num;

int main(){
	while(1){
		cin>>n;
		if(!n) break;
		ans=-inf;
		dp=vector<ll>(n);
		num=vector<ll>(n);
		for(int i=0;i<n;i++) cin>>num[i];
		dp[0]=num[0];
		for(int i=0;i<n-1;i++) dp[i+1]=max(num[i+1],num[i+1]+dp[i]);
		for(int i=0;i<n;i++) ans=max(ans,dp[i]);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1304
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n,h; cin >> n >> h;
    vector<Pll> ab(n);
    priority_queue<Pll> pq,clear;
    rep(i,n){
        ll a,b; cin >> a >> b;
        ab[i] = Pll(a,b);
        pq.push(Pll(b,a));
    }
    ll temp = 0,res = 0;
    bool ok = true;
    while(pq.size() && temp < h){
        Pll t = pq.top();pq.pop();
        temp += t.first;
        res++;
    }
    if(temp < h)ok = false;
    sort(ab.begin(), ab.end(),
    [](auto const a, auto const b){
        return (a.first < b.first) || (a.first == b.first && a.second > b.second);
    });
    Pll katana = ab.back();ab.pop_back();
    pq=clear;
    rep(i,n-1){  
        pq.push(Pll(ab[i].second, ab[i].first));
    }
    bool b = true;
    temp = 0;
    ll cnt = 0;
    while(pq.size() && temp < h && b){
        Pll t = pq.top();pq.pop();
        if(t.first < katana.first){
            b = false;
            continue;
        }
        temp += t.first;
        cnt++;
    }
    if(temp < h){
        ll r = h-temp;
        if(r < katana.second)cnt++;
        else{
            r -= katana.second;
            cnt += (r-1) / katana.first + 1;
            cnt++;
        }
    }

    cout << (ok ? min(res, cnt) : cnt) << endl;

}

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

using namespace std;

const int N = (int)2e3 + 7;

int n, x, y;
int dist[N], sum[N];

void bfs(int v) {
  queue <int> q;
  memset(dist, 0, sizeof dist);
  dist[v] = 1;
  q.push(v);
  while (!q.empty()) {
    v = q.front();
    q.pop();
    if (0 < v) {
      if (!dist[v - 1]) {
        dist[v - 1] = dist[v] + 1;
        q.push(v - 1);
      }
    }
    if (v + 1 < n) {
      if (!dist[v + 1]) {
        dist[v + 1] = dist[v] + 1;
        q.push(v + 1);
      }
    }
    if (v == x) {
      if (!dist[y]) {
        dist[y] = dist[v] + 1;
        q.push(y);
      }
    }
    if (v == y) {
      if (!dist[x]) {
        dist[x] = dist[v] + 1;
        q.push(x);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    sum[dist[i] - 1]++;
  }
}

main() {
  scanf("%d %d %d", &n, &x, &y);
  x--; y--;
  for (int i = 0; i < n; i++) {
    bfs(i);
  }
  for (int i = 1; i < n; i++) {
    printf("%d\n", sum[i] / 2);
  }
}


Measured memory_bytes: 256
import { readFileSync } from 'fs'

function main(input: string) {
  const [A, B] = input.split(' ').map(Number)

  const cost = (() => {
    if (A <= 5) return 0
    if (A < 13) return B / 2
    return B
  })()

  console.log(cost)
}

main(readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 7500
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string.h>

using namespace std;

int main() {
    int n, a[200];
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int tot = 1000000000;
    for(int x = -100; x <= 100; x ++) {
        int cur = 0;
        for(int i = 1; i <= n; i++) {
            cur += (x - a[i]) * (x - a[i]);
        }
        if(cur < tot) {
            tot = cur;
        }
    }
    cout << tot;
    return 0;
}


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

#define pb push_back

using ll = long long;
using pii = pair<int, int>;

int main() {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int n; cin >> n;
    for (int x = 1; x <= n; ++x) {
    	if (int(x * 1.08) == n) {
    		cout << x << "\n";
    		return 0;
    	}
    }
    cout << ":(\n";
}

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

int H, W;
int A[80][80], B[80][80];

bitset<30000> dp[80][80];

int main() {
    cin >> H >> W;
    rep(i, H) rep(j, W) cin >> A[i][j];
    rep(i, H) rep(j, W) cin >> B[i][j];

    int offset = 15000;
    dp[0][0][offset + abs(A[0][0] - B[0][0])] = 1;
    rep(i, H) rep(j, W) {
        if (i+1 < H) {
            int d = abs(A[i+1][j] - B[i+1][j]);
            dp[i+1][j] |= (dp[i][j] << d);
            dp[i+1][j] |= (dp[i][j] >> d);
        }
        if (j+1 < W) {
            int d = abs(A[i][j+1] - B[i][j+1]);
            dp[i][j+1] |= (dp[i][j] << d);
            dp[i][j+1] |= (dp[i][j] >> d);
        }
    }

    int ans = 1e8;
    rep(k, 30000) {
        if (dp[H-1][W-1][k]) ans = min(ans, abs(k - offset));
    }
    cout << ans << endl;
}


Measured memory_bytes: 23808
#include <iostream>

using namespace std;

int main()
{
    int c=0, boxa[3000],boxb[3000],x,y;
    while(1){
        cin >> x >> y;
        if(x==0 && y==0){
            break;
        }
        boxa[c]=x;
        boxb[c]=y;
        c++;
    }
    for(int i =0;i<c;i++){
        if(boxa[i]<boxb[i]){
            cout << boxa[i] << " " << boxb[i] << endl;
        }
        else {
            cout << boxb[i] << " " << boxa[i] << endl;
        }
    }
}



Measured memory_bytes: 3016
#define _USE_MATH_DEFINES // for C++  
#include <cmath> 
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <array>
#include <iterator>
#include <utility>
#include <set>
#include <random>
#include <map>
#include <stack>
#include <queue>
#include <list>
#include <functional>
#include <bitset>
#define LL long long

using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> v(m);
    for (size_t i = 0; i < m; i++)
    {
        cin >> v[i];
    }
    cout << n - 1 - m << endl;

}

Measured memory_bytes: 3076
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int n;
vector<int> S;

int partition(int p, int r)
{
    int x=S[r];
    int i=p-1;
    for(int j=p; j<r; j++){
        if(S[j]<=x){
            i++;
            swap(S[i], S[j]);
        }
    }
    swap(S[i+1], S[r]);
    return i+1;
}

int main()
{
    int n;
    scanf("%d", &n);
    S=vector<int>(n);
    for(auto &it : S){
        scanf("%d", &it);
    }
    int q=partition(0, n-1);
    int i=0;
    for(; i<q; i++){
        if(i!=0){
            printf(" ");
        }
        printf("%d", S[i]);
    }
    printf(" [%d]", S[i]);
    i++;
    for(; i<n; i++){
        printf(" %d", S[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 2720
N=int(input())
S=input()
kouho=[]
for n in range(1000):
    st=str(n)
    if len(st)<=2:
        st='0'*(3-len(st))+st
    kouho.append(st)
ans=0
for k in kouho:
    number=0
    for s in S:
        if k[number]==s:
            number+=1
        if number==3:
            break
    if number == 3:
        ans += 1
print(ans)


Measured memory_bytes: 73444
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<vector>
#include<set>

using namespace std;
int main(){
  int a,b,k;
  cin >>a>>b>>k;
  vector<int> v(110,0);
  for(int i=1;i<=100;i++){
    if(a%i==0 && b%i==0)v[i]=i;
  }
  sort(v.begin(),v.end(),greater<int>());
  
  cout<<v[k-1]<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define all(vec) vec.begin(), vec.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl
#define isEven(t) t % 2 == 0

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

//Ｏ(√n)
//素因数分解
map<int, int> prime_factor_ver2(int n, map<int, int> res)
{
	for (int i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			while (n % i == 0)
			{
				res[i]++;
				n /= i;
			}
		}
	}
	if (n != 1)
		res[n]++;
	return res;
}

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

	int N;
	int ans=1;
	map<int, int> mp;

	cin >> N;
	for (int i = 2; i <= N; i++) {
		mp = prime_factor_ver2(i, mp);
	}

	for (auto it = mp.begin();it!=mp.end();it++){
		//cout << it->first << " " << it->second << endl;
		if(it->second!=0){
			ans *= (it->second+1);
			ans %= MOD;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>

int f(int n){
    assert(1 <= n);
    assert(n <= 100000000);
    int x = n;
    int sum = 0;
    while(x > 0){
        sum += x % 10;
        x = x / 10;
    }
    return sum;
}

int main(int argc, char **argv)
{
    int N;
    std::cin >> N;
    
    assert(1 <= N);
    assert(N <= 100000000);
    
    if(N % f(N) == 0){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int main(){
  int A, B;
  cin >> A >> B;
  int num = A;
  int ans = 1;
  while(num < B){
    ans++;
    num += (A - 1);
  }
  if(B == 1){
    cout << 0 << endl;
  }
  else{
    cout << ans << endl;
  }
}




Measured memory_bytes: 256
/**
>>> In The Name Of GOD
**/
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

#define pb push_back
#define pp pop_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define bs binary_search
#define smin(x,y) (x) = min((x) ,(y))
#define smax(x,y) (x) = max((x) ,(y))
#define sz(x) (int)(x).size()
#define ssz(x) (int)(x).length()
#define all(x) (x).begin(),(x).end()

//freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

///ifstream fin("input.txt");
///ofstream fout("output.txt");


bool cmp_pair_F_2(pair <int,int> x, pair <int,int> y)
{
    return x.F>y.F;
}
bool cmp_pair_S_2(pair <int,int> x, pair <int,int> y)
{
    return x.S>y.S;
}
bool cmp_pair_S_1(pair <int,int> x, pair <int,int> y)
{
    return x.S<y.S;
}

bool cmp(int x, int y)
{
	return x>y;
}



int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //int i,j;
	int a,p;
	cin >> a >> p;
	p+=a*3;
	cout << int(p/2);
    return 0;
}


Measured memory_bytes: 256
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <queue>
# include <stack>
# include <map>
# include <math.h>
# include <algorithm>
using namespace std;
# define MAXN 55
# define MAXM 100005
# define INF 1000000000
# define MIN(a,b) (a)>(b)?(b):(a)
# define MAX(a,b) (a)<(b)?(b):(a)
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
typedef long long LL;
int _MAX(int a, int b){return a>b?a:b;}
int _MIN(int a, int b){return a>b?b:a;}

int a, b, f[10], l[10];
char s[10][10];

int main()
{
    scanf("%d%d",&a,&b);
    FO(i,0,a) scanf("%s",s[i]);
    mem(f,-1); mem(l,-1);
    if (s[0][0]!='#'||s[a-1][b-1]!='#') {puts("Impossible"); return 0;}
    FO(i,0,a) {
        f[i]=0;
        int flag=0;
        FO(j,0,b) {
            if (flag&&s[i][j]=='#'&&s[i][j-1]!='#') {puts("Impossible"); return 0;}
            if (s[i][j]=='#'&&flag==0) l[i]=j;
            if (s[i][j]=='#') f[i]=j, flag=1;
        }
    }
    FO(i,1,a) {
        if (l[i]<f[i-1]||l[i]==-1||f[i]==-1) {puts("Impossible"); return 0;}
    }
    puts("Possible");
}


Measured memory_bytes: 128
#Union Find
import sys
input = sys.stdin.readline
 
n,m = map(int,input().split())

#根なら-size,子なら親の頂点
par = [-1]*n

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x != y:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

def size(x):
    return -par[find(x)]


edge = [tuple(map(int,input().split())) for i in range(m)]
edge = edge[::-1]
for i in range(m):
    edge[i] = (edge[i][0]-1,edge[i][1]-1)

res = []
for i in range(m):
    fi = find(edge[i][0])
    se = find(edge[i][1])
    if fi == se:
        res.append(0)
    else:
        res.append(size(fi)*size(se))
        unite(fi,se)
ass = 0
for i in range(m):
    ass += res[m-1-i]
    print(ass)

Measured memory_bytes: 93916
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;
using pll=pair<ll,ll>;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	string a,b;
	cin >> a >> b;
	a += b;
	int c = stoi(a);
	rep(i, 1000) {
		if(i*i == c) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;


  return 0;
}


Measured memory_bytes: 256
from heapq import nlargest
x,y,z,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ab=nlargest(k,(x+y for x in a for y in b))
abc=nlargest(k,(x+y for x in ab for y in c))
for i in abc:
  print(i)

Measured memory_bytes: 4084
/* Coached by Dukkha */
#include <stdio.h>

int main() {
	static char s[5];
	int a, b, c, d;

	scanf("%s", s);
	a = s[0] - '0';
	b = s[1] - '0';
	c = s[2] - '0';
	d = s[3] - '0';
	if (a + b + c + d == 7)
		printf("%d+%d+%d+%d=7\n", a, b, c, d);
	else if (a + b + c - d == 7)
		printf("%d+%d+%d-%d=7\n", a, b, c, d);
	else if (a + b - c + d == 7)
		printf("%d+%d-%d+%d=7\n", a, b, c, d);
	else if (a + b - c - d == 7)
		printf("%d+%d-%d-%d=7\n", a, b, c, d);
	else if (a - b + c + d == 7)
		printf("%d-%d+%d+%d=7\n", a, b, c, d);
	else if (a - b + c - d == 7)
		printf("%d-%d+%d-%d=7\n", a, b, c, d);
	else if (a - b - c + d == 7)
		printf("%d-%d-%d+%d=7\n", a, b, c, d);
	else if (a - b - c - d == 7)
		printf("%d-%d-%d-%d=7\n", a, b, c, d);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>

u_int getDigit(u_int n){
	u_int digit = 1;
	
	while(n / 10 != 0){
		n /= 10;
		++digit;
	}
	
	return digit;
}
  
int main(){
    u_int a, b;
    
    while(std::cin >> a >> b){
        std::cout << getDigit(a + b) << std::endl;
    }
	
    return 0;
}

Measured memory_bytes: 3032
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<cstring>
#include<algorithm>
using namespace std;
long long n,k,x,y;
int main()
{
	cin>>n>>k>>x>>y;
	if(n<k) cout<<n*x; else cout<<k*x+(n-k)*y;
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int n,m;
	cin >> n;
	int a[100001];
	a[0] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> m;
		a[m] = i;
	}
	for (int i = 1; i <= n; i++) {
		cout << a[i] << " ";
	}

	return 0;
}

Measured memory_bytes: 1280
import math
import fractions
import copy
#以下てんぷら
def j(q):
    if q==1: print("YES")
    elif q == 0:print("NO")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
n,m= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
a =[]
for i in range(m):
    adder = [int(i)-1 for i in input().split()]
    adder.pop(0)
    a.append(adder)
sw =  [int(i) for i in input().split()]
ctsw = [0 for i in range(n)]
ctsw[0] = -1
suc = 0
while sum(ctsw)<n:
    p = 0
    ctsw[0]+=1
    if ctsw[p]==2:
        while ctsw[p] == 2:
            ctsw[p] = 0
            p+=1
            ctsw[p]+=1
    for i in range(m):
        use = a[i]
        total = 0
        for k in range(len(use)):
            d = use[k]
            total+=ctsw[d]
        if total%2 != sw[i]: break
        if total%2 == sw[i] and i == m-1:suc+=1
print(suc)

Measured memory_bytes: 5780
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main(){
    ll A,B,X;cin >> A >> B >> X;
    ll ans= 1e9;
    for(int i = 0;i <= 10000;i++){
        for(int j = 0;j <= 10000;j++){
            if(i * 1000 + j * 500>= X){
                //if(ans > 1LL * A * i + B * j)cout<<i<<" "<<j<<endl;
                ans = min(ans, 1LL * A * i + B * j);
                break;
            }
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;

int main(){
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];

    ll ans = 0;
    ll current_max = 0;
    rep(i,N){
        if (A[i] >= current_max){
            current_max = A[i];
        }
        else{
            ans += current_max - A[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4788
#include <stdio.h>

int main(int argc, char const *argv[])
{
    int d, t, s;
    scanf("%d %d %d", &d, &t, &s);

    int travelled_distance = s * t;
    if (travelled_distance >= d) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    
    return 0;
}


Measured memory_bytes: 1644
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int b, r, g, c, s, t;
    while(1){
        cin >> b >> r >> g >> c >> s >> t;
        if(!b && !r && !g && !c && !s && !t) break;
        
        int ans;
        ans = 100 + b*15 + r*15 + g*7 + c*2 + b*5*15 + r*3*15 - (t-5*b-3*r-s)*3 - (5*b+3*r)*2;
        cout << ans << endl;
    }
    
}



Measured memory_bytes: 3008
#include<iostream>
#include<cstring>
using namespace std;
char a[105],b[105],c[105];
int lena,lenb,lenc;
int check(char tmp){
	if(lena==0 && tmp=='a'){
		cout<<"A";
		return 0;
	}
	else if(lenb==0 && tmp=='b'){
		cout<<"B";
		return 0;
	}
	else if(lenc==0 && tmp=='c'){
		cout<<"C";
		return 0;
	}
	return -1;
}
int main(){
	cin>>a>>b>>c;
	lena=strlen(a);
	lenb=strlen(b);
	lenc=strlen(c);
	int a_i=0,b_i=0,c_i=0;
	char tmp='a';
	while(true){
		if(check(tmp)!=-1) break;
		if(tmp=='a'){
			tmp=a[a_i++];
			--lena;
			if(check(tmp)!=-1)	break;
		}
		if(tmp=='b'){
			tmp=b[b_i++];
			--lenb;
			if(check(tmp)!=-1)	break;
		}
		if(tmp=='c'){
			tmp=c[c_i++];
			--lenc;
			if(check(tmp)!=-1)	break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);	
  
  	map<string, int>day;
  	day.insert(make_pair("SUN",7));
  	day.insert(make_pair("MON",6));
  	day.insert(make_pair("TUE",5));
  	day.insert(make_pair("WED",4));
  	day.insert(make_pair("THU",3));
  	day.insert(make_pair("FRI",2));
  	day.insert(make_pair("SAT",1));
  	string s;
  	cin >> s;
  	cout << day[s] << endl;
  	return 0;
  	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

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

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 100005;

int a[MAXN], mx, g, n, m;

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read(), m = Read();
	for (int i = 1; i <= n; i ++)
		a[i] = Read(), g = __gcd(g, a[i]), mx = max(mx, a[i]);
	puts(m % g == 0 && mx >= m ? "POSSIBLE" : "IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>
#include <utility>
#include <map> 
#include <queue>
#include <stack>
#include <iomanip>
#include <sstream>
#define MP make_pair
#define PB push_back
#define S size()
#define B begin()
#define E end()
#define ll long long
#define REP(i,a,n) for(ll i=a; i<n; ++i)
#define RED(i,n,a) for(ll i=n; i>=a; --i)
#define m9 1000000007
#define endl "\n"
#define F first
#define SE second
#define ld long double



using namespace std;

ll gcd(ll a, ll b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b, a%b);
    }
}
ld area(ld x1, ld y1, ld x2, ld y2, ld x3, ld y3){
    return abs(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))/2;
}

vector <ll> v;

void generate(string s){
    stringstream obj(s);
    ll x=0;
    obj>>x;
    if(x<=1e6){
        v.PB(x);
        generate(s+"1"), generate(s+"0");
    }
}

int main(){
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    string s,t;
    cin>>s>>t;
    ll n= (ll)s.S+1, m=t.S+1;
    ll dp[n][m];
    REP(i,0,n){
        REP(j,0,m){
            dp[i][j]=0;
        }
    }
    REP(i,1,n){
        REP(j,1,m){
            
            if(s[i-1]==t[j-1]){
               
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else{
                dp[i][j]=max(dp[i][j], max(dp[i-1][j],dp[i][j-1]));
            }
           
                
           
        }
    }
    ll i=n-1, j=m-1;
    string ans="";
    while(i>0 && j>0){
        if(dp[i][j]>dp[i-1][j-1]){
            if(dp[i][j]>dp[i-1][j] && dp[i][j]>dp[i][j-1]){
                ans+=(char)s[i-1];
                i--, j--;
            }
            else if(dp[i][j-1]==dp[i][j]){
                j--;
            }
            else{
                i--;
            }
        }
        else{
            j--;
        }
    }
    reverse(ans.B , ans.E);
    cout<<ans;
}


Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
const ll mod=1000000007; // 998244353 = (119<<23)+1
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
// head

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x;
	cin>>x;
	for(int i=-205;i<=205;i++) {
		for(int j=-205;j<=205;j++) {
			if(pow(i,5)-pow(j,5)==x) {cout<<i<<' '<<j;return 0;}
		}
	}
	return 0;
}

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

int main(void) {
  int N;
  cin >> N;
  vector<long long> A(N);
  vector<long long> ans(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    ans[0] += A[i];
  }

  for (int i = 1; i < N; i += 2) {
    ans[0] -= 2 * A[i];
  }
  for (int i = 1; i < N; i++) {
    ans[i] = 2 * A[i - 1] - ans[i - 1];
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i] << " \n"[i == N - 1 ? 1 : 0];
  }

  return 0;
}

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

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

    ll n;
    cin >> n;

    vector<ll> a(n+1);
    ll sm = 0;
    rep(i, n+1){
        cin >> a[i];
        sm += a[i];
    }

    if(n==0){
        if(a[0]==1) cout << 1 << endl;
        else cout << -1 << endl;
        return 0;
    }

    ll res = 0;
    ll curr = 1;
    rep(i, n){
        if(curr <= a[i]) {
            cout << -1 << endl;
            return 0;
        }
        res += curr;
        sm -= a[i];
        ll nxt = min(sm, (curr - a[i]) * 2);
        // cout << i << " " << curr << " " << nxt << " " << sm << endl;
        curr = nxt;
        
    }
    if(curr != sm){
        cout << -1 << endl;
        return 0;
    }
    res += curr;

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3976
def dfs(v,visited):
  if all(visited):
    return 1
  res=0
  for nv in G[v]:
    if visited[nv]:
      continue
    visited[nv]=1
    res+=dfs(nv,visited)
    visited[nv]=0
  return res
 
n,m=map(int, input().split())
G=[[] for _ in range(n)]
visited=[0]*n
res=0
 
for i in range(m):
  a,b=map(int, input().split())
  G[a-1].append(b-1)
  G[b-1].append(a-1)

visited[0]=1
print(dfs(0,visited))

Measured memory_bytes: 9088
using System;

namespace ITP1_6_B
{
    class Program
    {
        static void Main()
        {
            int x = int.Parse(Console.ReadLine());
            bool [,] y = new bool[4,13];
            
            string[] s = {"S", "H", "C", "D"};
            
            for (int i = 0; i < x; i++)
            {
                string[] S = Console.ReadLine().Split(' ');
                for (int j = 0; j < 4; j++)
                {
                    if (S[0] == s[j])
                    {
                        //読み込んだ数字の取得
                        int k = int.Parse(S[1]) - 1;
                        y[j ,k] = true;
                        break;
                    }
                }
            }
            
            for (int l = 0; l < 4; l ++)
            {
                for (int m = 0; m < 13; m ++)
                {
                    if (y[l, m] == false)
                    {
                        Console.WriteLine(s[l] + " " + (m + 1));
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 15876
I = lambda: map(int, input().split())
n, m = I()
A = [list(I()) for _ in range(m)][1:]
B = [-1]*(n+1)
c = n*(n-1)//2
C = [c]
f = lambda x: x if B[x] < 0 else f(B[x])
for a, b in A[::-1]:
    a, b = sorted([f(a), f(b)])
    if a != b:
        c -= B[a]*B[b]
        B[a] += B[b]
        B[b] = a
    C += c,
print(*C[::-1])

Measured memory_bytes: 36840
c=[]
for i in range(3):
    c.append(list(map(int,input().split())))
for i in range(2):
    if c[i+1][0]-c[i][0]==c[i+1][1]-c[i][1] and c[i+1][1]-c[i][1]==c[i+1][2]-c[i][2] and c[0][i+1]-c[0][i]==c[1][i+1]-c[1][i] and c[1][i+1]-c[1][i]==c[2][i+1]-c[2][i]:
        flg=0
    else:
        flg=1
if flg==0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    int d, t, s; cin >> d >> t >> s;
    print(d <= s * t ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    int q;
    cin>>q;
    int g=0;
    deque<char> Q;
    for(char it:s)Q.push_back(it);
    for(int i=0;i<q;i++){
        int t;
        cin>>t;
        if(t==1){
            g^=1;
        }else{
            int f;char c;
            cin>>f>>c;
            if(f==1){
                if(g) Q.push_back(c);
                else Q.push_front(c);
            }else{
                if(g)Q.push_front(c);
                else Q.push_back(c);
            }
        }
    }
    string res="";
    if(g){
        while(!Q.empty()){
            char x=Q.back();
            res+=x;
            Q.pop_back();
        }
    }else{
        while(!Q.empty()){
            char x=Q.front();
            res+=x;
            Q.pop_front();
        }
    }
    cout<<res<<endl;
}

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

using namespace std;

string input;
typedef string::iterator State;

int m;

bool cons( State &s, char ch ) {
  if(*s == ch) {
    s ++;
    return true;
  }
  return false;
}

int formula( State &s ) {
  
  if(cons(s, 'T')) return true;
  if(cons(s, 'F')) return false;
  if(isalpha(*s)) { return (m>>(*(s++)-'a')) & 1; }
  
  if(cons(s, '-')) return !formula(s);
  
  int ret;
  if(cons(s, '(')) {
    ret = formula(s);
    
    if(cons(s, '*')) {
      ret &= formula(s);
    }
    if(cons(s, '+')) {
      ret |= formula(s);
    }
    if(cons(s, '-')) {
      cons(s, '>');
      ret = ret<=formula(s);
    }

    cons(s, ')');
  }
  
  return ret;
}

int main() {
  
  while( getline(cin, input) ) {
    if(input == "#") break;
    bool l, r;
    bool ok = 1;
    for(m=0; m<(1<<11); m++) {
      State s = input.begin();
      l = formula(s);
      cons(s, '=');
      r = formula(s);
        if(l != r) ok = 0;
    }
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1220