akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int ans(vector<int> a[],int x,int dp[],int a1[]){
    if(dp[x]!=-1)return dp[x];
    if(a1[x]==0){
        dp[x] = 0;
        return 0;
    }
    int m=0;
    for(auto i = a[x].begin();i!=a[x].end();i++){
        int t = 1+ans(a,(*i),dp,a1);
        m=m>t?m:t;
    }
    dp[x] = m;
    return m;
}
int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    vector<int> a[n];
    int a1[n];
    int dp[n];
    for(int i=0;i<n;i++){
        a1[i]=0;
        dp[i]=-1;
    }
    for(int i=0;i<m;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        a1[x-1]++;
        a[x-1].push_back(y-1);
    }
    int m1=0;
    for(int i=0;i<n;i++){
        if(dp[i]==-1){
            int t=ans(a,i,dp,a1);;
            m1 = m1>t?m1:t;
        }
    }
    cout<<m1<<endl;;
    
    return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int n,m,p,a,b;
    cin >> n >> m >> p >> a >> b;
    if(n==0) return 0;
    a--,b--;
    vector<double> t(n);
    for(int i=0;i<n;i++) cin >> t[i];
    vector<list<pair<int,double>>> e(m);
    int x,y,d;
    for(int i=0;i<p;i++){
      cin >> x >> y >> d;
      e[x-1].push_back({y-1,d});
      e[y-1].push_back({x-1,d});
    }
    vector<vector<double>> dist(m,vector<double>(1<<n,INF));
    priority_queue<pair<double,pair<int,int>>> dijk;
    dijk.push({0,{a,0}});
    pair<double,pair<int,int>> now;
    double di;
    int fl,nf;
    while(!dijk.empty()){
      now=dijk.top();
      dijk.pop();
      di=-now.first;
      x=now.second.first;
      fl=now.second.second;
      if(dist[x][fl]==INF){
        dist[x][fl]=di;
        for(int j=0;j<n;j++){
          if(!(fl&(1<<j))){
            nf=fl+(1<<j);
            for(auto pp:e[x]){
              if(dist[pp.first][nf]==INF){
                dijk.push({-di-pp.second/t[j],{pp.first,nf}});
              }
            }
          }
        }
      }
    }
    // for(int i=0;i<m;i++){
    //   for(int j=0;j<(1<<n);j++){
    //     cout << dist[i][j] << " ";
    //   }
    //   cout << endl;
    // }
    double mi=INF;
    for(int i=0;i<(1<<n);i++){
      mi=min(mi,dist[b][i]);
    }
    if(mi==INF) cout << "Impossible" << endl;
    else cout << fixed << setprecision(5) << mi << endl;
  }
  return 0;
}



Measured memory_bytes: 15752
#include <iostream>
#include <vector>


using namespace std;

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

	if (n % 2 == 0){
		cout << n/2-1 << endl;
	}
	else if (n % 2 == 1){
		cout << n/2 << endl;
	}

	return 0;
}

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

int main(){
   int N;
   cin >> N;
   vector<int> A(N);
   vector<int> B(N);
   vector<int> C(N-1);
   for (int i=0; i<N; i++)
      cin >> A.at(i);

   for (int i=0; i<N; i++)
      cin >> B.at(i);

   for (int i=0; i<N-1; i++)
      cin >> C.at(i);

   int sum = 0;
   for (int x : A)
      sum = sum + B.at(x-1);

   int sumc = 0;
   for (int i=0; i<N-1; i++)
      if (A.at(i+1) == A.at(i)+1)
         sumc = sumc + C.at(A.at(i)-1);

   cout << sum + sumc << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const string D_blue    = "\x1b[36m";
const string D_green   = "\x1b[32m";
const string D_red     = "\x1b[31m";
const string D_yellow  = "\x1b[33m";
const string Db_red    = "\x1b[41m";
const string Db_yellow = "\x1b[43m";
const string D_end     = "\x1b[39m";
const string Db_end    = "\x1b[49m";

int main (){
  int N,M;
  while (cin >> N){
    int ans = 0;
    map<string,int> mp;
    REP(i,N){
      string s;
      cin >> s;
      mp[s] += 1;
    }
    cin >> M;
    REP(i,M){
      string s;
      cin >> s;
      mp[s] -= 1;
    }
    map<string,int>::iterator itr = mp.begin();
    while(itr != mp.end()){
      ans = max(itr->second,ans);
      itr++;
    }
    cout << ans << endl;
    mp.clear();
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int H, W;
bool C[100][100];
int main() {
  cin >> H >> W;
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      char c;
      cin >> c;
      C[i][j] = c == 'c';
    }
  }
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      int a = C[i][j] ? 0 : -1;
      if (a == -1) {
        for (int k=j-1; k>=0; k--) {
          if (C[i][k]) {
            a = j - k;
            break;
          }
        }
      }
      cout << a;
      if (j != W-1) cout << " ";
    }
    cout << "\n";
  }
  return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include<string>
using namespace std;
int main(){
    int N;
    cin>>N;
    int count=0;
    int a[N];
    for(int i=0; i<N; i++){
        cin>>a[i];
    }
    for(int j=1; j<N-1; j++){
        if(a[j]>a[j+1]&&a[j]<a[j-1] || a[j+1]>a[j]&&a[j]>a[j-1]){
            count+=1;
            
        }
        
    }
    
    cout<<count<<endl;
    return 0;
    
}




Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    int X, Y;
    cin >> X >> Y;
    cout << X + (Y / 2) << endl;
    return 0;
}


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

using namespace std;

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

    int A, B;
    cin >> A >> B;

    int add = A + B;
    int subtract = A - B;
    int multiply = A * B;

    cout << max({add, subtract, multiply}) << endl;
}

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


int main(){
  long q,m=100010;
  cin >> q;
  vector<long> d(m,0),dd(m,0),rui(m,0);
  for(int i=2;i<m/2;i++){
    long tmp = 2;
    while(i*tmp < m){
      d[i*tmp] = 1;
      tmp++;
    }
  }
  for(int i=2;i<m;i++){
    if(i%2 == 1 && d[i] == 0 && d[(i+1)/2] == 0)dd[i] = 1;
  }
  rep(i,m-1)rui[i+1] = rui[i] + dd[i+1];
  rep(i,q){
    long l,r;
    cin >> l >> r;
    cout << rui[r]-rui[l-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 5628
#include <cstdlib>

#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
	ll a, b, x, ax, bx, ret;
	cin >> a >> b >> x;

	ret = 0;
	if (a == 0) ret++;

	ax = max((ll)0,(a-1)) / x;
	bx = b / x;
	ret = bx - ax + ret;

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = []
p = []
ans = [0]*n
for i in range(n):
    s1,p1 = [str(i) for i in input().split()]
    s.append(s1)
    p.append(p1)
    ans[i] = i + 1
for i in range(n):
    p[i] = int(p[i])
flag = 1
while flag:
    flag = 0
    for i in range(n-1,0,-1):
        if s[i] < s[i-1]:
            s[i],s[i-1] = s[i-1],s[i]
            p[i],p[i-1] = p[i-1],p[i]
            ans[i],ans[i-1] = ans[i-1],ans[i]
            flag = 1
flag = 1
while flag:
    flag = 0
    for i in range(n-1):
        if s[i] == s[i+1] and p[i] < p[i+1]:
            p[i],p[i+1] = p[i+1],p[i]
            ans[i],ans[i+1] = ans[i+1],ans[i]
            flag = 1
for i in range(n):
    print(ans[i])

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <cstdint>
using namespace std;
using vi = vector<int>;
using i64 = int64_t;

int main(void){
    int n;
    i64 k;
    cin >> n >> k;
    vi A(n+1), hist(n+1);
    for(int i=1; i<=n; i++) cin >> A[i];
    int now = 1, count = 0;
    hist[1] = 1;
    for(int i=1; i<=k; i++){
        now = A[now];
        hist[now]++;
        if(hist[now]==2) count++;
        if(hist[now]==3)  k = i+(k-i)%count;
    }
    cout << now << '\n';
    return 0;
}

Measured memory_bytes: 4824
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n;int  m; cin >> n >> m;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int su = 0;
    rep(i,n) su+=a[i];
    sort(a.begin(),a.end(),greater<int>());
    bool res = true;
    rep(i,m){
        if(4*m*a[i] < su){
            res = false;
        }
    }
    if(res) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
'''input
1 5
'''
n, p = map(int, input().strip().split())
ans = 1
i = 2
while i * i <= p:
	cnt = 0
	while p % i == 0:
		p //= i
		cnt += 1
	ans = ans * pow(i, cnt // n)
	i += 1
ans = ans * (p if n == 1 else 1)
print(ans)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;
    ll min_n = min({4 * Q, 2 * H, S});
    ll ans = 0;
    if (min_n * 2 >= D) {
        ll tmp = N / 2;
        ans = D * tmp;
        N -= tmp * 2;
    }
    ans += N * min_n;
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll D,T,S;
    cin >>D>>T>>S;
    if(D<=S*T){
        cout<<"Yes"<<endl;
    }else{
        cout << "No" << endl;
    }
    


    return 0;
    

}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 2e18;
const ll fact_table = 1200008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←

#define endl "\n"
#ifdef ENJAPMA
    #undef endl
#endif
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
// const ll mod = 998244353ll;
const ll mod = 2000000011;
  
ll mypow(ll number1,ll number2, ll mod){
    if(number2 == 0){
        return 1ll;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
void YES(bool condition){
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = mypow(fact[fact_table],mod - 2, mod);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/

bool multicase = false;

ll n,m,num,a,b,c,d,e,h,q;
ll w, k, l, r;
ll x[500005], y[500005], z[500005];
string s;

ll mygcd(ll a, ll b){
    if(a > b)swap(a, b);
    if(a == 0 || a == b){
        return b;
    }
    return mygcd(b % a, a);
}

void solve(){
    cin >> n;
    ll ans = 0;
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=n;j++){
            for(ll k=1;k<=n;k++){
                ans += mygcd(mygcd(i, j), k); 
            }
        }
    }
    p(ans);
    return;
}

int main(){
    // init();
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q, testcase = 1;

    if(multicase){
        cin >> q;
    }else{
        q = 1;
    }
    while(q--){
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
        testcase++;
    }
    
    // solve();
    return 0;

}
















Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    if (a + b < 10)
    {
        cout << a + b << endl;
    }
    else
    {
        cout << "error" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second

typedef long long int lli;
typedef pair<int,int> P;

const int INF=1<<30;
const long long int INF_=1<<60;

int main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int T;
    while(cin >> T&&T){
		int N;
		cin >> N;
		int sum=0;
		REP(i,0,N){
			int S,F;
			cin >> S >> F;
			sum+=F-S;
		}
		if(sum>=T) cout << "OK";
		else cout << T-sum;
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1196
// chahat  agarawal
// agrawal117

#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define endl '\n'
#define pb push_bck
using namespace std;
int main()
{
    ll n;
    cin>>n;
    map<ll,ll> mp;
    ll a;
    ll arr[n+2];
    for(int i=0;i<n;i++){
        cin>>a;
        arr[i]=a;
        mp[a]++;
    }
    a=arr[0];
    mp[a]--;
    ll b,c;
    for(int i=1;i<n;i++){
        b=arr[i];
        mp[b]--;
        ll val=a xor b;
        if(mp.count(val) && mp[val]>=1){
            c=val; mp[c]--; break;
        }
        mp[b]++;
    }
    for(int i=4;i<=n;i++){
        ll val= b xor c;
        if(mp.count(val) && mp[val]>=1){
             mp[val]--;
             b=c;
             c=val;
        }
        else{ cout<<"No"<<endl; return 0; }
    }
    cout<<"Yes"<<endl;
    
    
}


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

using ld = long double;

constexpr ld eps = 1e-8;


namespace geometry2d {


using point = std::complex<long double>;


bool eq(long double a, long double b) {
    return (std::abs(a-b) < eps);
}


long double dot(point a, point b) {
    return std::real(std::conj(a) * b);
}

long double cross(point a, point b) {
    return std::imag(std::conj(a) * b);
}


class line {
public:
    line()
        : a(point(0, 0)), b(point(0, 0))
    {}
    line(point a_, point b_)
        : a(a_), b(b_)
    {}

    point a, b;
};

bool isis_ll(line l, line m) {
    return !eq(cross(l.b - l.a, m.b - m.a), 0);
}

point proj(line l, point p) {
    long double t = dot(p - l.a, l.a - l.b) / std::norm(l.a - l.b);
    return l.a + t * (l.a - l.b);
}

point is_ll(line s, line t) {
    point sv = s.b - s.a, tv = t.b - t.a;
    assert(cross(sv, tv) != 0);
    return s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv);
}

point reflection(line const& l, point p) {
    auto pro = proj(l, p);
    return p + (pro - p) + (pro - p);
}


} // namespace geometry2d

using namespace geometry2d;

using result = vector<point>;

result op(result const& r1, result const& r2) {
    result res;
    if(r1.size() == 1) {
        if(r2.size() == 1) {
            res.push_back(r1[0]);
            res.push_back(r2[0]);
        } else {
            res.push_back(reflection(line(r2[0], r2[1]), r1[0]));
        }
    } else {
        if(r2.size() == 1) {
            res.push_back(reflection(line(r1[0], r1[1]), r2[0]));
        } else {
            res.push_back(is_ll(line(r1[0], r1[1]), line(r2[0], r2[1])));
        }
    }
    return res;
}

result expr(string const& s, int& p);
result factor(string const& s, int& p);

ld number(string const& s, int& p) {
    bool neg = s[p] == '-';
    p += neg;
    ld res = 0;
    while(isdigit(s[p])) {
        res *= 10;
        res += s[p++] - '0';
    }
    return (neg ? -res : res);
}

result expr(string const& s, int& p) {
    result v1 = factor(s, p);
    while(p < s.size() && s[p] == '@') {
        result v2 = factor(s, ++p);
        v1 = op(v1, v2);
    }
    return v1;
}

result factor(string const& s, int& p) {
    ++p; // (
    result res;
    if(isdigit(s[p]) || s[p] == '-') {
        ld x = number(s, p);
        ld y = number(s, ++p);
        res.push_back(point(ld(x), ld(y)));
    } else {
        res = expr(s, p);
    }
    ++p; // )
    return res;
}

int main() {
    string s;
    while(cin >> s, s != "#") {
        int p = 0;
        point res = expr(s, p)[0];
        cout << fixed << setprecision(10) << res.real() << ' ' << res.imag() << endl;
    }
}


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

int main() {
	// your code goes here
	int n,c=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		if(i&1){
			c++;
		}
	}
	double ans=(double)c/n;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3772
n, k = map(int, input().split())
h = list(map(int , input().split()))

INF = 10 ** 9
dp = [INF] * n

dp[0] = 0
for i in range(1, n):
    for j in range(1, k+1):
        if i - j >= 0:
            dpj = abs(h[i] - h[i - j]) + dp[i - j]
            dp[i] = min(dpj, dp[i])
            #print(dp[i])
    #print(dp)
#print(h)
#print(dp)
print(dp[n-1])

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N, M; cin >> N >> M;
  vector<ll> H(N); REP(i, N) cin >> H[i];
  vector<ll> A(M), B(M); REP(i, M) cin >> A[i] >> B[i];

  vector<ll> ans(N + 1);
  vector<vector<ll>> vec(N + 1);

  for(int i = 0; i < M; ++i) {
    if(!vector_finder(vec[A[i]], B[i])) {
      vec[A[i]].push_back(B[i]);
      vec[B[i]].push_back(A[i]);
    }
  }

  for(int i = 1; i <= N; ++i) {
    if(vec[i].empty()) {
      ans[i] = -1;
    } else {
      ll tmp = 0;
      for(int k = 0; k < vec[i].size(); ++k) {
        if(tmp < H[vec[i][k] - 1]) tmp = H[vec[i][k] - 1];
      }
      ans[i] = tmp;
    }
  }

  ll cnt = 0;
  for(int i = 1; i <= N; ++i) {
    if(ans[i] == -1) cnt++;
    else if(H[i - 1] > ans[i]) cnt++;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 12192
package main

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

var sc = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func getInt() (n int) {
	sc.Scan()
	n, _ = strconv.Atoi(sc.Text())
	return n
}

func main() {
	r := getInt()

	fmt.Println(r * r)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    ll N, ans;
    ans = 0;
    cin >> N;
    vector<ll> v(N);
    rep(i,N){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    v[N-1] = v[N-1]/2;
    rep(i,N){
        ans += v[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

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

func main() {
  NMVP := NextIntVec()
  N, M, V, P := NMVP[0], NMVP[1], NMVP[2], NMVP[3]
  A := NextIntVec()
  sort.Sort(sort.Reverse(sort.IntSlice(A)))
  T := A[P - 1]
  buf := 0
  cnt := P
  _V := Max(V - P, 0)
  for i, a := range A {
    if i < P { continue }
    if a + M < T { break }
    v := _V - (N - i - 1)
    if M * v <= buf + (i - P + 1) * (a + M - T) { cnt++ }
    buf += T - a
  }
  Write(cnt)
  Output()
}

Measured memory_bytes: 8232
#include<bits/stdc++.h>
    #define ll long long
    #define db double
    #define mod 1000000007
    #define pb push_back
    #define pp pair<ll,ll>
    #define rep(i,a,b) for(ll i=a;i<b;i++)
    #define repe(i,a,b) for(ll i=a;i<=b;i++)
    #define repr(i,a,b) for(ll i=b;i>=a;i--)
    #define maxn 100005
    #define ss second
    #define ff first
    #define lb lower_bound
    using namespace std;
    vector<ll> adj[maxn];
    ll arr[maxn],n,m;
    void solve()
    {
        map<ll,ll> mp,mp1;
        ll r;
        cin >> r;
        ll x=1;
        while(pow(x,5) <(ll)1e18 and pow(x,5) >= 1)
        {
            mp[pow(x,5)]=x;
            mp1[x]=pow(x,5);
            mp1[-x]=-mp1[x];
            x++;
        }
        ll start=-3981,end=3981;
        for(ll i=-3981;i<=end;i++)
        {
            if(mp.count(mp1[i]+r))
            {
                cout << mp[mp1[i]+r] <<" "<<i;
                return;
            }
        }
    }
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        ll t=1;
        //cin >> t;
        while(t--)
        solve();
        return 0;
    }

Measured memory_bytes: 7312
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll a,b,n;
	scanf("%lld %lld %lld",&a,&b,&n);
 ll x;
 if(b-1<n)
    { ll sum1=a*(b-1)/b;
	printf("%lld\n",sum1);
	}
	else{
		ll sum1=a*n/b;
		printf("%lld\n",sum1);
	}

	
}

Measured memory_bytes: 3824
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ll a,b;
    cin >> a >> b;
    a++; b++;
    ll ans = 0;
    ll now = 1;
    rep(i,50) {
        ll num = 0;
        num += b/(now*2)*now;
        num += max(0LL,b%(now*2)-now);
        if(a > 0) {
            num += (a-1)/(now*2)*now;
            num += max(0LL,(a-1)%(now*2)-now);
        }
        if(num%2 == 1) ans += now;
        now *= 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N=int(input())
A=[int(x) for x in input().split()]
Q=int(input())
somme=sum(A)

from collections import Counter
D=Counter()

for l in A:
    D[l]+=1
    
for step in range(Q):
    b,c=map(int,input().split())

    if b not in D:
        print(somme)
        continue

    somme=somme+(c-b)*D[b]

    D[c]=D[c]+D[b]
    del D[b]    
    print(somme)

Measured memory_bytes: 20896
const bool TEST=1;
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
#include<sstream>
#include<stack>
const int inf=0x7fffffff;
#define IF if(TEST)
#define FI if(!TEST)
#define gts(s) fgets((s),sizeof(s),stdin)
#define ALL(s) (s).begin(),(s).end()
#define MK(a,b) make_pair((a),(b))
typedef long long int LL;
typedef unsigned int U;
typedef unsigned long long ULL;
using namespace std;
typedef pair<int,int> Point;
template <typename T>
void pA(T *begin,int n){ for(int i=0;i<n;i++){ cout<<*(begin++); } printf("\n"); }
void sol(){
	ULL n,m;
	cin>>n>>m;
	ULL ans=0;
	ULL N;
	N=min(n,m/2);
	ans+=N;
	m-=2*N;
	ans+=m/4;
	cout<<ans<<endl;
}
int main()
{
	sol();
	return 0;
}
//C.cc
//generated automatically at Sat Feb 18 20:06:36 2017
//by xsthunder


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

int main() {
  
  int n;
  cin >> n;
  
  if ( n == 25 ){
    cout << "Christmas" << endl;
  }else if ( n == 24 ){
    cout << "Christmas Eve" << endl;
  }else if ( n == 23 ){
    cout << "Christmas Eve Eve" << endl;
  }else if ( n == 22 ){
    cout << "Christmas Eve Eve Eve" << endl;
  }
  
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  string s;
  string a;

  cin >> s;

  vector<string> sv(4);
  for(int i = 0; i < 4; i++){
    sv[i] = s[i];
  }
  sort(sv.begin(), sv.end());

  if(sv[0] == sv[1] && sv[2] == sv[3] && sv[0] != sv[2]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

int n,k,v[200005],ind,l[200005],r[200005],ans;
deque<pair<int,int> > minq;
map<pair<int,int>,bool > f;
map<vector<int>,bool> f2;
vector<int> v1,v2;

void add(int pos){
	
	while(minq.size()>0 && minq.back().first>v[pos]){
		minq.pop_back();
	}
	
	minq.push_back({v[pos],pos});
}

int query(){
	return minq.front().first;
}

void rem(int pos){
	
	while(minq.size()>0 && minq.front().second<=pos)minq.pop_front();
}

void check(int l,int r){
	
	
	//cout<<l<<"-"<<r<<endl;
	if(l>r){
		if(f[{-1,-1}]==false)ans++;
		f[{-1,-1}]=true;
	}
	else{
		if(f[{l,r}]==false)ans++;
		f[{l,r}]=true;
	}
}

int main(){

	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>n>>k;
	
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	
	//random_shuffle(v,v+n);
	
	
	
	ind=-1;
	for(int i=0;i<(k-1);i++){
		add(i);
	}
	
	for(int i=k-1;i<n;i++){
		add(i);
		
		if(ind<(i-(k-1))){
			ind=i-k;
			
			while((ind+1)<=i && v[ind+1]<=query() && (ind==(i-k) || v[ind+1]>v[ind])){
				ind++;
				rem(ind);
			}	
		}
		else{
			
			
			if(ind==i-1 && v[i]>v[ind]){
				ind++;
				rem(ind);
			}
			else
			while(ind>(i-k) && v[ind]>query()){
				ind--;
			}
		}
		
		rem(i-k);
		l[i-k+1]=ind-i+k;
	}
	
	while(minq.size()>0)minq.pop_back();
	for(int i=0;i<n;i++)v[i]*=(-1ll);
	reverse(v,v+n);
	
	ind=-1;
	for(int i=0;i<(k-1);i++){
		add(i);
	}
	
	for(int i=k-1;i<n;i++){
		add(i);
		
		if(ind<(i-(k-1))){
			ind=i-k;
			
			while((ind+1)<=i && v[ind+1]<=query() && (ind==(i-k) || v[ind+1]>v[ind])){
				ind++;
				rem(ind);
			}	
		}
		else{
			
			
			if(ind==i-1 && v[i]>v[ind]){
				ind++;
				rem(ind);
			}
			else
			while(ind>(i-k) && v[ind]>query()){
				ind--;
			}
		}
		
		rem(i-k);
		r[n-i-1]=ind-i+k;
	}
	
	for(int i=0;i<=n-k;i++){
		check(i+l[i],i+k-1-r[i]);
	}
	/*
	for(int i=0;i<n;i++)v[i]*=(-1ll);
	reverse(v,v+n);
	
	v1.clear();
	for(int i=0;i<n;i++){
		v1.push_back(v[i]);
	}
	
	int ans2=0;
	for(int i=0;i<=(n-k);i++){
		v2=v1;
		sort(v2.begin()+i,v2.begin()+(i+k));
		if(f2[v2]==false)ans2++;
		f2[v2]=true;
	}*/
	

	/*for(int i=0;i<n;i++)cout<<l[i]<<" ";
	cout<<endl;
	
	for(int i=0;i<n;i++)cout<<r[i]<<" ";
	cout<<endl;

	*/
	//cout<<ans<<" "<<ans2<<end;
	cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 15104
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
#define repD(i, m, n) for(int i = m; i >= n; i--)

int com[1500];

int to_num(string s){
	int n = s.size();
	if(n == 3){
		return (s[0] - '0') * 60 + (s[1] - '0') * 10 + s[2] - '0';
	}else{
		return (s[0] - '0') * 600 + (s[1] - '0') * 60 + (s[2] - '0') * 10 + s[3] - '0';
	}
}

int main(){
	int n, k;
	string p, q;
	string c;
	int s, t;
	while(cin >> n >> p >> q && (n || p != "0" || q != "0")){
		s = to_num(p);
		t = to_num(q);
		fill(com, com + 1500, n);
		rep(i, n){
			cin >> k;
			rep(j, k){
				cin >> p >> q;
				int a = to_num(p), b = to_num(q);
				rep2(l, a, b) com[l]--;
			}
		}
		int res = 0;
		int pos = s;
		int cnt = 0;
		while(pos < t){
			if(com[pos++]) cnt++;
			else cnt = 0;
			res = max(res, cnt);
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> dp(n + 1), sum(n + 1);
    dp[0] = 1;
    sum[0] = 1;
    for (int i = 1; i <= n; i++) {
        dp[i] += dp[i - 1];
        if (i >= 3) {
            dp[i] += sum[i - 3];
        }
        dp[i] %= MOD;
        sum[i] = sum[i - 1] + dp[i] % MOD;
        // cout << i << " " << dp[i] << endl;
    }
    ll res = dp[n - 1] * n % MOD;
    if (n >= 2) {
        res += dp[n - 2] * (n - 1LL) % MOD * n % MOD;
    }
    res %= MOD;
    for (ll i = 0; i <= n - 3; i++) {
        res += dp[i] * (i + 2LL) % MOD;
        res += dp[i] * (n - 1LL) % MOD * (n - 1LL) % MOD;
        res %= MOD;
    }
    cout << res << endl;
}

Measured memory_bytes: 15872
# include<stdio.h>
int solve(int,int);
int n,A[2000];

int main(void){
  int q,i,j,m[2000];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
  }

  for(i=0;i<q;i++){
    for(j=0;j<q;j++){
      if(solve(j,m[i])==1){
      printf("yes\n");
      break;
      }
      else{
      printf("no\n");
      break;
      }
    }
  }
  return 0;
}

int solve(int i, int m){
  int res;
 
  if(m==0){
    return 1;
  }
  if(i>=n){
    return -1;
  }
  res=solve(i+1,m);
  if(res==1){
    return res;
  }
  res=solve(i+1,m-A[i]);
  if(res==1){
    return res;
  }
}
  
    
      
  



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;

vector<P>E[100000];
ll d1[100000],d2[100000];
int u[200000],v[200000],d[200000];
ll dp1[100000],dp2[100000];

signed main(){
	int n,m,s,t;scanf("%d%d%d%d",&n,&m,&s,&t);s--;t--;
	rep(i,m){
		scanf("%d%d%d",&u[i],&v[i],&d[i]);u[i]--;v[i]--;
		E[u[i]].push_back(P(d[i],v[i]));
		E[v[i]].push_back(P(d[i],u[i]));
	}
	
	priority_queue<P,vector<P>,greater<P>>que;
	memset(d1,0x3f,sizeof(d1));
	d1[s]=0;dp1[s]=1;que.push(P(0,s));
	while(!que.empty()){
		P p=que.top();que.pop();
		if(d1[p.second]!=p.first)continue;
		for(auto u:E[p.second]){
			if(d1[u.second]>p.first+u.first){
				d1[u.second]=p.first+u.first;
				dp1[u.second]=dp1[p.second];
				que.push(P(d1[u.second],u.second));
			}
			else if(d1[u.second]==p.first+u.first){
				(dp1[u.second]+=dp1[p.second])%=MOD;
			}
		}
	}
	
	memset(d2,0x3f,sizeof(d2));
	d2[t]=0;dp2[t]=1;que.push(P(0,t));
	while(!que.empty()){
		P p=que.top();que.pop();
		if(d2[p.second]!=p.first)continue;
		for(auto u:E[p.second]){
			if(d2[u.second]>p.first+u.first){
				d2[u.second]=p.first+u.first;
				dp2[u.second]=dp2[p.second];
				que.push(P(d2[u.second],u.second));
			}
			else if(d2[u.second]==p.first+u.first){
				(dp2[u.second]+=dp2[p.second])%=MOD;
			}
		}
	}
	
	ll ans=dp1[t]*dp1[t];
	
	rep(i,n){//頂点で重なる
		if(d1[i]+d2[i]!=d1[t])continue;
		if(d1[i]==d2[i]){
			ans=(ans+MOD-(dp1[i]*dp1[i]%MOD*dp2[i]%MOD*dp2[i])%MOD)%MOD;
		}
	}
	rep(i,m){//辺(頂点を除く)で重なる
		if(d1[u[i]]>d1[v[i]])swap(u[i],v[i]);
		if(d1[u[i]]+d[i]!=d1[v[i]])continue;
		if(d1[u[i]]+d2[v[i]]+d[i]!=d1[t])continue;
		ll L1=d1[u[i]]+1,R1=d1[u[i]]+d[i]-1;
		ll L2=d2[v[i]]+1,R2=d2[v[i]]+d[i]-1;
		if(!(R2<L1||R1<L2)){
			ans=(ans+MOD-(dp1[u[i]]*dp1[u[i]]%MOD*dp2[v[i]]%MOD*dp2[v[i]])%MOD)%MOD;
		}
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 19824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (b==0) return a;
    else{
    	return gcd(b,a%b);
    }
}

int main() {
	ll A,B;
  	cin >> A >> B;
  	cout << A*B/gcd(A,B) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;

int n, a[100], ct = 0;


int main()
{
	while (1){
		cin >> n;
		if (n == 0) break;
		for (int i = 0; i < n; i++) cin >> a[i];
		for (int j = 0; j < n; j++)
			for (int i = 0; i < n - 1; i++){
				if (a[i]>a[i + 1]){
					swap(a[i], a[i + 1]);
					ct++;
				}
			}
		cout << ct << endl;
		ct = 0;
	}
	return 0;
}

Measured memory_bytes: 1160
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())

x = ii()

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
y = make_divisors(x)

m = 10000000000000

if(len(y)%2==1):
    for i in range(0,len(y),2):
        if(i==len(y)-1):
            if m > (y[i]-1)*2:
                m = (y[i]-1)*2
        else:
            if m > y[i]+y[i+1]-2:
                m = y[i]+y[i+1]-2
else:
    for i in range(0,len(y),2):
        if m > y[i]+y[i+1]-2:
                m = y[i]+y[i+1]-2

print(m)

Measured memory_bytes: 3276
import std.algorithm;
import std.bigint;
import std.bitmanip;
import std.concurrency : generator = Generator, yield;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long[] x, long[] y) {
    double psum = 0;
    foreach (i; 0 .. N)
        foreach (j; i .. N) {
            const d = ((x[i] - x[j]) ^^ 2 + (y[i] - y[j]) ^^ 2).to!double.sqrt;
            psum += d;
        }
    
    return 2.0 * psum / N;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long[] x = new long[](cast(size_t) (N));
    long[] y = new long[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        x[i] = input.front.to!long;
        input.popFront;
        y[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, x, y);
    else {
        auto ans = solve(N, x, y);

        static if (isFloatingPoint!(ReturnType!solve))
            writeln(format("%.9f", ans));
        else static if (is(ReturnType!solve == bool))
            writeln(ans ? YES : NO);
        else
            writeln(ans);
    }
}


Measured memory_bytes: 256
S=input()
Q=int(input())
mode=0
sento=''
matubi=''
for i in range(Q):
  query=list(input().split())
  if query[0]=='1':
    mode=(mode+1)%2
  if query[0]=='2':
    if query[1]=='1':
      if mode==0:
        sento=query[2]+sento
      else:
        matubi=matubi+query[2]
    else:
      if mode==0:
        matubi=matubi+query[2]
      else:
        sento=query[2]+sento
if mode==1:
  S=matubi[::-1]+S[::-1]+sento[::-1]
else:
  S=sento+S+matubi
print(S)

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;


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

    int mx = 0;
    int limit = min(n, k);
    for (int i = 0; i <= limit; i++) {
        for (int j = 0; j <= limit - i; j++) {
            int t = 0;
            vector<int> m;
            for (int l = 0; l < i; l++) {
                t += v[l];
                if (v[l] < 0) {
                    m.push_back(v[l]);
                }
            }
            for (int r = 0; r < j; r++) {
                t += v[n - 1 - r];
                if (v[n - 1 - r] < 0) {
                    m.push_back(v[n - 1 - r]);
                }
            }
            sort(ALL(m));
            for (int d = 0; d < min(k - (i + j), (int)m.size()); d++) {
                t -= m[d];
            }

            mx = max(mx, t);
        }
    }

    cout << mx << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ; 
 
const int MAXN = 1e6 + 100 ; 
#define int long long
int vis[MAXN] , bd , sz ;
vector<int> ver[MAXN] ; 
void dfs(int v , int col = 1) {
	vis[v] = col ; 
	for(auto u : ver[v]){
		if(vis[u] == col){bd = false ; continue ; }
		if(! vis[u]) dfs(u , 3 - col) ; 
	}
	sz ++ ;
}
int32_t main(){
    ios_base::sync_with_stdio(0) ; 
    cin . tie(0) , cout . tie(0) ; 
    
    int n , m ; cin >> n >> m ; 
    for(int i = 0 ; i < m ; i ++){
    	int x , y ; cin >> x >> y ; 
    	x -- , y -- ; 
    	ver[x] . push_back(y) ; 
    	ver[y] . push_back(x) ;
    }
    int a = 0 , b = 0 , c = 0 ; 
    for(int i = 0 ; i < n ; i ++){
    	if(vis[i]) continue ; 
    	sz = 0 , bd = true ; 
    	dfs(i) ; 
    	if(sz > 1 && bd)b ++ ;
    	else if(sz > 1) a ++ ; 
    	else c ++ ; 
    }
    cerr << a << ' ' << b << ' ' << c << '\n' ; 
    int ans = a * a + b * b * 2 + 2 * a * b + c * (n - c) * 2 + c * c ;
    cout << ans ; 
 
}

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



int main(){
    string S, T;
    cin >> S >> T;

    if(S == T ){
        cout << "Yes" << endl;
        return 0;
    }
    for(int i = 1; i < S.size(); i++){
        string tmp1 = S.substr(0,i);
        string tmp2 = S.substr(i, S.size() - i);
        if(tmp2 + tmp1 == T){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
class union_find:
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]

    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:return True
        
        if self.table[y] < self.table[x]:x, y = y, x

        self.table[x] += self.table[y]
        self.table[y] = x
        return False
            
    def find(self, x):
        if self.table[x] < 0:return x
        self.table[x] = self.find(self.table[x])
        return self.table[x]

import sys
f = sys.stdin

n, q = map(int, f.readline().split())
uf = union_find(n)

op = (uf.union, lambda x, y:print(1 if uf.find(x) == uf.find(y) else 0))

for com, x, y in (map(int, f.readline().split()) for _ in range(q)):
    op[com](x, y)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

// 素因数分解
map<ll, ll> prime_factorize(ll N) {
    map<ll, ll> res;
    for (ll i = 2; i * i <= N; ++i) {
        while (N % i == 0) {
            res[i]++;
            N /= i;
        }
    }
    if (N != 1) res[N] = 1;
    return res;
}

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

void Main() {
    ll N; cin >> N;
    if (N >= 3){
        vector<ll> A(N); rep(i, N){cin >> A.at(i);}
        // N^{2}を避けるため，累積最大公約数という概念を導入
        // Li: 0, 1, ..., i-1 の最大公約数
        // Ri: i, ... N - 1 の最大公約数
        vector<ll> L(N + 1), R(N + 1); L.at(0) = 0; R.at(N) = 0;
        rep(i, N){L.at(i + 1) = __gcd(L.at(i), A.at(i));}
        rrep(i, N, 1){R.at(i - 1) = __gcd(R.at(i), A.at(i - 1));}

        ll ans = 1;
        rep(i, N){
            ll tmp = __gcd(L.at(i), R.at(i + 1));
            if (ans < tmp){ans = tmp;}
        }
        cout << ans << endl;
    } else {
        vector<ll> A(N);
        rep(i, N){cin >> A.at(i);}
        cout << *max_element(A.begin(), A.end()) << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

int main(){
    LL n;
    cin >> n;
    vector<LL> a(n + 1);
    vector<LL> b(n);


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

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

    LL ans = 0,f = 0;
    LL ap = 0,bp = 0;
    bool check = true;

    while(ap <= n && bp < n){
        if(check){
            f = min(a[ap] - f, b[bp]);
            ans += f;
            ap++;
            check = !check;
        }else{
            f = min(a[ap], b[bp] - f);
            ans += f;
            bp++;
            check = !check;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 2147483647
#define MOD 1000000007
#define MAX 200005
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<ii> vii;
typedef priority_queue<int,vector<int>,greater<int> > PQ;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

vector<int> graph[MAX];
int vis[MAX];
int comp;

void dfs(int u)
{
    vis[u] = 1;
    comp++;

    for(int i = 0; i < graph[u].size(); i++) {
        int v = graph[u][i];
        if(!vis[v])
            dfs(v);
    }
}

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

    cin>>n>>m;

    for(int i = 0; i < m; i++) {
        int u, v;
        cin>>u>>v;
        graph[u].pb(v);
        graph[v].pb(u);
    }

    int maxComp = 0;
    for(int i = 1; i <= n; i++) {
        if(!vis[i]) {
            comp = 0;
            dfs(i);
            maxComp = max(maxComp, comp);
        }
    }

    cout<<maxComp<<endl;

    return 0;
}



Measured memory_bytes: 21624
#include <bits/stdc++.h> 
using namespace std;  
void constructXOR(int A[], int n) 
{ 

	int XOR = 0; 
	for (int i = 0; i < n; i++) 
		XOR ^= A[i]; 
	for (int i = 0; i < n; i++) 
		A[i] = XOR ^ A[i]; 
} 
int main() 
{ 
	int n;
  cin>>n;
  int A[n];
  for(int i=0;i<n;i++)
  cin>>A[i];
	constructXOR(A, n); 
	for (int i = 0; i < n; i++) 
		cout << A[i] << " "; 
	return 0; 
} 


Measured memory_bytes: 4308