akhauriyash/Code-Regression huggingface dataset:
import bisect
n,k,q = map(int,input().split())
a = list(map(int,input().split()))
if q == 1:
  print(0)
  exit()
ls = [-1,n]
b = sorted(((a[i],i) for i in range(n)))
ansls = [b[q-1][0]-b[0][0]]
space = [n]
qc = q
for i,x in enumerate(b):
  for j in range(i,n):
    idx = bisect.bisect_left(ls,b[j][1])
    if space[idx-1] < k:
      continue
    qc -= 1
    space[idx-1] -= 1
    if qc == 0:
      ansls.append(b[j][0]-x[0])
      break
  ins = bisect.bisect_left(ls,x[1])
  ls.insert(ins,x[1])
  space = []
  qc = q
  for j in range(1,i+3):
    space.append(ls[j]-ls[j-1]-1)
print(min(ansls))

Measured memory_bytes: 48348
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    long long a, b, c;
    cin >> a >> b >> c;

    cout << ((c > a + b) && (4 * a * b < (c - a - b) * (c - a - b)) ? "Yes" : "No") << endl; 
    
    return 0;
}

Measured memory_bytes: 256
function Main(input) {
    var N = parseInt(input[0], 10);
    var result = 0;

    for (var i = 1; i <= N; i++) {
        if (1 <= i && i <= 9 ||
            100 <= i && i <= 999 ||
            10000 <= i && i <= 99999) {
                result++;
        }
    }
    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 7372
// Example program
#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;
int main()
{
 int a;
 int b;
 int c;
 int d;
 int e;
 int f;
 int g;
 int h;
 
 cin >> a;
 cin >> b;
 cin >> c;
 cin >> d;
 cin >> e;
 cin >> f;
 cin >> g;
 cin >> h;
 
 int  s=(a+b+c+d); 
 int  t=(e+f+g+h);

 
 if(s<t){
     cout << t << endl;
 }else{
     cout << s << endl;
 }
}

Measured memory_bytes: 1160
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-9;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

string s;

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}
 
inline void Solve () {
   cin >> s;
   if ((sz (s) & 1) == (s[0] == s.back ()))
      cout << "Second";
   else
      cout << "First";
}               
 
signed main () {                                       
   #ifdef QWERTY
      freopen("input", "r", stdin);
   #endif
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}                   

Measured memory_bytes: 3784
n=int(input())
a=[int(input()) for _ in range(n)]
aa=a.copy()
aa.sort()
import bisect
a=[bisect.bisect_left(aa,x) for x in a]
ans=0
for i in range(n):
  if (i-a[i])%2==0:
    pass
  else:
    ans+=1
print(ans//2)

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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

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

  int n; cin >> n;
  vll a(1<<n);
  REP(i, 1<<n) {
    cin >> a[i];
  }

  vector<ll> ma1(1<<n), ma2(1<<n, -1);
  REP(i, 1<<n) ma1[i] = a[i];

  int dp1[1<<n][n+1], dp2[1<<n][n+1];
  REP(i, 1<<n) {
    dp1[i][0] = a[i];
    dp2[i][0] = 0;
  }
  REP(j, n) {
    REP(i, 1<<n) {
      if(i & (1<<j)) {
        vector<int> v;
        v.push_back(dp1[i&(~(1<<j))][j]);
        v.push_back(dp2[i&(~(1<<j))][j]);
        v.push_back(dp1[i][j]);
        v.push_back(dp2[i][j]);
        sort(ALL(v));
        reverse(ALL(v));
        dp1[i][j+1] = v[0];
        dp2[i][j+1] = v[1];
      } else {
        dp1[i][j+1] = dp1[i][j];
        dp2[i][j+1] = dp2[i][j];
      }
    }
  }

  int ma = 0;
  FOR(i, 1, 1<<n) {
    chmax(ma, dp1[i][n] + dp2[i][n]);
    cout << ma << endl;
  }


}
























Measured memory_bytes: 48128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,m;
    cin>>n>>m;
    vector<int> a(n);
        rep(i,n) cin>>a.at(i);
    int sum=0;
    rep(i,n) sum +=a[i];
    sort(all(a));
    reverse(all(a));
    int i=0;
    int m4=4*m;
    int lim=(sum+4*m-1)/m4;
    while(m>0){
        if(a[i]<lim){
            No;
            return 0;
        }
        m --;
        i ++;
    }
    Yes;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()){
            int n = sc.nextInt();
            int count = 0;
            if(n > 36){
                System.out.println("0");
            }else{
                for(int a = 0 ; a <= 9 ; a++){
                    for(int b = 0 ; b <= 9 ; b++){
                        for(int c = 0 ; c <= 9 ; c++){
                            for(int d = 0 ; d <= 9 ; d++){
                                if((a+b+c+d) == n){
                                	count++;
                                }
                            }
                        }
                    }
                }
                System.out.println(count);
            }
        }
    }
}

Measured memory_bytes: 26560
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> sa(3);
    sa.at(0) = abs(a - b);
    sa.at(1) = abs(b - c);
    sa.at(2) = abs(c - a);

    sort(sa.begin(), sa.end());

    cout << sa.at(0) + sa.at(1) << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
char s[125252];
int g[9][9];

int main(){
  scanf("%d",&n);
  scanf("%s",s);
  REP(i,n-1){
    int bef = s[i]-'1';
    int nxt = s[i+1]-'1';
    if(bef>nxt)swap(bef,nxt);
    g[bef][nxt]++;
  }
  vi p(9);REP(i,9)p[i]=i;
  vi best = p;
  int bestscore = 252521830;
  do{
    int tmp = 0;
    REP(to,9)REP(from,to){
      int mul = g[from][to];
      int fx = p[from]/3, fy = p[from]%3;
      int tx = p[to]/3, ty = p[to]%3;
      tmp += mul * (abs(fx-tx) + abs(fy-ty));
    }
    if(tmp < bestscore){
      bestscore = tmp;
      vi ans(9);
      REP(i,9)ans[p[i]] = i;
      best = ans;
    }else if(tmp == bestscore){
      vi ans(9);
      REP(i,9)ans[p[i]] = i;
      if(ans < best){
        best = ans;
      }
    }
  }while(next_permutation(ALL(p)));
  REP(i,3){
    REP(j,3)printf("%d",best[3*i+j]+1);puts("");
  }
  return 0;
}



Measured memory_bytes: 3368
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int main()
{
	int num[10];
	string s;
	while(cin >> s)
	{
		for(int i=0;i<10;i++)
		{
			num[i]=(s[i]-'0');
		}
		for(int i=9;i>0;i--)
		{
			for(int j=0;j<i;j++)
			{
				num[j]=(num[j]+num[j+1])%10;
			}
		}
		cout << num[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    int n;
    int A[4][13];
    char ch;
    int num;
    
    for(int i=0;i<4;i++){
        for(int j=0;j<13;j++){
            A[i][j]=0;
        }
    }
    
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%c",&ch);
        scanf("%c %d",&ch,&num);
        
        if(ch=='S'){
            A[0][num-1]=1;
        }else if(ch=='H'){
            A[1][num-1]=1;
        }else if(ch=='C'){
            A[2][num-1]=1;
        }else{
            A[3][num-1]=1;
        }
    }
    
    for(int i=0;i<4;i++){
        for(int j=0;j<13;j++){
            if(A[i][j]==0){
                if(i==0){
                    cout<<'S'<<" "<<j+1<<endl;
                }else if(i==1){
                    cout<<'H'<<" "<<j+1<<endl;
                }else if(i==2){
                    cout<<'C'<<" "<<j+1<<endl;
                }else{
                    cout<<'D'<<" "<<j+1<<endl;
                }
                
            }
        }
    }
    
    
    return 0;
}



Measured memory_bytes: 3136
from math import *

a,b,h,m = map(int,input().split())

p = h * 30 + m / 2
q = 6 * m
r = abs(p - q)
r = min(r, 360 - r)
res = a * a + b * b - 2 * a * b * cos(radians(r))
print("%.12f" % res ** 0.5)


Measured memory_bytes: 62640
n, a, b = list(map(int, input().split()))

c = 0
for s in range(1, n+1):
    sum = 0
    r = s
    for t in range(1, len(str(s))+1):
        sum += r%10
        r = r//10
    if(a <= sum <= b):
        c += s
print(c)


Measured memory_bytes: 2940
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

N=II()
AS=LI()
AS.sort(reverse=True)
# print(AS)

i, j = AS[0], AS[1]
HQ=[]
heapq.heappush(HQ, (-i, -j))
heapq.heappush(HQ, (-i, -j))
# print(HQ)
res = AS[0]
for n in range(2, len(AS)):
    k = AS[n]
    i, j = heapq.heappop(HQ)
    i *= -1
    j *= -1
    res += min(i, j)
    heapq.heappush(HQ, (-k, -i))
    heapq.heappush(HQ, (-k, -j))
    # print("i: {} j: {} k:{} res:{}".format(i,j,k,res))
    # print(HQ)

print(res)


Measured memory_bytes: 107384
#include <stdio.h>

int main(void)
{
    char a,b,c,d,e,f,g,h,i,j,k,l;
    scanf("%c%c%c%c%c%c%c%c%c%c%c%c",&a,&b,&c,&d,&e,&f,&g,&h,&i,&j,&k,&l);

    printf("%c%c%c\n",a,f,k);

    return 0;
}


Measured memory_bytes: 128
n = int(input())
c = []
s = []
f = []
for i in range(n-1):
  c_, s_ , f_ = map(int, input().split())
  c.append(c_)
  s.append(s_)
  f.append(f_)
  
for i in range(n-1):
  res = s[i] + c[i]
  for j in range(i+1, n-1):
    if res >= s[j]:
      if (res-s[j]) % f[j] == 0:
        res = res + c[j] + ((res - s[j]) % f[j])
      else:
        res = res + c[j] + f[j] - ((res-s[j])%f[j])
    else:
      res = s[j] + c[j]
  print(res)
print(0)

Measured memory_bytes: 9060
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
long long n;
string s;
char ch[27]={"abcdefghijklmnopqrstuvwxyz"};
int main(){
	scanf("%lld",&n);
	while(n!=0){
		--n;
		s.push_back(ch[n%26]);
		n/=26;
	}
	reverse(s.begin(),s.end());
	printf("%s\n",s.c_str());
	return 0;
}


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

#define lli long long int
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define INF 1000000007
#define endl "\n"

lli nn,a,tamcvp=0;
vector<lli>v;
map<lli,lli>m;

int main(){
	cin>>nn;
	lli n= nn;
	while(n--){
		cin>>a;
		v.pb(a);
		m[a]++;
	}
	for(map<lli,lli>::iterator it=m.begin(); it!=m.end(); ++it){
		tamcvp+=it->nd*(it->nd-1);
	}
	for(int i=0;i<nn;i++){
		cout<<(tamcvp+(m[v[i]]-1)*(m[v[i]]-2)-m[v[i]]*(m[v[i]]-1))/2<<endl;
	}

}

Measured memory_bytes: 11120
#include <stdio.h>

int main() {
	int n, a;
	double ans = 0.0;
	scanf("%d", &n);
	while (n--) {
		scanf("%d", &a);
		ans += (1.0 / (double) a);
	}
	printf("%.14lf\n", 1.0 / ans);
	return 0;
}

Measured memory_bytes: 128
def resolve():
    S = list(input())
    if len(S)%2 == 0:
        s1, s2 = S[:len(S)//2], S[len(S)//2:]
    else:
        s1, s2 = S[:len(S)//2], S[(len(S)//2)+1:]
    s2.reverse()
    cnt = 0
    for i in range(len(s1)):
        if s1[i] != s2[i]:
            cnt += 1
    print(cnt)


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 8992
#include<bits/stdc++.h>
using namespace std;
char a[110];
char b[1000];
int main(){
    int n;
    scanf("%d",&n);
    scanf("%s",a);
    for(int i=0;i<n;i++)
        b[i]=a[i];
    int ln=0;
    int rn=0;
    for(int i=0;i<n;i++)
    {
        if(b[i]=='(')
        {
            int j;
            for(j=i+1;j<n;j++){
                if(b[j]==')'){
                    b[j]='w';
                    break;
                }
            }
            if(j>=n)
                rn++;
        }
        if(b[i]==')')
            ln++;
    }
    memset(b,0,sizeof(b));
    int l=499;
    int r=510+n;
    for(int i=500;i<500+n;i++)
        b[i]=a[i-500];
    for(int i=0;i<n;i++){
        if(a[i]=='('&&rn>0){
           b[r]=')';
           rn--;
           r++;
        }
        if(a[i]==')'&&ln>0){
            b[l]='(';
            l--;
            ln--;
        }

    }
    for(int i=l;i<r;i++)
    {
        if(b[i]!=0)
            printf("%c",b[i]);
    }
}


Measured memory_bytes: 256
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}

#define trace(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma=strchr(names+1,',');
    cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1,args...);
}

int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int a[n+1];
    rep(i,1,n+1) cin >> a[i];
    sort(a+1,a+n+1);
    int ans=0;
    for(int i=1; i<=n; i++){
        for(int j=i+1; j<=n; j++){
            int x=lower_bound(a+1,a+n+1,a[i]+a[j])-a;
            ans+=max(x-(j+1),0ll);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {

    string s;
    cin >> s;
    int a = s[0] - '0';
    int b = s[1] - '0';
    int c = s[2] - '0';
    int d = s[3] - '0';
    int op[] = {-1, 1};
    REP(i, 2)REP(j, 2)REP(k, 2){
        if (a + op[i] * b + op[j] * c + op[k] * d == 7){
            char o = i == 0 ? '-' : '+';
            char p = j == 0 ? '-' : '+';
            char q = k == 0 ? '-' : '+';
            printf("%d%c%d%c%d%c%d=7\n", a, o, b, p, c, q, d);
            return 0;
        } 
    }
    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define nmax 1005
struct mang
{
    long long x,y,z,t;
} ;
mang f[nmax],d[nmax];
long long t[nmax];
int a[10][10];
int n,m,h=0;
long long ans=0,dx,dy,dz,da;
bool cm(mang a, mang b)
{
    return a.t>b.t;
}
int main()
{
    cin.tie(NULL);
    cin>>n>>m;
    for (int i=1;i<=n;i++)
    {
        cin>>f[i].x>>f[i].y>>f[i].z;
        f[i].t=f[i].x+f[i].y+f[i].z;
        h++;
            d[h].x=f[i].x;
            d[h].y=f[i].y;
            d[h].z=f[i].z;
            d[h].t=f[i].t;
    }
   /*for (int i=1;i<=n;i++)
    {
        bool o=true;
        for (int j=1;j<=h;j++)
        {
            if (f[i].z==d[j].z && f[i].y==d[j].y && f[i].z==d[j].z)o=false;
        }
        if (o==true)
        {
            h++;
            d[h].x=f[i].x;
            d[h].y=f[i].y;
            d[h].z=f[i].z;
            d[h].t=f[i].t;
        }
    }*/
    a[1][1]=1  ; a[1][2]=1  ; a[1][3]=1 ;
    a[2][1]=1  ; a[2][2]=1  ; a[2][3]=-1;
    a[3][1]=1  ; a[3][2]=-1 ; a[3][3]=1 ;
    a[4][1]=1  ; a[4][2]=-1 ; a[4][3]=-1;
    a[5][1]=-1 ; a[5][2]=1  ; a[5][3]=1 ;
    a[6][1]=-1 ; a[6][2]=1  ; a[6][3]=-1;
    a[7][1]=-1 ; a[7][2]=-1 ; a[7][3]=1 ;
    a[8][1]=-1 ; a[8][2]=-1 ; a[8][3]=-1 ;

    for (int k=-1;k<=1;k=k+2)
    for (int j=-1;j<=1;j=j+2)
    for (int g=-1;g<=1;g=g+2)
    {
        for (int i=1;i<=h;i++)
        {
            d[i].t=d[i].x*k+d[i].y*j+d[i].z*g;
        }
        sort(d+1,d+h+1,cm);
        dx=0;dy=0;dz=0;da=0;
        for (int i=1;i<=m;i++)
            {
              da=da+d[i].t;
            }
        ans=max(ans,da);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <cstring>
#include <sstream>
#include <stdlib.h>

using namespace std;

int main (void)
{
	string a;
	cin >> a;

	int p = 0;
	p = a.size();
	int co = 0;

	
	
	if (a.substr(0,1) != "A")
	{
		cout << "WA" << endl;
		return 0;
	}

	for (int i = 2; i < p - 1; i++)
	{
		if (a.substr(i,1) == "C")
		{
			co++;
		}
		else if ((a.substr(i,1) >= "A") && (a.substr(i,1) <= "Z"))
		{
			cout << "WA" << endl;
			return 0;
		}
	}
	if ((a.substr(1,1) >= "A") && (a.substr(1,1) <= "Z"))
	{
		cout << "WA" << endl;
		return 0;
	}
	if ((a.substr(p - 1,1) >= "A") && (a.substr(p - 1,1) <= "Z"))
		{
			cout << "WA" << endl;
			return 0;
		}
	
	
	if (co == 1)
	{
		cout << "AC" << endl;
	}
	else
	{
		cout << "WA" << endl;
	}
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int a,b,c;
  cin>>a>>b>>c;
  cout<<min(c,b)<<" "<<max(b+c-a,0)<<endl;
  return 0;
}


Measured memory_bytes: 892
from collections import deque
N, M = [int(x) for x in input().split()]
INF = 10**6
dist = [INF] * N
ans = [-1] * N
to = [set() for _ in range(N)]
for _ in range(M):
    A, B = [int(x)-1 for x in input().split()]
    to[A].add(B)
    to[B].add(A)
bfs = deque([(0, 0, -1)])
while len(bfs):
    cur, d, p = bfs.popleft()
    if d >= dist[cur]: continue
    dist[cur] = d
    ans[cur] = p
    for v in to[cur]:
        if d+1 < dist[v]:
            bfs.append((v, d+1, cur))
print('Yes')
for a in ans[1:]:
    print(a+1)


Measured memory_bytes: 137928
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 510000;
const int MOD =  998244353;

     signed main(){
     int a,b;
     cin>>a>>b;
     if(a%3&&b%3&&(a+b)%3)cout<<"Impossible"<<endl;
     else cout<<"Possible"<<endl;

     }

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    string T; cin >> T;
    int ans = 0;
    rep(i, T.size()) {
        if(T[i] == '?') T[i] = 'D';
    }
    rep(i, T.size()) {
        if(T[i] == 'D') ++ans;
        if(i != T.size() - 1) {
            if(T[i] == 'P' && T[i + 1] == 'D') ++ans;
        }
    }
    cout << T << endl;
}


Measured memory_bytes: 3600
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << endl;
using LL=long long;
using VI=vector<int>;
using VL=vector<long long>;
using VS=vector<string>;
using VVI=vector<vector<int>>;
using PII=pair<int, int>;
const int inf = (int)1e9;
const LL mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

template <class T>void Sort(T & a) { sort(a.begin(), a.end()); }
template <class T>void ReSort(T& a) { sort(a.rbegin(), a.rend()); }
template <class T>void Reverse(T& a) { reverse(a.begin(), a.end()); }
template <class T>void Unique(T& a) { a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T>auto Max(T a) { return *max_element(a.begin(), a.end()); }
template <class T>auto Min(T a) { return *min_element(a.begin(), a.end()); }
template <class T, class U>int Count(T a, U c) { return count(a.begin(), a.end(), c); }
template <class T, class U>U Sum(T a, U init = 0) { return accumulate(a.begin(), a.end(), init); }

//INPUT//
void CINPUT() {}
template <class H, class ...T> void CINPUT(H&& h, T&& ...t) { cin >> h; CINPUT(forward<T>(t)...); }
#define Cin(T,...) T __VA_ARGS__; CINPUT(__VA_ARGS__);
#define VecIn(T,name,n) vector<T> name(n); for(auto &i:name)cin>>name[i];

//OUTPUT//
void print() { cout << endl; }
template <class H> void print(H&& h) { cout << h << endl; }
template <class H, class... T> void print(H&& h, T&& ... t) { cout << h << " "; print(forward<T>(t)...); }
template <class T>void out(T n) { cout << n << endl; }
template <class T>void out(vector<T> a, string sep = " ", string end = "\n") { for (int i = 0; i < (int)a.size(); ++i)cout << a[i] << (i == (int)a.size() - 1 ? end : sep); }
template <> void out(double a) { printf("%.20f\n", a); }
void yes(bool f) { puts(f ? "yes" : "no"); }
void Yes(bool f) { puts(f ? "Yes" : "No"); }
void YES(bool f) { puts(f ? "YES" : "NO"); }
void Yay(bool f) { puts(f ? "Yay!" : ":("); }
void poss(bool f) { puts(f ? "possible" : "impossible"); }
void Poss(bool f) { puts(f ? "Possible" : "Impossible"); }
void POSS(bool f) { puts(f ? "POSSIBLE" : "IMPOSSIBLE"); }

int main() {
	Cin(int,a, b);
	out(max({ a + b,a - b,a * b }));
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
n = sum([1 for i in range(N) if A[i] < 0])
abs_A = [abs(a) for a in A]
ans = sum(abs_A)
if n % 2 == 0:
  print(ans)
else:
  print(ans-2*min(abs_A))

Measured memory_bytes: 14332
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def solve():
    A, B, C = Scanner.map_int()
    K = Scanner.int()
    for i in range(K):
        if A >= B:
            B *= 2
        else:
            C *= 2
    return A < B < C


def main():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    print('YNeos'[not solve()::2])


if __name__ == "__main__":
    main()


Measured memory_bytes: 10692
def main():
    N, T = map(int, input().split())
    *t, = map(int, input().split())
    t += [1 << 31]

    u = iter(t)
    next(u)

    ans = sum(min(T, u_ - t_) for t_, u_ in zip(t, u))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 26708
n=int(input())
a=sorted(list(map(int, input().split(" "))))
if sum(a) == 0:
  print("Yes")
elif n % 3 != 0:
  print("No")
else:
  ass = [a[0], a[n // 3], a[n // 3 * 2]]
  #print(a.count(ass[0]), (n // 3))
  if a.count(ass[0]) % (n // 3) != 0 or a.count(ass[1]) % (n // 3) != 0 or a.count(ass[2]) % (n // 3) != 0:
    print("No")
  else:
    if ass[0] ^ ass[1] != ass[2]:
      print("No")
    else:
      print("Yes")

Measured memory_bytes: 20576
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main(){

  string a, b;
  cin >> a >> b;
  int s;
  s = atoi((a + b).c_str());

  int sq;
  sq = sqrt(s);
  if ((sq * sq) == s){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: C: こだわり者いろはちゃん / Iroha's Obsession
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

bool dls[10];

/* subroutines */

/* main */

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

  for (;;) {
    int m = n;
    bool ok = true;
    while (m > 0) {
      if (dls[m % 10]) {
	ok = false;
	break;
      }
      m /= 10;
    }
    if (ok) break;
    n++;
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int col[200005],ans[200005],cnt[2];
vector<int> v[200005],pos[3];
void dfs(int node,int p)
{
	col[node]=(col[p]^1);
	cnt[col[node]]++;
	for (int u:v[node])
	{
		if (u!=p)
		dfs(u,node);
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for (int i=1;i<=n;i++)
	pos[i%3].push_back(i);
	dfs(1,0);
	int s=0;
	if (cnt[1]<cnt[0])
	s=1;
	if (cnt[s]<=pos[0].size())
	{
		for (int i=1;i<=n;i++)
		{
			if (col[i]==s)
			{
				ans[i]=pos[0].back();
				pos[0].pop_back();
			}
		}
	}
	else
	{
		for (int i=1;i<=n;i++)
		{
			if (col[i]==s)
			{
				if (!pos[s+1].empty())
				{
					ans[i]=pos[s+1].back();
					pos[s+1].pop_back();
				}
				else
				{
					ans[i]=pos[0].back();
					pos[0].pop_back();
				}
			}
		}
	}
	for (int i=1;i<=n;i++)
	{
		if (!ans[i])
		{
			for (int j=0;j<3;j++)
			{
				if (!pos[j].empty())
				{
					ans[i]=pos[j].back();
					pos[j].pop_back();
					break;
				}
			}
		}
	}
	for (int i=1;i<=n;i++)
	printf("%d ",ans[i]);
}

Measured memory_bytes: 20088
#include <bits/stdc++.h>
using namespace std;
typedef std::pair<int, int> ipair;
#define int long long
#define pb push_back
#define ff first
#define INF INT_MAX
#define ss second
#define fr(i, j, a) for (int i = j; i < a; i++)
#define cnt_ones(x) __builtin_popcount(x)
#define all(x) x.begin(), x.end()
#define sz size()
#define endl "\n"
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<ipair>
#define mod 1000000007
#define ar array
#define IOS                                                                    \
  std::ios::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

void init() {
  int n;
  cin >> n;
  vi a(n);
  for (int &i : a)
    cin >> i;
  vi l(n), r(n);
  l[0] = INT_MIN;
  r[n - 1] = INT_MIN;
  vi ans;
  for (int i = 1; i < n; i++)
    l[i] = max(l[i - 1], a[i - 1]);
  for (int i = n - 2; i >= 0; i--)
    r[i] = max(a[i + 1], r[i + 1]);
  for (int i = 0; i < n; i++)
    ans.push_back(max(l[i], r[i]));
  for(auto x:ans) cout<<x<<" ";
}
int32_t main() {
  IOS;
  init();
  return 0;
}


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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> A(N);
    map<int64_t, int64_t> appear_count;
    for (int64_t& a : A) {
        cin >> a;
        appear_count[a]++;
    }

    int64_t sum = 0;
    for (const auto& p : appear_count) {
        sum += p.second * (p.second - 1) / 2;
    }

    for (int64_t a : A) {
        int64_t count = appear_count[a];
        int64_t sub = (count == 1 ? 0 : (count - 1) * (count - 2) / 2 - count * (count - 1) / 2);
        cout << sum + sub << endl;
    }
}

Measured memory_bytes: 11008
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<set>
#include<string.h>
#include<queue>
#include<map>
#include<unordered_map>
#include<vector>
//~#include<algorithm>
#include<iomanip>
#include<limits>
#include<string.h>

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
 
#define pb push_back
#define ii pair<int, int>
#define vai freopen("in","r",stdin);
#define inf 0x3f3f3f3f
#define f first
#define s second

const ll INF = 1e18;
const double dinf = 12345678;
const int MOD = 1000000007;
const int maxn = 1000010;
 


//~ output :5 4 4 8


int a, b,c ,d;
int f(int n , int k){
	while(k--)n*=2;
	return n;
}
signed main (){
 
	
	ios_base::sync_with_stdio(0); cin.tie(nullptr);  
	cin >> a >> b >> c >> d;
	
	if(a>b)swap(a,b);
	if(b>c)swap(b,c);
	if(a>b)swap(a,b);
	cout << f(c,d) + b + a << '\n';
 
}


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

#define ll long long
#define endl "\n"
#define deb(x) cerr << #x << ":" << x << "\n"

void solve()
{
	int n, m, x;
	cin >> n >> m >> x;
	vector<vector<int> > v(n, vector<int>(m + 1));
	for (int i = 0; i < n;i++){
		for (int j = 0; j <= m;j++)
			cin >> v[i][j];
	}
	ll ans = INT64_MAX;
	for (int i = 0; i < (1 << n); i++)
	{
		vector<int> d(m);
		ll val=0;
		for (int j = 0; j < n; j++)
		{
			if(i&(1<<j)){
				val += v[j][0];
				for (int k = 1; k <= m;k++)
					d[k - 1] += v[j][k];
			}
		}
		bool ok = 1;
		for(auto el:d){
			if(el<x)
				ok = 0;
		}
		if(ok)
			ans = min(ans, val);
	}
	if(ans==INT64_MAX)
		ans = -1;
	cout << ans << endl;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	while (t--)
		solve();
	return 0;
}

Measured memory_bytes: 3624
using System;
using System.Text;
using System.Collections.Generic;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        int[] A = new int[N];
        bool[] R = new bool[N];
        {
            string[] str0 = Console.ReadLine().Split(' ');
            string[] str1 = Console.ReadLine().Split(' ');
            string[] str2 = Console.ReadLine().Split(' ');
            for(int i=0;i<N;i++){
                int x = int.Parse(str0[i]);
                int y = int.Parse(str1[i]);
                int z = int.Parse(str2[i]);
                if(x+1 == y && y+1 == z && z%3 == 0){
                    A[i] = y/3;
                    R[i] = (i%4 >= 2) ^ (A[i]%4 >= 2) ^ true;
                }
                else if(x-1 == y && y-1 == z && x%3 == 0){
                    A[i] = y/3;
                    R[i] = (i%4 >= 2) ^ (A[i]%4 >= 2);
                }
                else{
                    sb.Append("No\n");
                    return;
                }
                if((A[i] - i) % 2 != 0){
                    sb.Append("No\n");
                    return;
                }
            }
        }
        {
            int[] P = new int[(N+1)/2];
            int[] E = new int[(N+1)/2];
            bool b = true;
            for(int i=0;i<(N+1)/2;i++){
                P[A[i*2]/2] = i;
                E[i] = A[i*2]/2;
            }
            for(int i=0;i<(N+1)/2;i++){
                if(P[i] != i){
                    b = !b;
                    int temp = E[i];
                    P[E[i]] = P[i];
                    E[i] = E[P[i]];
                    E[P[i]] = temp;
                    P[i] = i;
                }
            }
            for(int i=0;i<N/2;i++){
                if(!R[i*2+1]){
                    b = !b;
                }
            }
            if(!b){
                sb.Append("No\n");
                return;
            }
        }
        {
            int[] P = new int[N/2];
            int[] E = new int[N/2];
            bool b = true;
            for(int i=0;i<N/2;i++){
                P[A[i*2+1]/2] = i;
                E[i] = A[i*2+1]/2;
            }
            for(int i=0;i<N/2;i++){
                if(P[i] != i){
                    b = !b;
                    int temp = E[i];
                    P[E[i]] = P[i];
                    E[i] = E[P[i]];
                    E[P[i]] = temp;
                    P[i] = i;
                }
            }
            for(int i=0;i<(N+1)/2;i++){
                if(!R[i*2]){
                    b = !b;
                }
            }
            if(!b){
                sb.Append("No\n");
                return;
            }
        }
        sb.Append("Yes\n");
    }
}

Measured memory_bytes: 35652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;

void solve() {
	int n;
	cin >> n;
	VI a(n);
	rep(i, 0, n)cin >> a[i];
	sort(all(a));
	ll ans = 0;
	int cnt = n - 1;
	for (int i = n - 1; i >= 0; i--) {
		if (i == n - 1) {
			ans += a[i];
			cnt--;
		}
		else {
			if (cnt >= 2) {
				ans += 2 * a[i];
				cnt -= 2;
			}
			else {
				ans += a[i];
				cnt -= 1;
			}
		}
		if (cnt == 0) {
			break;
		}
	}
	cout << ans << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}







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

#define ll long long
#define int ll
#define pii pair<int, int>
#define pb push_back
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

void solve() {
    int N;
    cin >> N;
    if (N%2 == 0) {
        print(0.5);
    } else {
        print((floor(double(N)/2)+1)/N);
    }
}

signed main() {
    solve();
}


Measured memory_bytes: 768
N = int(input())

if N == 1:
    print(0)
    exit()

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

candidates = factorization(N)
# print(candidates)
li = []

for item in candidates:

    for i in range(item[1]):
        li.append(item[0]**(i+1))

li.sort()
# print(li)

cnt = 0
for i in range(len(li)):
    if N % li[i] == 0:
        N /= li[i]
        cnt += 1

print(cnt)


Measured memory_bytes: 63412
#include <iostream>
#include <queue>

using namespace std;

int main(){
  priority_queue<int> PQ;
  char com[20];

  while(1){
    cin>>com;
    if(com[0]=='i'){
      int key;
      cin>>key;
      PQ.push(key);
    }
    else if(com[1]=='x'){
      cout<<PQ.top()<<"\n";
      PQ.pop();
    }

    else{
      break;
    }
  }


  return 0;
}

Measured memory_bytes: 6992
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<functional>
#include<map>
using namespace std;
typedef long long ll;
int main()
{
	int n=0,x;
	int res=0;
	map<int,int> a;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		if(a[x]==0){a[x]++;res++;}
	}
	cout<<res<<endl;
	return 0;
}

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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

const int MOD = 1000000007;

void add(int &a, int b) {
  if ((a += b) >= MOD) a -= MOD;
}

void sub(int &a, int b) {
  if ((a -= b) < 0) a += MOD;
}

int mul(int a, int b) {
  return (int) ((a * 1LL * b) % MOD);
}

int mpow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = mul(res, a);
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

int minv(int x) {
  return mpow(x, MOD - 2);
}

// (altering lowest row, non-altering)
pair<int, int> solve(vector<int> v) {
  if (v.size() == 0) {
    return {1, 0};
  }
  if (v.size() == 1) {
    return {mpow(2, v[0]), 0};
  }
  int m = *min_element(v.begin(), v.end());

  int res1 = 1;
  int res2 = 1;
  vector<int> st;
  for (int i = 0; i <= (int)v.size(); i++) {
    if (i != (int)v.size() && v[i] > m) {
      st.push_back(v[i] - m + 1);
    } else {
      auto r = solve(st);
      res1 = mul(res1, mul(r.first, minv(st.empty() ? 1 : 2)));
      res2 = mul(res2, r.first + r.second);
      if (i != (int)v.size()) {
        res2 = mul(res2, 2);
      }
      st.clear();
    }
  }

  sub(res2, mul(res1, 2));
  res1 = mul(res1, mpow(2, m));

  return {res1, res2};
}

int main() {
#ifdef LOCAL
  freopen("d.in", "r", stdin);
  freopen("d.out", "w", stdout);
#endif

  int n;
  while (scanf("%d", &n) == 1) {
    vector<int> v(n);
    for (int &x : v) {
      scanf("%d", &x);
    }
    auto res = solve(v);
    printf("%d\n", (res.first + res.second) % MOD);
//    break;
  }

  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    int n;
    int A[1000000];
    cin >> n;
    for(int i=0;i<n;i++) cin >> A[i];

    int m=0;
    int g=0;
    int cnt=0;
    vector<int> G;
    while(3*g+1<=n) g=3*g+1;
    for(;g>0;g/=3){
        G.push_back(g);
        m++;
    }
    for(int i=0;i<m;i++){
        for(int j=G[i];j<n;j++){
            int v=A[j];
            int k=j-G[i];
            while(k>=0 && A[k]>v){
                A[k+G[i]]=A[k];
                k-=G[i];
                cnt++;
            }
            A[k+G[i]]=v;
        }
    }

    cout << m << endl;
    cout << G[0];
    for(int i=1;i<m;i++) cout << ' ' << G[i];
    cout << endl;
    cout << cnt << endl;
    for(int i=0;i<n;i++) cout << A[i] << endl;

    return 0;
}


Measured memory_bytes: 6940
#include <bits/stdc++.h>
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define mod         (ll)1000000007
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = (ll)1e18;
ld pi = 3.141592653589;
using namespace std;

ll bpow(ll x, ll v) {	
	if (v == 0)
		return 1 % mod;
	if (v % 2 == 1)
		return (x * bpow(x, v - 1)) % mod;
	ll r = bpow(x, v / 2);
	return (r * r) % mod;	
}

ll lcm(ll a,ll b)
{
	ll ret=(a*b)/__gcd(a,b);
	return ret;
} 

ll solve(){ 
	string a; cin>>a;
	ll n = sz(a);
	ll l=0,r = n-1,ans=0;
	while(l<r){
		if(a[l]!=a[r])
			ans++;
		l++;
		r--;
	}
	cout<<ans;
}
int main(){
    ios
    ll t=1; 
    //cin>>t;
    while(t--){
    	solve();
    }
}

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

int main(){
    string S;
    cin >> S;
    for(int i=0; i<3; i++) if(S[i] == S[i+1]){
        cout << "Bad" << endl;
        return 0;
    }
    cout << "Good" << endl;
    return 0;
}


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

static const int MAX = 100000;

int n, A[MAX + 1], L[MAX];

int lis() {
  L[0] = A[0];
  int length = 1;

  for (int i = 1; i < n; i++) {
    if (L[length - 1] < A[i]) {
      L[length] = A[i];
      length++;
    } else {
      *lower_bound(L, L + length, A[i]) = A[i];
    }
  }

  return length;
}

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

  cout << lis() << endl;

  return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <algorithm> 
#include <cmath>
#include <numeric>
using namespace std;


int main(void){
    // Your code here!
    vector<int> v(5);
    for(int i=0; i<5; i++) cin >> v[i];
    
    vector<int> fv(5);
    
    transform(v.begin(), v.end(), fv.begin(), [](int x){return x%10==0 ? 10 : x%10 ;} );
    //for(int i=0; i<5; i++) cout << fv[i];
    
    auto it = min_element(fv.begin(), fv.end());
    auto min_index = distance(fv.begin(), it);
    int f = fv[min_index];
    //cout << f << endl;
    vector<int> tv(5);
    transform(v.begin(), v.end(), tv.begin(), [](int x){return (int)(ceil((float)x/10)*10);} );
    //for(int i=0; i<5; i++) cout << tv[i];
    cout << accumulate(tv.begin(), tv.end(), 0) - (10-f) << endl;
    
    return 0;
}


Measured memory_bytes: 256
a,b,x = map(int,input().split())

v_max = a * a * b
v_emp = a * a * b - x

if v_emp < v_max / 2:
    tan = 2 * v_emp / (a ** 3)
else:
    tan = a * b * b / (2 * x)

import math
deg = math.degrees(math.atan(tan))

print(deg)

Measured memory_bytes: 3060