akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <string>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x,y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template<class T> using vv=vector<vector<T>>;
typedef deque<int> di;
typedef deque<deque<int>> ddi;


int main() {
    int t;
    cin >> t;
    rep(j,t) {
        int n,k;
        int x[100000];
        int y[100000];
        cin >> n >> k;
        rep(i,n) {
            cin  >> x[i];
        }
        FOR(i,1,n) {
            y[i-1] = x[i] - x[i-1];
        }
        sort(begin(y), &y[n-1]);
        int sum = 0;
        rep(i,n-k) {
            sum += y[i];
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3864
def cin; gets.split.map(&:to_i) end
def cout(*x); puts x.join(" ") end

# exit if $0 != __FILE__

s = gets.chop
c1, c2 = 0, 0
s.chars.each_with_index do |x, i|
  if x == ((i%2==0) ? "0" : "1") then
    c1 += 1
  else
    c2 += 1
  end
  #p "#{c1},#{c2}"
end

puts [c1, c2].min


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

int main(){
    int N, D;

    cin >> N >> D;

    double X[N][D];
    double sum;
    int ans = 0;

    for(int i = 0; i < N; i++){
        for(int j = 0; j < D; j++){
            cin >> X[i][j];
        }
    }

    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            sum = 0.0;
            for(int k = 0; k < D; k++){
                sum += pow(X[i][k] - X[j][k], 2.0);
            }
            sum = pow(sum, 0.5);
            if(abs(sum - floor(sum)) < 0.0001){
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a,b) for(int i=int(a);i>int(b);--i)
using namespace std;
using ll = long long;

int p[2][200010];
map<int, int> mp[200010];

void init(int t, int n){
  rep(i,n) p[t][i]=i;
}

int root(int t, int x){
  if(p[t][x]==x) return x;
  else return p[t][x]=root(t,p[t][x]);
}

bool same(int t, int x, int y){
  return root(t,x)==root(t,y);
}

void unite(int t, int x, int y){
  x = root(t,x);
  y = root(t,y);
  if(x==y) return;

  p[t][x] = y;
}

int main()
{
  int N,K,L;
  cin >> N >> K >> L;

  init(0,N);
  init(1,N);

  int p,q;
  rep(i,K){
    cin >> p >> q;
    unite(0,p-1,q-1);
  }
  rep(i,L){
    cin >> p >> q;
    unite(1,p-1,q-1);
  }

  rep(i,N) mp[root(0,i)][root(1,i)]++;
  rep(i,N) cout << mp[root(0,i)][root(1,i)] << ((i==N-1)?"\n":" ");
}


Measured memory_bytes: 20096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

int main() {
    int n, m;
    cin >> n >> m;
    
    vector<vector<int> > v(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        v[a].eb(b);
        v[b].eb(a);
    }
    
    vector<pii> reached(100001, {0, 0});
    rep(i, 100001) reached[i].S = i;
    reached[0].F = 1e6;
    
    
    { // 左側 次数3以上でも、テキトーに一つ選ぶ
        queue<int> q;
        q.push(0);
        while (!q.empty()) {
            int now = q.front();
            q.pop();
            
            for (int nxt : v[now]) {
                if (reached[nxt].F == 0) {
                    q.push(nxt);
                    reached[nxt].F = reached[now].F - 1;
                    break;
                }
            }
        }
    }
    
    {
        queue<int> q;
        q.push(0);
        while (!q.empty()) {
            int now = q.front();
            q.pop();
            
            for (int nxt : v[now]) {
                if (reached[nxt].F == 0) {
                    q.push(nxt);
                    reached[nxt].F = reached[now].F + 1;
                    break;
                }
            }
        }
    }
    
    sort(all(reached));
    int cnt = 0;
    rep(i, 100001) if (reached[i].F) cnt++;
    out(cnt);
    int flg = 0;
    rep(i, 100001) {
        if (reached[i].F == 0) continue;
        if (flg++) cout << " ";
        cout << reached[i].S + 1;
    }
    cout << endl;
}


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

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

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 != 0 && i % 5 != 0) {
            ans += i;
        }
    }

    cout << ans << endl;
}


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

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

#define INF INT_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int H,W;
  cin>>H>>W;
  vector<string>S(H);
  for(int i=0;i<H;i++)cin>>S[i];
  vector<vector<ll>>sum(H,vector<ll>(W));
  for(int i=0;i<H;i++){
    vector<ll>tor(W,0);
    for(int j=0;j<W;j++){
      if(j==0&&S[i][j]=='.')tor[j]=1;
      else if(j!=0&&S[i][j]=='.')tor[j]=tor[j-1]+1;
      else tor[j]=0;
    }
    vector<ll>tol(W,0);
    for(int j=W-1;j>=0;j--){
      if(j==W-1&&S[i][j]=='.')tol[j]=1;
      else if(j!=W-1&&S[i][j]=='.')tol[j]=tol[j+1]+1;
      else tol[j]=0;
    }
    vector<ll>res(W,0);
    for(int j=0;j<W;j++){
      res[j]=max(tol[j],tor[j]);
    }
    for(int j=1;j<W;j++){
      if(S[i][j]=='.')res[j]=max(res[j-1],res[j]);
    }
    for(int j=W-2;j>=0;j--){
      if(S[i][j]=='.')res[j]=max(res[j+1],res[j]);
    }
    sum[i]=res;
  }

  for(int i=0;i<W;i++){
    vector<ll>tod(H,0);
    for(int j=0;j<H;j++){
      if(j==0&&S[j][i]=='.')tod[j]=1;
      else if(j!=0&&S[j][i]=='.')tod[j]=tod[j-1]+1;
      else tod[j]=0;
    }
    vector<ll>tou(H,0);
    for(int j=H-1;j>=0;j--){
      if(j==H-1&&S[j][i]=='.')tou[j]=1;
      else if(j!=H-1&&S[j][i]=='.')tou[j]=tou[j+1]+1;
      else tou[j]=0;
    }
    vector<ll>res(H);
    for(int j=0;j<H;j++){
      res[j]=max(tod[j],tou[j]);
    }
    for(int j=1;j<H;j++){
      if(S[j][i]=='.')res[j]=max(res[j-1],res[j]);
    }
    for(int j=H-2;j>=0;j--){
      if(S[j][i]=='.')res[j]=max(res[j+1],res[j]);
    }
    for(int j=0;j<H;j++){
      sum[j][i]+=res[j];
    }
  }
  ll ans=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(sum[i][j]!=0)sum[i][j]--;
      ans=max(ans,sum[i][j]);
      //cout<<sum[i][j]<<" ";
    }
    //cout<<endl;
  }
  cout<<ans<<endl;
  return 0;
}


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

cnt1 = 0
cnt2 = 0
while c > 0:
    c -= b
    cnt1 += 1

while a > 0:
    a -= d
    cnt2 += 1

if cnt1 <= cnt2:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 8976
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
from bisect import bisect_left

def main():
    n = int(input().strip())
    a = [0] * n
    for i in range(n):
        a[i] = int(input().strip())
    l = [a[0]]
    for i in range(1, n):
        if a[i] <= l[-1]:
            k = bisect_left(l, a[i])
            l[k] = a[i]
        else:
            l.append(a[i])
    print(len(l))

if __name__ == '__main__':
    main()



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

int main() {
  int n;
  int a[3] = {2, 3, 5};
  int b[3] = {380, 550, 850};
  int c[3] = {5, 4, 3};
  int d[3] = {20, 15, 12};
  int e[3];
  int z[51] = {0};
  int f, g, h, s;

  for (int i=0; i<3; i++) {
    e[i] = b[i] * c[i] * (100 - d[i]) / 100;
  }

  for (int i=0; i<3; i++) {
    for (int j=0; j<=50; j++) {
      if (j && !z[j]) continue;
      int k=1;
      while (1) {
        f = j+k*a[i];
        if (f>50) break;
        g = k / c[i];
        h = k - g*c[i];
        s = z[j] + g*e[i] + h*b[i];
        if (!z[f] || s<z[f]) z[f] = s;
        k++;
      }
    }
  }

  //for (int i=6; i<=50; i++) {
  //  for (int j=i-1; j>=5; j--) {
  //    if (z[j]<=z[i]) break;
  //    z[j] = z[i];
  //  }
  //}

  while (cin >> n && n) {
    cout << z[n/100] << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vvi g;
vi res,a;

void dfs(int v,int p,vi &dp){
	res[v]=lower_bound(dp.begin(),dp.end(),inf)-dp.begin();
	for(auto u:g[v]) if(u!=p){
		int it=lower_bound(dp.begin(),dp.end(),a[u])-dp.begin();
		swap(dp[it],a[u]);
		dfs(u,v,dp);
		swap(dp[it],a[u]);
	}
}

int main(){
	cin>>n;
	g=vvi(n);
	res=a=vi(n);
	for(auto &i:a) cin>>i;
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	vi dp(n+1,inf);
	dp[0]=a[0];
	dfs(0,-1,dp);
	for(auto i:res) cout<<i<<endl;
}

Measured memory_bytes: 30892
n, m = map(int, input().split())
ansFlag = [0 for i in range(n)]
waList = [0 for i in range(n)]
ac = 0
wa = 0
for i in range(m) :
  p, S = input().split()
  p = int(p)
  if str(S) == 'AC' and ansFlag[p-1] == 0 :
    ac += 1
    ansFlag[p-1] = 1
  elif ansFlag[p-1] == 0 :
    wa += 1
    waList[p-1] += 1
    
for i in range(len(ansFlag)) :
  if ansFlag[i] == 0 :
    wa -= waList[i]
print(str(ac) + ' ' + str(wa))


Measured memory_bytes: 4772
#include<iostream>
#include<cstdio>
using namespace std;
const int INF = 2e9;

int n, r[200000];
int ans = -INF;
int main()
{
  scanf("%d", &n);
  for(int i = 0; i < n; i++)
    scanf("%d", &r[i]);

  int mn = r[0];
  for(int i = 1; i < n; i++){
    ans = max(ans, r[i] - mn);
    mn = min(mn, r[i]);
  }

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

Measured memory_bytes: 1968
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
const double PI  =3.141592653589793238463;
using namespace std;
using ll = long long;
const ll INF = +10010010000;
typedef pair<int,int> P;
const int mod = 1e9+7;

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

    // for prime mod
    mint inv() const {
      return pow(mod-2);
    }
    mint& operator/=(const mint a){
      return (*this) *= a.inv();
    }
    mint operator/(const mint a)const{
      mint res(*this);
      return res/=a;
    }
};

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

vector<int> dp;
int main(){
    int n;
    dp.resize(n+5,10e5);
    dp[0] = 0;
    cin >> n;
    set<int> d;
    d.insert(1);
    rrep(i,20){
        if(pow(6,i)>1000000)break;
        d.insert(pow(6,i));
        d.insert(pow(9,i));
    }
    vector<int> a;
    for(auto ele : d){
        a.push_back(ele);
    }
    rrep(i,n){
        rep(j,a.size()){
            if(i-a[j]<0)break;
            dp[i] = min(dp[i], dp[i-a[j]]+1);
        }
    }
    cout << dp[n] << endl;
    // rep(i,40)cout<<dp[i] << " ";
    // cout << endl;
    return 0;

    // rep(i,10)cout<<a[i]<<" ";
    // cout << endl;
    // int ans = 0;
    // while(n>0){
    //     auto t = distance(a.begin(),upper_bound(a.begin(),a.end(),n));
    //     --t;
    //     printf("[n,t,a[t]] = [%d,%d,%d]\n",n,t,a[t]);
    //     n-=a[t];
    //     ans++;
    // }
    // cout << ans << endl;
    // return 0;
}

Measured memory_bytes: 16640
L = []
for i in range(3):
  L.append(list(map(int,input().split())))
p = [0,L[1][0]-L[0][0],L[2][0]-L[0][0]]
q = [L[0][0],L[0][1],L[0][2]]
flag = True
for i in range(3):
  for j in range(3):
    if L[i][j] != p[i]+q[j]:
      flag = False
      break
if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
program main
Implicit None
	integer i,N,M,count,Lmax,Rmin
	integer,allocatable :: L(:),R(:)
	
	read(5,*) N,M
	allocate(L(M),R(M))
	Lmax=0	;Rmin=N
	
	do i=1,M
		read(5,*) L(i),R(i)
		if(L(i)>Lmax)	Lmax=L(i)
		if(R(i)<Rmin)	Rmin=R(i)
	end do
	
	count=Rmin-Lmax+1
	if(count<0)	count=0
	write(6,'(i0)') count

end program main

Measured memory_bytes: 1152
def pow_k(x, n):
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K = K * x
            x = x ** 2
            n = (n - 1) // 2
        else:
            x = x ** 2
            n = n // 2

    return K * x


MOD = 10**9 + 7

N = int(input())
An = list(map(int, input().split()))

res = 0
for d in range(60):
    n0, n1 = 0, 0
    for i in range(N):
        if (An[i] >> d) & 1:
            n1 += 1
        else:
            n0 += 1

    temp = pow_k(2, d) % MOD
    temp *= (n0*n1) % MOD
    res = (res + temp) % MOD

print(res)


Measured memory_bytes: 125624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define ff first
#define ss second
#define p pair<int,int>
#define pb push_back
#define endl '\n'
#define w(t) ll test;cin>>test;while(test--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define pi acos(-1)

int main()
{
    fast;
    int n,m,x;
    cin>>n>>m>>x;
    vector<vector<int>>book(n,vector<int>(m+1));
    for(auto &i:book)
    {
        for(auto &j:i)
        {
            cin>>j;
        }
    }
    ll mn=1e18;
    for(int mask=0;mask<(1<<n);mask++)
    {
        ll sum=0;
        vector<ll> val(m);
        for(int i=0;i<n;i++)
        {
            if(mask&(1<<i))
            {
                sum+=book[i][0];
                for(int j=0;j<m;j++)
                {
                    val[j]+=book[i][j+1];
                }
            }
        }
        bool flag=1;
        for(auto i:val)
        {
            if(i<x)
            {
                flag=0;
                break;
            }
        }
        if(flag)mn=min(mn,sum);
    }
    cout<<(mn==1e18?-1:mn)<<endl;
}



Measured memory_bytes: 3672
h,w,k=map(int,input().split())
ws=[0]*10
ws[0]=1
ws[1]=1
for i in range(2,10):
    ws[i]=ws[i-1]+ws[i-2]
dp=[[0 for i in range(h+1)] for j in range(w)]
dp[0][0]=1
mod=10**9+7
if w==1:
    print(1)
    exit()
for i in range(h):
    for j in range(w):
        if j==0:
            dp[0][i+1]=dp[0][i]*ws[w-1]+dp[1][i]*ws[max(0,w-2)]
            dp[0][i+1]%=mod
        elif j==w-1:
            dp[w-1][i+1]=dp[w-1][i]*ws[w-1]+dp[w-2][i]*ws[max(0,w-2)]
            dp[w-1][i+1]%=mod
        else:
            dp[j][i+1]=dp[j][i]*ws[max(0,j)]*ws[max(0,w-j-1)]+dp[j-1][i]*ws[max(0,j-1)]*ws[max(0,w-j-1)]+dp[j+1][i]*ws[max(0,j)]*ws[max(0,w-j-2)]
            dp[j][i+1]%=mod
print(dp[k-1][h]%mod)


Measured memory_bytes: 3064
from itertools import groupby as gb 
n=int(input())
l=[(s,len(list(i))) for s,i in gb(sorted([input() for i in range(n)]))]
sl,vl=[list(a) for a in zip(*l)]
m=int(input())
lm=[(s,-len(list(i))) for s,i in gb(sorted([input() for i in range(m)]))]
slm,vlm=[list(a) for a in zip(*lm)]
for i in set(sl)&set(slm):
  vl[sl.index(i)]+=vlm[slm.index(i)]
print(max(0,max(vl)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
#define mod 1000000007
using namespace std;
vector<ll> val;
ll cnt = 0;
void solve()
{
    
}
bool compare(vector<ll> &a, vector<ll> &b, ll n)
{
    ll i= 0;
    while(i<n)
    {
        if(a[i]!=b[i])
            return false;
        i++;
    }
    return true;
}
bool find(ll k, vector<ll> & ans)
{
    for (ll i = 0; i < ans.size(); i++)
    {
        if(ans[i] == k)
            return true;
    }
    return false;
}
void permute(ll s, vector<ll> &p, vector<ll>& q, ll n, vector<ll> & ans)
{
    // cout<<s<<'\n';
    if(ans.size() == n)
    {
        cnt++;
        // for(ll i=0; i<n; i++)
        // {
        //     cout<<ans[i]<<" ";
        // }
        // cout<<'\n';
        if(compare(ans, p, n))
        {
            val.push_back(cnt);
        }
        if(compare(ans, q, n))
        {
            val.push_back(cnt);
        }
    }
    for(ll i=1; i<=n; i++)
    {
        if(!find(i, ans))
        {
            ans.push_back(i);
            permute(i, p, q, n, ans);
            ans.pop_back();
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
    ll n;
    cin>>n;
    vector<ll> p,q;
    for (ll i = 0; i < n; i++)
    {
        /* code */
        ll p1;
        cin>>p1;
        p.push_back(p1);
    }
    for (ll i = 0; i < n; i++)
    {
        /* code */
        ll p1;
        cin>>p1;
        q.push_back(p1);
    }
    vector<ll> ans;
    for(ll i=1; i<=n; i++)
    {
        ans.push_back(i);
        permute(i, p , q, n, ans);
        ans.pop_back();
    }
    cout<<val[1] - val[0]<<'\n';
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
typedef long long ll;
const int MOD = 1000000007;
using namespace std;

int main() {
	int n;
	string s1, s2;
	cin >> n >> s1 >> s2;
	int count = 1;
	vector<int> a;
	for (int i = 0; i < s1.size() - 1; i++) {
		if (s1[i] == s1[i + 1])
			count++;
		else {
			a.push_back(count);
			count = 1;
		}
	}
	a.push_back(count);
	ll ans;
	if (a[0] == 2)
		ans = 6;
	else
		ans = 3;
	for (int i = 1; i < a.size(); i++) {
		if (a[i - 1] == 1)
			ans = ans * 2 % MOD;
		else if (a[i - 1] == 2 && a[i] == 2)
			ans = ans * 3 % MOD;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;
typedef long long int ll;
typedef vector<pair<int, int> > vpii;
int n, m;
main(){
	int i,j;
	while(cin >> n >> m){
		int ans;
		vpii data(n);
		for(i=0;i<n;i++) cin >> data[i].first >> data[i].second;
		sort(data.begin(), data.end());
		for(i=0;i<m;i++){
			int x1,y1,x2,y2,ans=0;
			cin >> x1 >> y1 >> x2 >> y2;
			vpii::iterator itr1 = lower_bound(data.begin(), data.end(), pair<int, int>(x1, y1));
       		vpii::iterator itr2 = upper_bound(data.begin(), data.end(), pair<int, int>(x2, y2));
       		for(;itr1!=itr2;++itr1){
       			if(y1 <= (*itr1).second && (*itr1).second <= y2) ans ++;
       		}
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1236
import java.util.*;

public class Main {

    public static String printAnswer(int[][] c) {
        int col1 = 0;
        int col2 = 0;
        int col3 = 0;
        int row1 = 0;
        int row2 = 0;
        int row3 = 0;
        for (int i = 1; i < 3; i++) {
            col1 = c[0][0] - c[i][0];
            col2 = c[0][1] - c[i][1];
            col3 = c[0][2] - c[i][2];
            if (col1 != col2 || col2 != col3) {
                return "No";
            }
            row1 = c[0][0] - c[0][i];
            row2 = c[1][0] - c[1][i];
            row3 = c[2][0] - c[2][i];
            if (row1 != row2 || row2 != row3) {
                return "No";
            }
        }
        return "Yes";
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[][] c = new int[3][3];
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                c[i][j] = sc.nextInt();
            }
        }
        System.out.println(printAnswer(c));
    }

}


Measured memory_bytes: 23636
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <chrono>
#include <numeric>

using namespace std;


int main(){
  int n, k, x, e;
  cin >> n;
  cin >> k;
  x = 1;
  e = 0;
  
  while ((k >> e) > 0) {
    e++;
  }

  e = n<e?n:e;

  for (int i=0;i<e;i++) {
    x *= 2;
  }
  if (n > e)
    x += k*(n - e);
  cout << x << endl;
}


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

using namespace std;

int main() {
	int n, x[110], y[110], h[110], ch, temp;
	bool found = false, valid;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d %d %d", &x[i], &y[i], &h[i]);
	for (int cx = 0; cx < 101; cx++) {
		if (found)
			break;
		for (int cy = 0; cy < 101; cy++) {
			if (found)
				break;
			temp = 0;
			while (h[temp] == 0)
				temp++;
			ch = h[temp] + abs(cx - x[temp]) + abs(cy - y[temp]);
			valid = true;
			for (int i = 0; i < n; i++) {
				temp = max(ch - abs(cx - x[i]) - abs(cy - y[i]), 0);
				if (temp != h[i]) {
					valid = false;
					break;
				}
			}
			if (valid) {
				printf("%d %d %d\n", cx, cy, ch);
				found = true;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
//package Atcoder;
import java.util.*;
import java.io.*;
public class Main
{
	static final int mod=(int)1e9+7;
	static final int inf=(int)1e9;
	static final long INF=(long)1e18;
	public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		int n=fs.nextInt();
		String s="";
		for(int i=1;i<=n;i++)
		{
			s+="ACL";
		}
		System.out.println(s);
	}
}
class FastScanner 
{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		public String next() 
		{
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		long pow(long x,long n)
		{
			long res=1;
			while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			}
			return res;
		}
		int gcd(int a,int b)
		{
			if(b==0)
			{
				return a;
			}
			return gcd(b,a%b);
		}
		long longgcd(long a,long b)
		{
			if(b==0)
			{
				return a;
			}
			return longgcd(b,a%b);
		}
		int[] sort(int arr[])
		{
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		char[] charsort(char arr[])
	        {
	    	ArrayList<Character> list = new ArrayList<>();
	    	for(char c:arr)list.add(c);
	    	Collections.sort(list);
	    	for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	}
	    	return arr;
	        }
		long[] longsort(long arr[])
		{
			ArrayList<Long> list = new ArrayList<Long>();
			for(long i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		public int nextInt() 
		{
			return Integer.parseInt(next());
		}
		public int[] readArray(int n)
		{
			int[] arr=new int[n];
			for (int i=0; i<n; i++) arr[i]=nextInt();
			return arr;
		}	
		public long nextLong()
		{
			return Long.parseLong(next());
		}
		public long[] longreadArray(int n) 
		{
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
}

Measured memory_bytes: 36340
n = int(input())
points = [list(map(lambda x: int(x), input().split(" "))) for x in range(n)]

t = 0
x = 0
y = 0

able = True
for point in points:
    dt = point[0] - t
    dl = abs(point[1] - x)+abs(point[2]-y)
    if dt-dl>=0 and (dt-dl)%2 == 0:
        pass
    else:
        able = False
    t = point[0]
    x = point[1]
    y = point[2]
print("Yes" if able else "No")

Measured memory_bytes: 27288
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
//26

const int MAX = 300;
struct edge{int to, cap, rev;};
vector<edge> G[MAX];
int used[MAX];
void add_edge(int from, int to, int cap){
	G[from].push_back((edge){to, cap, G[to].size()});
	G[to].push_back((edge){from, 0, G[from].size()-1});
}

int dfs(int v, int t, int f){
	if(v == t)return f;
	used[v] = 1;
	rep(i,G[v].size()){
		edge &e = G[v][i];
		if(used[e.to] == 0 and e.cap > 0){
			int d = dfs(e.to, t, min(f, e.cap));
			if(d > 0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t){
	int flow = 0;
	while(1){
		fill(used, used+MAX, 0);
		int f = dfs(s, t, inf);
		if(f == 0)return flow;
		flow += f;
	}
}

int a[200];
signed main(){
	int n, mx = 0;
	scanf("%lld", &n);
	rrep(i,n)scanf("%lld", &a[i]);
	int s = n+1, t = s+1;
	rrep(i,n){
		mx += max((int)0, a[i]);
		if(a[i] >= 0){add_edge(s, i, 0);add_edge(i, t, a[i]);}
		else {add_edge(s, i, -a[i]);add_edge(i, t, 0);}
		repi(j,2,inf){
			if(i*j > n)break;
			add_edge(i, i*j, INF);
		}
	}
	int res = max_flow(s, t);
	printf("%lld\n", mx-res);
	return 0;
}





Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<bool> vbool;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<llint> vllint;
typedef vector<vllint> vvllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;
#define Pi 3.1415926535897932384626
#define coutans rep(i, ans.size())cout << ans[i] << endl;
#define mod (llint)1000000007
#define int_max 2147483647
#define ll_max (llint)9223372036854775807

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(llint a, llint b) {
	return a > b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aのb乗を求める(1000000007で割った余りやで)
llint modpow(llint a, llint b) {
	if (b == 0)return 1;
	if (b == 1)return a;
	llint tmp = modpow(a, b / 2);
	tmp %= mod;
	tmp = tmp * tmp % mod;
	if (b % 2)return tmp * a % mod;
	else return tmp;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= mod;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, mod);
		ans %= mod;
	}
	return ans;
}


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int k;
	cin >> k;
	if (a > b)swap(a, b);
	if (b > c)swap(b, c);
	cout << a + b + pow(2, k) * c << endl;
	return 0;
}

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

int main() {
    int W, H, x, y, r; cin >> W >> H >> x >> y >> r;
    if (x >= 0 + r && x <= W - r && y >= 0 + r && y <= H - r)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3116
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    string s;
    cin >> s;
    s[3]='8';
    cout << s;
}

Measured memory_bytes: 256
#include "algorithm"
#include "cmath"
#include "iostream"
#include "map"
#include "string"
#include "unordered_map"
#include "vector"
constexpr int MOD = 1e9 + 7;
constexpr int INF = 1e9;
using namespace std; // std::を省略して書くことができる

int edges[8][8]{};
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    edges[a - 1][b - 1] = 1;
    edges[b - 1][a - 1] = 1;
  }
  vector<int> list;
  int ans = 0;
  for (int i = 1; i < N; i++) {
    list.push_back(i);
  }
  do {
    list.insert(list.begin(), 0);
    for (int i = 0; i < N - 1; i++) {
      if (edges[list[i]][list[i + 1]] == 0) {
        break;
      } else if (i == N - 2) {
        ans += 1;
      }
    }
    list.erase(list.begin());
  } while (next_permutation(list.begin(), list.end()));
  cout << ans << endl;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
string s;
int n;

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

  cin>>s;
  n=s.size();
  int best=1e9;
  for (int i=0; i+3<=n; i++) {
    int cur = 100*(s[i]-'0')+10*(s[i+1]-'0')+(s[i+2]-'0');
    //cout<<cur<<" "<<abs(cur-753)<<endl;
    best = min(best, abs(cur-753));
  }
  out(best);
  

  return 0;
}


Measured memory_bytes: 256
n=int(input())
s=list(input())
ans=0
ans2=0
stack=[0]*(n+1)
for i in range(n):
  if s[i]!="#":
    stack[0]+=1
    stack[i+1]-=1
  else:
    stack[i+1]+=1
for i in range(n):
  stack[i+1]+=stack[i]
print(min(stack))

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n),f(n);
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin>>f[i];
    }
    sort(all(a));
    sort(all(f));
    reverse(all(f));
    
    ll l=0,r=1e18;
    while(l<r)
    {
        ll mid=(l+r)/2;
        ll cnt=0;
        for (int i = 0; i < n; i++)
        {
            ll atmp = (mid)/f[i];
            cnt+=max(0LL,a[i]-atmp);
        }
        if(cnt<=k)
        {
            r=mid;
        }
        else 
        {
            l=mid+1;
        }
    }
    cout<<l<<endl;

    return 0;
}

Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int n[1000002];

int main()
{
    int len = 0;
    char ch;

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

    while ((ch = getchar()) != '\n' && len < 1000000)
    {
        n[len++] = ch - '0';
    }

    int64_t ans = 0;
    int add = 0;
    int cur;

    for (int i = len-1; i >= 0; --i)
    {
        cur = add + n[i];
        add = cur / 10;
        cur %= 10;
        if (cur < 5)
        {
            //cout << "digit = " << n[i]  << ", cur=" << cur << ", add=" << add << ", ans += " << cur << "\n";
            ans += cur;
        }
        else if (cur == 5 && i > 0 && n[i-1] >= 5)
        {
           add = 1;
           ans += 5;
        }
        else if (cur == 5)
        {
            ans += cur;
        }
        else
        {
            add++;
            ans += 10 - cur;
            //cout << "digit = " << n[i]  << ", cur=" << cur << ", add=" << add << ", ans += " << (10-cur) << "\n";
        }
    }

    if (add != 0)
    {
        ans += add;
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4096
#include <stdio.h>
#include <cstring>

int main(){
  int i1[2] = {0};
  int ansers[5] = {0};
  int total = 1;
 
  for(int n = 0;n < 6; n++){
    scanf("%d",&total);
    if(total == 0){
      for(int x = 0; x < n; x++) printf("%d\n",ansers[x]); 
      return 0;
    }
    memset(i1,0,sizeof(i1));

    for(int n = 0; n < 9; n++){
      scanf("%d",&i1[1]);
      i1[0] += i1[1];
    }
    ansers[n] = total - i1[0];
  }
}

Measured memory_bytes: 2572
n = int(input())
a = list(map(int, input().split()))
s = [0]
for i in a:
    s.append(s[-1]+i)
l = s[-1]
from bisect import bisect_left
j = bisect_left(s, l/2)
ans = float("inf")
for i in range(2):
    ans = min(ans, abs(2*s[j-i]-l))
print(ans)

Measured memory_bytes: 26764
#include<stdio.h>
#include<stdlib.h>

typedef struct node{
	int key;
	struct node *left;
	struct node *right;
}node;

void insert(node **p,int x){
	node *new=malloc(sizeof(node));
	new->key=x;
	new->left=NULL;
	new->right=NULL;
	
	while((*p)!=NULL){
		if((*p)->key > x)
			p=&((*p)->left);
		else
			p=&((*p)->right);
	}
	(*p)=new;
	
	return;
}

int find(node *p,int x){

	while(p!=NULL){
		if(p->key == x)return 1;
		
		if(p->key > x)
			p=p->left;
		else
			p=p->right;
	}
	
	return 0;
	
}

void inorder(node *p){
	
	if(p->left!=NULL)
		inorder(p->left);
	
	printf(" %d",p->key);
	
	if(p->right!=NULL)
		inorder(p->right);
	
	return;
}

void preorder(node *p){
	
	printf(" %d",p->key);
	
	if(p->left!=NULL)
		preorder(p->left);
	
	if(p->right!=NULL)
		preorder(p->right);
	
	return;
}

void print(node *root){
	inorder(root);
	printf("\n");
	
	preorder(root);
	printf("\n");
	
	return;
}

node * Delete(node *p,int x){
	
	if(p->key == x){
	
		if(p->left==NULL && p->right==NULL)/*葉*/
			return NULL;
		
		if(p->left==NULL || p->right==NULL){/*子1つ*/
			if(p->left!=NULL)
				return p->left;
			else
				return p->right;
		}
		
		node *q=p->right;
		while(q!=NULL)
			q=q->left;
		return q;
	
	}
	
	if(p->key > x)
		p->left=Delete(p->left,x);
	else
		p->right=Delete(p->right,x);
	
	return p;
	
}

int main(){
	int n,i,x;
	node *root=NULL;
	char com[10];
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%s",com);
		
		switch(com[0]){
			case 'i':scanf("%d",&x);
					 insert(&root,x);
					 break;
			
			case 'f':scanf("%d",&x);
					 if(find(root,x))
					 	printf("yes\n");
					 else
					 	printf("no\n");
					 break;
					 
			case 'd':scanf("%d",&x);
					 root=Delete(root,x);
					 break;
					 
			case 'p':print(root);
					 break;
		}
	}
	
	return 0;
	
}


Measured memory_bytes: 14200
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 10000;
    int tmp;
    string s, sub;
    cin >> s;
    REP(i, s.size()-2){
        sub = s.substr(i, 3);
        tmp = (sub[0] - '0') * 100 + (sub[1] - '0') * 10+ sub[2] - '0';
        ans = min(ans, abs(753 - tmp));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>



using namespace std;

long long  gcd(long long a, long long b) {
	if (a == 0) {
		return b;
	}

	return gcd(b%a, a);
}

int main() {
	
	
	long long  a, b;
	cin >> a >> b;
	vector<int> prime;
	

	if (a > b) {
		swap(a, b);
	}
	long long _gcd = gcd(a, b);
	
	

	
	long long num = _gcd;


	vector<pair<long long,int>> facto;
	for (long long i = 2; i*i <= _gcd; i++) {
		int cnt = 0;
		
		
		
		while (num %i == 0LL) {
			cnt++;
			num /= i;
		}

		if (cnt > 0) {
			facto.emplace_back(make_pair(i, cnt));
		}
		

		
		
	}
	if (num != 1) {
		facto.emplace_back(make_pair(num, 1));
	}

	
	cout << facto.size() +1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int min(int a, int b){
	return a<b ? a:b;
}

int main()
{
	int a, b, c, d;

	scanf("%d %d %d %d", &a, &b, &c, &d);

	printf("%d", min(a, b) + min(c, d));

	return 0;
}

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

int main()
{
    // input
    int n, k;
    cin >> n >> k;
    vector<int> vs(n);
    rep(i,n) cin >> vs[i];

    // solve
    ll ans = 0;
    rep(i,n){
        rep2(j,i,n+1){
            ll tmp = 0;
            if(n-(j-i) > k) continue;
            vector<int> temochi;
            rep(l,n){
                if(i <= l && l < j) continue;
                temochi.emplace_back(vs[l]);
            }
            sort(ALL(temochi));

            int rest = k - (n - (j - i));
            rep(l,rest){
                if(temochi.size() == 0) break;
                if(temochi[0] >= 0) break;
                temochi.erase(temochi.begin());
            }
            rep(l,temochi.size()) tmp += temochi[l];
            ans = max(ans, tmp);
        }
    }

    // output
    cout << ans << endl;

    return 0;
}

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

  #define vi vector<int>
  #define all(v) v.begin(),v.end()
  #define ll long long int
  #define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
  #define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

  const ll MOD=1e9+7;

  void solve(){
     int n;
     cin >> n;
     map<int,int> mp;
     vi v(n);
     for(int i=0;i<n;i++){
        cin >> v[i];
        mp[v[i]]++;
     }
     bool ok =true;
     int cnt=0;
     for(int i=0;i<n;i++){
       mp[v[i]]--;
       ok = true;
       for(int j=1;j*j<=v[i];j++){
         if((v[i]%j)==0){
            if((mp[j]>0) || (mp[v[i]/j]>0)){ok=false;break;}
         }
       }
       if(ok)cnt++;
       mp[v[i]]++;
     }
     cout << cnt;
  }


  int main(){
    IOS
       solve();
       cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 32960
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] s = scanner.next().toCharArray();
			int n = s.length;
			System.out.println(
					IntStream.range(1, n).filter(i -> s[i - 1] != s[i]).map(i -> Math.max(i, n - i)).min().orElse(n));
		}
	}
}


Measured memory_bytes: 39792
#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;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
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; }
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
//---------------------------------------------------------------------------------------------------

int main(void){
    // Your code here!
    int n; cin >> n;
    vi d1(n),d2(n);
    rep(i,n) cin >> d1[i] >> d2[i];
    string ans = "No";
    rep(i,n - 2) {
        if (d1[i] == d2[i] && d1[i+1] == d2[i+1]  && d1[i+ 2] == d2[i+2] ) ans = "Yes";
    }
    cout << ans << endl;
}


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

int n,m,ch,cw,dh,dw;
vector<string> a;
bool ok(int r,int c){
	if(r<0 || c<0 || r>=n || c>=m || a[r][c]=='#')
		return false;
	return true;
}
vector<int> dx = {-1,1,0,0};
vector<int> dy = {0,0,-1,1};
int d[1010][1010];
int main(){
	cin>> n>>m;
	cin>> ch >> cw;
	cin>> dh >> dw;
	int i,j,k,l;
	for(i=0;i<n;i++){
		string s;cin>>s;
		a.push_back(s);
	}
	--ch; --cw; --dh; --dw;
	for(i=0;i<n;i++)
		for(j=0;j<m;j++){
			d[i][j]=10000000;
		}

	d[ch][cw]=0;
	deque<pair<int,int>> q;
	q.push_front({ch,cw});
	while(!q.empty()){
		pair <int,int> p= q.front();
		q.pop_front();
		for(i=0;i<4;i++){
			int row = p.first + dx[i];
			int col = p.second + dy[i];
			if(!ok(row,col)){
				continue;
			}
			if(d[row][col]> d[p.first][p.second]){
				d[row][col] = d[p.first][p.second];
				q.push_front({row,col});
			}
			
		}

		for(i=p.first-2;i<=p.first+2;i++)
			for(j=p.second-2;j<=p.second+2;j++){
				if(!ok(i,j)){
					continue;
				}
				if(d[i][j]> d[p.first][p.second] + 1){
					d[i][j] = d[p.first][p.second] + 1;
					q.push_back({i,j});
				}
			}
				

	}
	if(d[dh][dw] == 10000000){
		cout<<"-1"<<"\n";
	}else{
		cout<<d[dh][dw]<<"\n";
	}
	//cout<< d[dh][dw]==10000000?"-1":d[dh][dw] <<"\n";

	return 0;
}

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

int main(){
  long long int n;
  cin>>n;
  
  string s="";
        
        while(n>0)
        {
            n=n-1;
            char c;
            int i='a'+(n%26);
            //cout<<i<<" ";
            if(i==122)
                c='z';
            else
                c=i;
            s+=c;
            n=n/26;
        }
        
        reverse(s.begin(),s.end());
  cout<<s;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define SORT(c) sort((c).begin(), (c).end())
#define RSORT(c) sort((c).rbegin(), (c).rend())
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const ll MOD = 1e+9 + 7;
// --------------------------------------------------------


const int MAX_N = 1e+5;
VVI dp(MAX_N, VI(3, 0));

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

    int N; cin >> N;
    VI a(N), b(N), c(N); REP(i,N) cin >> a[i] >> b[i] >> c[i];

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    FOR(i, 1, N) {
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + b[i];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
    }

    int ans = max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2]));
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 9792
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol a,b,c,d;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >>a>>b;
    cout <<a+b/2<<'\n';
    return 0;
}


Measured memory_bytes: 256
a,b,c=map(int,input().split())
ans=0
if a%2==0 and b%2==0 and c%2==0 and a==b and b==c:
    print(-1)
else:
    while True:
        if a%2==0 and b%2==0 and c%2==0:
            ans+=1
            a_tmp=int(a/2)
            b_tmp=int(b/2)
            c_tmp=int(c/2)
            a=b_tmp+c_tmp
            b=a_tmp+c_tmp
            c=b_tmp+b_tmp
        else:
            break
    print(ans)

Measured memory_bytes: 9180