akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

bool flags[60000];
void Sieve() {
  flags[0] = true;
  flags[1] = true;
  const int sqrt_x = ceil(sqrt(60000) + 0.1);
  FOR(p,2,sqrt_x){
    if (flags[p])continue;
    for (int mult = p * p; mult < 60000; mult += p)
      flags[mult] = true;
  }
}
int main(){
  ll n;cin>>n;
  Sieve();
  vector<ll> ans(n);
  ll cnt=0;
  for (int i=31;i<=55555;i+=30){
    if(!flags[i]){
      ans[cnt]=i;
      cnt++;
      if(cnt==n){
        break;
      }
    }
  }
  rep(i,n){
    cout<<ans[i]<<" ";
  }
  cout<<endl;
  return 0;
}

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

typedef long long ll;

int main(){
    string s;
    ll k;

    cin >> s >> k;

    if(k < 100){
        bool judge = true;
        for(int i = 0; i < k; i++)  if(s[i] != '1') judge = false;
        if(judge){
            cout << 1 << endl;
        }else{
            int i;
            for(i = 0; i < s.length(); i++) if(s[i] != '1') break;
            cout << s[i] << endl;
        }
    }else{
        int i;
        for(i = 0; i < s.length(); i++) if(s[i] != '1') break;
        cout << s[i] << endl;
    }
    
    return 0;
}

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

int main(){
    ll h, n; cin >> h >> n;
    vector<ll> a(n); rep(i, 0, n) cin >> a[i];

    ll sum = accumulate(a.begin(), a.end(), 0);
    
    if(sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 1024
/*
 
श्रीगुरु चरन सरोज रज
निजमनु मुकुरु सुधारि
बरनउँ रघुबर बिमल जसु
जो दायकु फल चारि
बुद्धिहीन तनु जानिके, सुमिरौं पवन-कुमार
बल बुधि बिद्या देहु मोहिं, हरहु कलेस बिकार 
 
*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD (ll)1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin >> s;
    int n = s.size();
    ll dp[n][2];
    memset(dp, -1, sizeof(dp));
    for (ll i = 0; i < n; i++)
    {
        if (i == 0)
        {
            dp[i][0] = 1;
        }
        else
        {
            if (s[i] != s[i - 1])
            {
                dp[i][0] = max(1 + dp[i - 1][0], dp[i][0]);
                dp[i][0] = max(1 + dp[i - 1][1], dp[i][0]);
            }
            else
            {
                dp[i][0] = max(1 + dp[i - 1][1], dp[i][0]);
            }
            if (i >= 3 && s[i] == s[i - 2] && s[i - 1] == s[i - 3])
            {
                dp[i][1] = max(1 + dp[i - 2][1], dp[i][1]);
                dp[i][1] = max(1 + dp[i - 2][0], dp[i][1]);
            }
            else if (i >= 2)
            {
                dp[i][1] = max(1 + dp[i - 2][0], dp[i][1]);
            }
            else
            {
                dp[i][1] = 1;
            }
        }
    }
    cout << max(0ll, max(dp[n - 1][0], dp[n - 1][1]));
}

Measured memory_bytes: 3732
read n m;
a=(`dd`);
for((i=0;i<n;i++))do
	k=0;
	s=1000000000;
	x=${a[$[i*2]]};
	y=${a[$[i*2+1]]};
	for((j=n;j<n+m;j++))do
		z=${a[$[j*2]]};
		w=${a[$[j*2+1]]};
		t=$[(x>z?x-z:z-x)+(y>w?y-w:w-y)];
		if [ $t -lt $s ];then
			s=$t;
			k=$[j-n+1];
		fi
	done
	echo $k
done


Measured memory_bytes: 552
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

l,r,d = inm()
sm = 0
for i in range(l,r+1):
    if i%d==0:
        sm += 1
print(sm)


Measured memory_bytes: 61800
a,b,c,x,y = map(int,input().split())
if x<y:
    a,b,x,y=b,a,y,x

if a+b<2*c:
    ans=a*x+b*y
else:
    if a>2*c:
        ans = c*2*x
    else:
        ans = c*2*y + a*(x-y)
print(ans)


Measured memory_bytes: 9108
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    int a, b;
    
    b = 0;
    
    cin >> a;
    
    for(int i = 0; i < 3; i++){
        if(a % 10 == 9){
            b += pow(10, i);
        }
        if(a % 10 == 1){
            b += 9 * pow(10, i);
        }
        a /= 10;
    }
    
    cout << b << endl;
    
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    string S;cin >> S;
    int K;cin >> K;
    vector<string> V;
    if(S.size() < K){
        REP(i,S.size()){
            REPP(j,i+1,S.size()+1){
                auto A = S.substr(i,j-i);
                V.pb((string)A);
            }
        }
        sort ALL(V);V.erase(unique(V.begin(), V.end()), V.end());
        cout << V[K-1] << endl;
    }
    else{
        REP(i,S.size()-K+1){
            auto A = S.substr(i,K);
            V.pb(A);
        }
        sort ALL(V);V.erase(unique(V.begin(), V.end()), V.end());
        string T = V[0];
        REP(i,T.size()){
            REPP(j,i+1,T.size()+1){
                auto A = T.substr(i,j-i);
                V.pb((string)A);
            }
        }
        REPP(i,S.size()-K+1,S.size()){
            REPP(j,i+1,S.size()+1){
                auto A = S.substr(i,j-i);
                V.pb((string)A);
            }
        }
        sort ALL(V);V.erase(unique(V.begin(), V.end()), V.end());
        cout << V[K-1] << endl;
    }
}

Measured memory_bytes: 512
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define MAXI (1<<32)
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define SIZ 1000005
#define SIZE 200005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair<ll,ll>&a,const pair<ll,ll>&b){
	return a.ss < b.ss;
}

//ll p[20000005]={0};
//vector<ll>ans;
/*void sieve(){
    ll i,j;
    p[0]=p[1]=1;
    for(i=2;i*i<=20000005;i++){
        if(!p[i]){
            for(j=2*i;j<20000005;j+=i){
                p[j]=1;
            }
        }
    }
    fo(i,2,20000005){
        if(!p[i]){
            ans.pb(i);
        }
    }
}*/


signed main(){ 
    IOS
    //io_set();
    ll x, y, c = 0;
    cin >> x >> y;
    while(x <= y){
        c++;
        x *= 2;
    }
    cout << c << endl;
    return 0;
}



Measured memory_bytes: 256
n, K = gets.chomp.split.map(&:to_i)
h_n = gets.chomp.split.map(&:to_i)

results = []
n.times do |_|
  results << Float::INFINITY
end

results[0] = 0

h_n.each.with_index(0) do |h_i, i|
  next if i == h_n.length - 1

  1.upto(K) do |k|
    next if h_n[i+k].nil?
    next if results[i+k].nil?

    cost_to_next_k = results[i] + (h_n[i+k] - h_i).abs
    results[i+k] = cost_to_next_k if results[i+k] > cost_to_next_k
  end
end

puts results[-1]

Measured memory_bytes: 21776
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=10000000007;

int main(){
  int n;cin>>n;
  map<string,int> mp;
  int m=0;
  rep(i,n){
    string s;
    cin>>s;
    mp[s]++;
    m=max(m,mp[s]);
  }
  
  for(auto p:mp){
    if(p.se==m) cout<<p.fi<<endl;
  }
}


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

int main() {
	ios_base::sync_with_stdio( false );

	int64_t N, K, Q;
	cin >> N >> K >> Q;

	vector<int64_t> ans( N );
	for( int64_t i = 0; i < Q; ++i ) {
		int64_t A;
		cin >> A;

		ans[A-1] += 1;
	}

	for( int64_t i = 0; i < N; ++i ) {
		cout << (K-Q+ans[i] > 0 ? "Yes" : "No") << '\n';
	}
}


Measured memory_bytes: 1536
#include<iostream>
using namespace std;
int bubbleSort(int p[],int n)
{
    int flag=1;
    int count=0;
    for(int i=0;i<n-1;i++){
        if(!flag)break;
        flag=0;
        for(int j=n-1;j>i;j--)
           if(p[j]<p[j-1]){
               flag=1;
               int t=p[j];
               p[j]=p[j-1];
               p[j-1]=t;
               count++;
           }
    }
    return count;
}
int main(){
    int n;
    cin>>n;
    int *p=new int[n];
    for(int i=0;i<n;i++) cin>>p[i];
    
    int m=bubbleSort(p,n);
    for(int i=0;i<n-1;i++) 
        cout<<p[i]<<' ';
    cout<<p[n-1]<<endl;
    cout<<m<<endl;
    
    
}


Measured memory_bytes: 3100
#include<iostream>
using namespace std;
int main()
{
	
	int n;
	bool card[52];  //S 0~12 : H 13~25 : C 26~38 : D 39~51
	for(int i=0;i<52;++i){
		card[i]=true;
	}
	cin >> n;
	for(int i=0;i<n;++i){
		int x;
		char a;
		cin >> a >> x;
		switch(a){
		case 'S':
			card[x-1]=false;
			break;
		case 'H':
			card[x+12]=false;
			break;
		case 'C':
			card[x+25]=false;
			break;
		case 'D':
			card[x+38]=false;
			break;
		}
	}
	for(int i=0;i<52;++i){
		if(card[i]==true){
			switch(i/13){
			case 0:
				cout << "S " << i+1 << endl;
				break;
			case 1:
				cout << "H " << i-12 << endl;
				break;
			case 2:
				cout << "C " << i-25 << endl;
				break;
			case 3:
				cout << "D " << i-38 << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
//#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

ll powmod(ll x, ll n, ll m = MOD) {
    ll ans = 1;
    while(n) {
        if(n & 1) {
            ans = ans * x % m;
        }
        x = x * x % m;
        n >>= 1;
    }
    return ans;
}
inline ll invmod(ll x, ll m = MOD) {
    return powmod(x, m - 2);
}

const int N = 222222;
vector<int> tree[N];
int s[N], ways[N];
int n, nf;

void dfs(int u = 1, int p = 0) {
    s[u] = 1;
    rall(v, tree[u]) {
        if(v != p) {
            dfs(v, u);
            s[u] += s[v];
        }
    }
}

void dfs2(int u = 1, int p = 0) {
    if(p) {
        int w = ways[p];
        w = w * s[p] % MOD * s[u] % MOD;
        s[p] -= s[u];
        s[u] += s[p];
        w = w * invmod(s[p]) % MOD * invmod(s[u]) % MOD;
        ways[u] = w;
    }
    rall(v, tree[u]) {
        if(v != p) {
            dfs2(v, u);
        }
    }
    if(p) {
        s[u] -= s[p];
        s[p] += s[u];
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    rep(i, 1, n - 1) {
        int u, v;
        cin >> u >> v;
        tree[u].pb(v);
        tree[v].pb(u);
    }
    dfs();
    ways[1] = 1;
    rep(u, 1, n) {
        ways[1] = ways[1] * u % MOD * invmod(s[u]) % MOD;
    }
    dfs2();
    rep(u, 1, n) {
        cout << ways[u] << endl;
    }
}


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

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

    long long x, y, cnt = 0;
    cin >> x >> y;
    while(x <= y){
        x *= 2;
        cnt++;
    }
    cout << cnt << endl;

    return 0;
}

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

int main() {

	int n, k;
	std::cin >> n >> k;

	std::vector<int> v;
	v.resize(k);
	for (auto&e : v)
		std::cin >> e;


	const auto beg = std::begin(v);
	const auto en = std::end(v);
	auto exist = [&](auto v) {
		return en != std::find(beg, en, v);
	};



	while (true) {
		if (   ( 10000<=n ? exist(n / 10000):false)
			||	(1000<=n ? exist(n % 10000/1000):false)		//X***
			||  ( 100<=n ? exist(n % 1000 / 100):false ) //*X**
			||  (  10<=n ? exist(n % 100 / 10):false )	//**X*
			||  exist(n % 10)						//***X
			)
			++n;
		else
			break;
	}

	std::cout << n << "\n";
	return 0;
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    ll n, k;
    cin >> n >> k;
    vll a(n), f(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];
    
    sort(all(a));
    sort(all(f), greater<ll>());

    ll left=0, right=1000000000000;
    while(left<right){
        ll mid = (left+right)/2;
        ll count = 0;
        bool possible = true;
        rep(i, n){
            if(a[i]*f[i]>mid){
                count += a[i] - mid/f[i];
            }
            if(count>k){
                possible = false;
                break;
            }
        }
        if(possible) right = mid;
        else left = mid + 1;
    }
    cout << left << endl;
}


Measured memory_bytes: 3328
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigInteger n = sc.nextBigInteger();
        BigInteger ans = n.remainder(new BigInteger("9"));
        if(ans.equals(BigInteger.ZERO)) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 42432
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;

int main(){
  int N, X;
  cin >> N >> X;
  vector<long long> a(N);
  long long ans = 0;
  
  REP(i,N){
    cin >> a[i];
    if( i == 0 ){
      if( a[i] > X ){
	ans += a[i] - X;;
	a[i] = X;
      }
    }else{
      if( a[i-1] + a[i] > X ){
	long long t = a[i-1] + a[i] - X;
	ans += t;
	a[i] = max( 0ll, a[i] - t );
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.Arrays;
 
public class Main {
	public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);

      int N = sc.nextInt();
      int AC=0,WA=0,TLE=0,RE=0;
      for(int i=1;i<N+2;i++){
      	String S = sc.nextLine();
        if(S.equals("AC")){
        	AC++;
          	continue;
        }else if(S.equals("WA")){
        	WA++;
          continue;
        }else if(S.equals("TLE")){
        	TLE++;
          continue;
        }else if(S.equals("RE")){
        	RE++;
          continue;
        }
      }
      System.out.println("AC x "+AC);
      System.out.println("WA x "+WA);
      System.out.println("TLE x "+TLE);
      System.out.println("RE x "+RE);
    }
}

Measured memory_bytes: 50280
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin>>n;
  	vector<int>vec(0);
  	int y;
  	//x is original value
  	for(int x=1;x<=n;x++){
      	y=1.08*x;
    	if(n==y){
        vec.push_back(x);
        }
      	
    }
  	if(vec.size()==0){
    	cout<<":("<<endl;
    }
  	else{
    	cout<<vec.at(0)<<endl;
    	
    }

}

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

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    int ans = 1, x;
    cin >> x;
    while(ans * (ans+1)/2 < x) ans++;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
// Hope is a good thing maybe the best of things and no good thing ever dies

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define pii pair <int, int>
#define pll pair <long long, long long >
#define PI 2 * acos(0.0)
#define testcase ll T; cin >> T; for (int tc = 1; tc <= T; tc++)
const long long M = 2e5 + 10, M2 = 1e6 + 10, oo = 998244353;
ll ara[M], cnt[M2], dsum[M2], inv[M2];
ll inverse (ll m) {
    inv[1] = 1;
    for (ll j = 2; j <= m; j++) {
        inv[j] = (oo - (inv[oo % j] * (oo / j)) % oo) % oo;
    }
}
vector < ll > dvs[M2];

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, sm = 0;
    cin >> n;
    ll mxnum = 0;
    for (ll i = 0; i < n; i++) {
        cin >> ara[i];
        mxnum = max(mxnum, ara[i]);
        sm = (sm + ara[i]) % oo;
        cnt[ara[i]]++;
    }
    inverse(mxnum);
    for (ll i = 1; i <= mxnum + 2; i++) {
        for (ll j = i; j <= mxnum + 2; j += i) {
            if (cnt[j]) {
                //cout << i << " " << j << endl;
                dsum[i] = (dsum[i] + cnt[j] * j) % oo;

            }
            dvs[j].pb(i);
        }
    }
    for (ll i = 0; i <= mxnum; i++) dsum[i] = (dsum[i] * dsum[i]) % oo;
    ll ans = 0;
    for (ll i = mxnum; i >= 1; i--) {
        //cout << i << " " << dsum[i] << endl;
        ans = (ans + dsum[i] * inv[i]) % oo;
        //cout << ans << endl;
        for (auto j : dvs[i]) {
            dsum[j] = (dsum[j] + oo - dsum[i]) % oo;
        }
    }
    //cout << ans << endl;
    ans = ((ans + oo - sm) * inv[2]) % oo;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 205824
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
const ll m = 1e9 + 7;
const int MAX = 1e3 + 5;
ll F[MAX];

ll mul(ll a, ll b, ll m) {
    return (ll)((__uint128_t)a * b % m);
}
ll add(ll a, ll b) {
    a += b;
    if (a >= m) a -= m;
    return a;
}

void pre() {
    F[0] = F[1] = 1;
    for (int i = 2; i < MAX; i++) {
        F[i] = mul(F[i - 1], i, m);
    }
}

ll cntdiv(ll N) {
    ll cnt = 0;
    for (int i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            if (i * i == N)
                cnt++;
            else
                cnt += 2;
        }
    }
    return cnt;
}
void fact(int n, map<ll, ll> &f) {
    for (int i = 2; i <= n; i++) {
        while (n % i == 0) f[i]++, n /= i;
    }
    if (n > 1) f[n]++;
}
int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif

    int n;
    cin >> n;
    map<ll, ll> F;
    for (int i = 1; i <= n; i++) {
        fact(i, F);
    }
    ll ans = 1;
    for (ll i = 2; i <= n; i++) {
        ans = mul(ans, F[i] + 1, m);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>
#include <random>
#include <vector>
#include <unordered_map>
#include <bitset>

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

LL mod = 1000000007;

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

  string s;
  cin >> s;

  LL cnt = 0;

  REP(i,s.size()){
    if((s[i]=='0')^(i%2==0)){
      cnt++;
    }
  }

  cout << min(cnt, (int)s.size() - cnt) << endl;
}


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

using namespace std;

template<typename T>
int longestIncreasingSubsequence(const std::vector<T> &a) {
    if (a.empty()) return {};

    const T INF = std::numeric_limits<T>::max();
    const int size = a.size();

    std::vector<T> dp(size, INF);
    std::vector<int> idx(size);
    for (int i = 0; i < size; ++i) {
        // 単調増加： a_i <= a_j
        idx[i] = std::distance(dp.begin(), upper_bound(dp.begin(), dp.end(), a[i]));
        dp[idx[i]] = a[i];
    }

    return *max_element(idx.begin(), idx.end()) + 1;
}

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

    int n;
    cin >> n;

    vector<int> a(n);
    for (auto &a_i : a) cin >> a_i, a_i *= -1;

    cout << longestIncreasingSubsequence<int>(a) << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <iomanip>
typedef long long ll;

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    
    if(a < 10 && b < 10) {
        cout << a * b << endl;
    }
    else {
        cout << -1 << endl;
    }
    
    return 0;
}


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


signed main() {
    int k, s;
    cin >> k >> s;

    int res = 0;
    rep(x, k+1) {
        rep(y, k+1) {
            int z = s - (x+y);
            if(z>=0 && z<=k) res++;
        }
    }
    
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mn=1e6+10;
const ll mod=1e9+7;

int main(){
    int n,x;
    scanf("%d%d",&n,&x);
    int ans=1,sum=0;
    for(int i=0;i<n;i++){
        int a;
        scanf("%d",&a);
        sum+=a;
        if(sum<=x)ans++;
    }
    printf("%d",ans);
}


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

using namespace std;

int main() {
    long long x;
    cin>>x;
    
    long long temp=x%1000;
  if(temp==0)
  {cout<<0<<endl;
   exit(0);
  }
   
        cout<<(1000-temp)<<endl;
    
}


Measured memory_bytes: 3616
def make_list(X) :
    if X != -1 :
        x_list = [X]
    else :
        x_list = [i for i in range(1, 10)]
    return x_list

A, B, C, D, E, F, G, H, I = map(int, input().split())
a_list = make_list(A)
b_list = make_list(B)
c_list = make_list(C)
d_list = make_list(D)
e_list = make_list(E)
f_list = make_list(F)
g_list = make_list(G)
h_list = make_list(H)
i_list = make_list(I)

cnt = 0
for a in a_list :
    for b in b_list :
        if b not in [a]:
            for c in c_list :
                if c not in [a, b] :
                    for d in d_list :
                        if d not in [a, b, c] :
                            for e in e_list :
                                if e not in [a, b, c, d] :
                                    for f in f_list :
                                        if f not in [a, b, c, d, e] :
                                            for g in g_list :
                                                if g not in [a, b, c, d, e, f] :
                                                    for h in h_list :
                                                        if h not in [a, b, c, d, e, f, g] :
                                                            for i in i_list :
                                                                if i not in [a, b, c, d, e, f, g, h] :
                                                                    if a+10*b+c+100*d+10*e+f == 100*g+10*h+i :
                                                                        cnt += 1
print(cnt)


Measured memory_bytes: 5620
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,a,n) for(int i=n;i>=a;--i)
#define pb push_back
#define fi first
#define se second
#define io std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
const int maxn=1e5+50;
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}
ll qpow(ll a,ll n)
{
    ll r=1%P;
    for (a%=P; n; a=a*a%P,n>>=1)if(n&1)r=r*a%P;
    return r;
}

 int main()
 {
   int n,k;
   cin>>n>>k;
   ll ans=n/k;
   ans=ans*ans*ans;
   if(k%2==0)
   {
       n-=k/2;
       if(n>=0)
       {
       ll  x=n/k+1;
       ans+=x*x*x;
     }
   }
   cout<<ans<<endl;
 }


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

const int maxn=1e5+10;

typedef struct job
{
    int day;
    int pay;
}job;

bool cmp(job a,job b)
{
    return a.pay>b.pay;
}

int N,M;
job p[maxn];

int main()
{
    scanf("%d%d",&N,&M);
    for(int i=0;i<N;i++)
    {
        scanf("%d%d",&p[i].day,&p[i].pay);
    }
    sort(p,p+N,cmp);
    set<int> s;
    for(int i=1;i<=M;i++)
        s.insert(i);
    int sum=0;
    for(int i=0;i<N;i++)
    {
        if(s.lower_bound(p[i].day)!=s.end())
        {
            sum+=p[i].pay;
            s.erase(*s.lower_bound(p[i].day));
        }
    }
    cout<<sum<<endl;

}



Measured memory_bytes: 5760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		long n = Long.parseLong(input.readLine( ));
		long a = 1;
		long b = 1;
		long answer = String.valueOf(n).length();

		while(a < Math.sqrt(n)+1){
			if(n%a == 0){
				b = n / a;
				if(answer > String.valueOf(b).length() && String.valueOf(b).length() >= String.valueOf(a).length()){
					answer = String.valueOf(b).length();
				}
			}
			a++;
		}
		System.out.println(answer);
	}
}


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

typedef long long ll;
typedef unsigned long long ull;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
const double PI=3.14159265358979323846;

using namespace std;

int n, m;
int q;
int ans = 0;
vector<int> a(10), b(10), c(10), d(10);

// i は 1から
void dfs(int i, int r, int *x) {

	if (r == n) {
		int sum = 0;
		rep (k, q) {

			if (x[b[k] - 1] - x[a[k] - 1] == c[k]) {
				sum += d[k];
			}
		}
		ans = max(ans, sum);
		return;
	}
	if (i == m + 1)
		return;

	x[r] = i;
	dfs(i, r + 1, x);
	dfs(i + 1, r, x);
	
	return;
}

int main() {

	cin >> n >> m >> q;
	a.resize(q);
	b.resize(q);
	c.resize(q);
	d.resize(q);

	rep(i, q) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}

	int x[10];
	ans = 0;
	dfs(1, 0, x);

	cout << ans << endl;
}


Measured memory_bytes: 3588
import java.util.*;
public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long K = sc.nextLong();
        Map<Integer, Integer> mp = new HashMap<>();
        for(int i=0;i<N;i++){
            int A = sc.nextInt()-1;
            mp.put(i, A);
        }
        Set<Integer> visited = new HashSet<>();
        int now=0;
        List<Integer> arr = new ArrayList<>();
        while(true){
            if(visited.contains(now)){
                break;
            }
            visited.add(now);
            arr.add(now);
            now = mp.get(now);
        }
//        System.out.println(arr);
//        System.out.println(arr.indexOf(now));
        int remain = arr.indexOf(now);
        int ans=0;
        if(K < remain){
            ans = arr.get((int)K);
        }else{
            long res = ((K-(long)remain) % (long)(arr.size()-remain)) + (long)remain;
            ans = arr.get((int)res);
        }
        System.out.println(ans+1);
    }

}


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

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

	vector < long long > a;

	while ( n ) {
		a.push_back(1);
		n /= 2;
	}
	int sz = a.size();

	for ( int i = sz - 2; i >= 0; i-- ) {
		a[i + 1] *= 2;
		a[i] += a[i + 1];
	}
	cout << a[0];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace std;
typedef long long ll;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

void solve() {
    int N;
    cin >> N;
    int ans=0;
    rep(i, N){
        int a;
        cin >> a;
        if(i%2==0 && a%2==1) ans++;
    }
    out(ans);
}
int main() {
    INCANT;
    solve();
    return 0;
}




Measured memory_bytes: 3648
n = int(input())
l = list(map(int, input().split()))
d = set()
over = 0
for i in l:
    if i <= 399:
        d.add("gray")
    elif i <= 799:
        d.add("brown")
    elif i <= 1199:
        d.add("green")
    elif i <= 1599:
        d.add("light blue")
    elif i <= 1999:
        d.add("blue")
    elif i <= 2399:
        d.add("yellow")
    elif i <= 2799:
        d.add("orange")
    elif i <= 3199:
        d.add("red")
    else:
        over += 1

min_color = len(d)
if len(d) == 0:
    min_color +=1
max_color = len(d) + over

print(min_color, max_color)


Measured memory_bytes: 9148
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    b=[False]*N
    c=[0]*N
    ans=0
    ans2=0
    for i in range(M):
        p,S=input().split()
        p=int(p)-1
        if S=='WA' and b[p]==False:
            c[p]+=1
        elif S=='AC' and b[p]==False:
            b[p]=True
            ans+=c[p]
            ans2+=1
    print(ans2,ans)
        
if __name__ == '__main__':
    main()


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

int main(){
    ll n;
    cin >> n;
    vector<ll> x(n),y(n),d;
    ll pality[n];
    rep(i,n){
        cin >> x[i] >> y[i];
        pality[i]=abs(x[i])+abs(y[i]);
    }
    rep(i,n-1){
        if(pality[i]%2!=pality[i+1]%2){
            cout << "-1" << endl;
            return 0;
        }
    }
    rep(i,31){
        d.push_back(1 << i);
    }
    if(pality[0]%2==0)d.push_back(1);
    sort(d.begin(),d.end(),greater<ll>());
    cout << d.size() << endl;
    rep(i,d.size()) cout << d[i] << " ";
    cout << endl;
    rep(i,n){
        rep(j,d.size()){
            if(abs(x[i])>abs(y[i])){
                if(x[i]>0){
                    x[i]-=d[j];
                    cout << "R";
                }else{
                    x[i]+=d[j];
                    cout << "L";
                }
            }else{
                if(y[i]>0){
                    y[i]-=d[j];
                    cout << "U";
                }else{
                    y[i]+=d[j];
                    cout << "D";
                }
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 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 I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, K = LI()
    V = LI()
    in_deq = deque()
    ans = 0
    for v in V:
        in_deq.append(v)
    for toru in range(K+1):
        for left_toru in range(toru+1):
            deq = copy.copy(in_deq)
            modosu = K - toru
            temochi = []
            right_toru = toru - left_toru
            # print('left_toru: {}, right_toru: {}, modosu: {}'.format(left_toru, right_toru, modosu))
            while len(deq) and left_toru > 0:
                x = deq.popleft()
                temochi.append(x)
                left_toru -= 1
            while len(deq) and right_toru > 0:
                x = deq.pop()
                temochi.append(x)
                right_toru -= 1
            temochi = sorted(temochi)[::-1]
            while len(temochi) > 0 and modosu > 0:
                extra = temochi[-1]
                if extra > 0:
                    break
                temochi = temochi[:-1]
                modosu -= 1
            ans = max(ans, sum(temochi))
    print(ans)
main()



Measured memory_bytes: 71256
N = int(input())
X = list(map(int, input().split()))

ave = sum(X) / float(N)
my_round_int = lambda x: int((x * 2 + 1) // 2)
t = my_round_int(ave)
val = 0
for x in X:
  val += (t - x)**2
print(val)


Measured memory_bytes: 61956
/*
      d888888b                         d888888b
   d888    8888b                    d888888   888b
 d88    88  898888b               d8888  888     88b
d8P        88888888b             d88888888888     b8b
88        8888888888             88888888888       88
88       88888888888             8888888888        88
98b     88888888888P             988888888        d8P
 988     888  8888P      _=_      9888898  88    88P
   9888   888888P      q(-_-)p       98888    888P
      9888888P         '_) (_`         9888888P
         88            /__/  \            88
         88          _(<_   / )_          88
        d88b        (__\_\_|_/__)        d88b
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                          
                     saint_coder

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
*/

#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define pb push_back 
#define mp make_pair
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORD(i,a,b) for(int i=(a);i>(b);i--)
#define inp(x) cin>>x
#define print(x) cout<<x<<" "
#define printl(x) cout<<x<<endl
#define WL(t) while(t --)
#define F first
#define S second
#define PQ(type) priority_queue<type>
#define PQD(type) priority_queue<type,vector<type>,greater<type> >
#define SZ(x) ((int)(x).size())
#define inrange(i,a,b) ( ( i>=min(a,b) ) && ( i<=max(a,b) ) )


typedef long long ll;
typedef map<int,int> mii;
typedef vector<int> vi;
typedef pair<int,int> pii;

int32_t main(){

	/*int testcases;
	cin>>testcases;

	WL(testcases){
		
		int n;
		cin>>n;

		int a[n];
		FOR(i,n)
			cin>>a[i];		
	}*/	

	int a,b,c,d;
	
	inp(a);
	inp(b);
	inp(c);
	inp(d);
	
	int s= a/c;
	int e = b/c; 
	
	if(a % c !=0)
		s++;
		
	int factc=0;
	if(s<=e){
		factc = e-s+1;
	}
	
	s= a/d;
	e = b/d; 
	
	if(a % d !=0)
		s++;
		
	int factd=0;
	
	if(s<=e){
		
		factd = e-s+1;
	
	}
	
	int both = c * d / __gcd(c,d);
	
	s= a/both;
	e = b/both; 
	
	if(a % both !=0)
		s++;
		
	int factboth=0;
	
	if(s<=e){
		
		factboth = e-s+1;
	
	}
	
	
	print(b- a + 1 - factc - factd + factboth);
	return 0;	
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
bool chmax(T &a, const T &b) {if (a < b){ a = b; return 1;} return 0;}
template <class T>
bool chmin(T &a, const T &b) {if (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

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

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

int main()
{
    int K, X;
    cin >> K >> X;

    int l = max(-100000, X-(K-1));
    int r = min( 100000, X+(K-1));

    for (int i = l; i<=r; i++){
        cout << i ;
        if (i != r) cout << " ";
    }

    return 0;
}


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

int main() {
    int n, a, b;
    int train;

    cin >> n >> a >> b;
    train = n * a;
    if( train > b) {
      cout << b << endl;
    }else {
      cout << train << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
ll n;
cin>>n;
ll i=1;
ll ans=0;
if(n==1){
    cout<<0<<endl;
    return 0;
}
while(1){
    if(i*i>n)break;
    if((n-i)%i==0&&n%((n-i)/i)==i)ans+=(n-i)/i;
    i++;
}
cout<<ans<<endl;
}


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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define ALL(a) a.begin(), a.end()
#define FOR(x,to) for(x=0;x<(to);x++)

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

void solve() {	
	int N;
	int a[100];
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	sort(a,a+N);
	reverse(a,a+N);

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		if (i%2==0) {
			ans += a[i];
		} else {
			ans -= a[i];
		}
	}

	cout << ans << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

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

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

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

#define mp make_pair
#define pb push_back

using namespace std;

char s[222222];
int nxt[222222][26];
int f[222222];
int n;

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%s",&s);
	n = strlen(s);
	for(int i = 0; i < 26; ++i) nxt[n][i] = n;
	for(int i = n - 1; i >= 0; --i){
		for(int j = 0; j < 26; ++j) nxt[i][j] = nxt[i + 1][j];
		nxt[i][s[i] - 'a'] = i;
	}
	f[n] = n + 1;
	for(int i = n - 1; i >= 0; --i){
		f[i] = n + 1;
		for(int j = 0; j < 26; ++j)
			f[i] = min(f[i], f[nxt[i][j] + 1] + 1);
	}
	int c = 0;
	while (1){
		if (f[c] == 0) break;
		for(int j = 0; j < 26; ++j)
			if (f[c] == f[nxt[c][j] + 1] + 1){
				printf("%c",char(j + 'a'));
				c = nxt[c][j] + 1;
				break;
			}
	}
	return 0;
}

Measured memory_bytes: 22912
#include<deque>
#include<queue>
#include<map>
#include<string>
#include<iostream>
#include<set>
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
//#define scanf scanf_s
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pub push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<30);
const llint mod=1000000007;


int main(void){
	int N,M,Q,i,j,a,b,c;
	pair<int,int> P;
	vector<tuple<int,int,int>>query;
	vector<int> col;
	vector<int> sai;
	vector<vector<int>> edge;
	queue<pair<int,int>> que;//頂点,残り強さ
	scanf("%d %d",&N,&M);
	col.resize(N+1);
	sai.resize(N+1);
	edge.resize(N+1);
	for(i=0;i<M;i++){
		scanf("%d %d",&a,&b);
		edge[a].pub(b);
		edge[b].pub(a);
	}
	scanf("%d",&Q);
	for(i=0;i<Q;i++){
		scanf("%d %d %d",&a,&b,&c);
		query.pub(mt(a,b,c));
	}
	for(i=Q-1;i>=0;i--){
		a=get<0>(query[i]);b=get<1>(query[i]);c=get<2>(query[i]);
		que.push(mp(a,b));
		while(!que.empty()){
			P=que.front();
			que.pop();
			a=P.first;
			b=P.second;
			if(col[a]==0){col[a]=c;}
			if(sai[a]>=b){ continue; }
			sai[a]=b;
			b--;
			if(b<0){continue;}
			for(j=0;j<edge[a].size();j++){
				que.push(mp(edge[a][j],b));
			}
		}
	}
	for(i=1;i<=N;i++){
		printf("%d\n",col[i]);
	}
	return 0;
}



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

using namespace std;

//begin: 20:07
//end: 

typedef int64_t ll;
#define For(i, a, b) for(ll i = a; i <= b; i++)

ll n, cnt[20][20], ans;

int fir(ll i)
{
    ll tmp;
    while (i != 0)
    {
        tmp = i;
        i /= 10;
    }
    return tmp;
}

int las(ll i)
{
    return i % 10;
}

void process()
{
    For(i, 1, n)
    cnt[fir(i)][las(i)]++;
    For(i, 1, 9)
    For(j, 1, 9)
    ans += cnt[fir(i)][las(j)]*cnt[las(j)][fir(i)];
    cout << ans << "\n";
}

void input()
{
    cin >> n;
}

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
  //  freopen("test.in", "r", stdin);
    //freopen("test.ok", "w", stdout);
    input();
    process();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod = 998244353;
ll fp(ll a,ll k){
	ll ans=1;
	for(;k;k>>=1,a=a*a%mod)
		if(k&1) ans=a*ans%mod;
	return ans;
}
int n,m;
ll fac[1001000],ifac[1001000];
ll C(int n,int m){return fac[n]*ifac[m]%mod*ifac[n-m]%mod;}
int main(){
	cin>>n>>m;
	fac[0]=1;
	for(int i=1;i<=1000000;i++) fac[i]=fac[i-1]*i%mod;
	ifac[1000000]=fp(fac[1000000],mod-2);
	for(int i=1000000;i;i--) ifac[i-1]=ifac[i]*i%mod;
	ll ans=0;
	for(int i=0;i<=min(n,m);i++)
		ans=(ans+(i&1?-1:1)*C(n,i)*C(m,i)%mod*fac[i]%mod*fp(n+1,m-i)%mod*fp(m+1,n-i))%mod;
	cout<<(ans+mod)%mod<<'\n';
	return 0;
}


Measured memory_bytes: 15872
def factorize(n):
    i=2
    result={}
    while True:
        if i**2>n:
            break
        count=0
        while n%i==0:
            n//=i
            count+= 1
        if count!=0:
            result[i]=count
        i+=1
    if n>1:
        result[n]=1
    return result

def count(v):
    cnt=0
    num=1
    while cnt<=v:
        cnt+=num
        num+=1
        #print(cnt,num)
    return num-2

def main():
    n=int(input())
    F=factorize(n)
    #print(F)
    ans=0
    for val in F.values():
        #print(val,count(val))
        ans+=count(val)
    print(ans)
    
if __name__=='__main__':
    main()

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

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;

//階乗
int factorial(int k){
    int result=1;
    for (int i=1;i<=k;++i){
        result*=i;
    }
    return result;
}

int main() {
    int n,cnt=0;
    cin>>n;

    rep(i,n){
        int a;
        cin>>a;

        while(a%2==0){
            a/=2;
            cnt++;
        }
    }

    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
    int main(){
    	int A;
        int B;
        int c;
        int d;
        int e;
        int X;
    	scanf("%d",&X);
    	scanf("%d",&A);
    	scanf("%d",&B);
    	c = X - A;
    	d = c / B;
    	e = c - (B * d);
    	printf("%d\n",e);
    }

Measured memory_bytes: 128
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int n, m;
  cin >> n >> m;
  cout << (n+m)%24 << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        int [] L = new int [n];
        for(int i=0;i<n;i++) L[i] = i;
        for(int i=0;i<q;i++){
            int cmd = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();
            if(cmd==0){
                int X = L[x];
                int Y = L[y];
                for(int j=0;j<n;j++)if(L[j]==Y)L[j] = X;
            }
            else{
                if(L[x]==L[y]) System.out.println(1);
                else System.out.println(0);
            }
        }
    }
}


Measured memory_bytes: 70072