akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"

#define rep(i, N) for(int i = 0;i < N;i++)

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



int main(void) {
	int N; cin >> N;
	vector<int> A(N + 2, 0);

	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}

	ll cost = 0;
	rep(i, N + 1) {
		cost += abs(A[i] - A[i + 1]);
	}

	for (int i = 1; i <= N; i++) {
		ll ans = cost;
		ans -= abs(A[i - 1] - A[i]);
		ans -= abs(A[i] - A[i + 1]);
		ans += abs(A[i - 1] - A[i + 1]);
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3756
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) //[l, r)
#define rep(i,n) REP(i,0,n)           //[0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showslr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i];}cerr<<endl //[l, r))

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}

void _DEBUG(){cerr<<endl;}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<",";_DEBUG(b...);}

template<typename T> inline void in(T &e){cin>>e;}
template<typename H,typename... T>void in(H &a, T&... b){in(a);in(b...);}
template<typename T> inline void out(T e){cout<<e<<endl;}
template<typename H,typename... T> void out(H a, T... b){out(a);out(b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int n,x;
vi vec;
vi dist;

int ans;

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

signed main(){
    io();
    
    in(n,x);
    vec.resize(n);
    rep(i,n) in(vec[i]);
    dist.resize(n);
    rep(i,n) dist[i]=abs(x-vec[i]);
    ans=dist[0];
    REP(i,1,n){
        ans=min(ans,gcd(dist[i],dist[i-1]));
    }
    
    out(ans);

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n;
	while(cin>>n,n){
		vector<string> s(n);
		vector<string > s_changed(n);
		int maxl = 0;
		REP(i,n){
			cin >> s[i];
			string t;
			REP(si,s[i].size()){
				if(si == 0)t += s[i][0];
				if(s[i][si] == 'a' || s[i][si] == 'i' || s[i][si] == 'u' || s[i][si] == 'e' || s[i][si] == 'o'){
					if(si<s[i].size()-1){t += s[i][si+1];}
				}
			}
			s_changed[i] = t;
			maxl = max(maxl,(int)t.size());
		}

		bool isre = false;
		bool ismatch = false;
		int ki = 1;
		for(;ki<=maxl;ki++){
			ismatch = false;
			REP(i,n){
				for(int j = 0;j<i;j++){
					string t1,t2;
					if(s_changed[i].size()<ki)
						t1 = s_changed[i].substr(0,s_changed[i].size());
					else
						t1 = s_changed[i].substr(0,ki);
					if(s_changed[j].size()<ki)
						t2 = s_changed[j].substr(0,s_changed[j].size());
					else
						t2 = s_changed[j].substr(0,ki);
					if(t1 == t2){
						ismatch = true;
						break;
					}
				}
				if(ismatch){
					break;
				}
			}
			if(!ismatch){
				isre = true;
				break;
			}
		}
		if(!isre)cout << -1 << endl;
		else cout << ki << endl;
	}
  return 0;
}

Measured memory_bytes: 3144
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using IP = pair<int, int>;
using vi = vector<int>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll gcd(ll a, ll b) {//最大公約数
	if (a < b)swap(a, b);
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	if (a < b)swap(a, b);
	return (a / gcd(a, b))*b;
}

ll area(ll h, ll w) {
	ll ans = 1e9;
	for (int i = 1; i < w; i++) {
		ll a = w - i;
		ll b = a / 2;
		ll c = a -	b;
		vector<ll> v = { i,b,c };
		sort(all(v));
		chmin(ans, (v[2] - v[0])*h);

		b = h / 2;
		c = h - b;
		vector<ll> v2 = { i*h,b*a,c*a };
		sort(all(v2));
		chmin(ans, (v2[2] - v2[0]));
	}
	return ans;
}

int main() {

	int h, w;
	cin >> h >> w;

	if (h % 3 == 0 || w % 3 == 0)pr(0);
	else pr(min(area(h, w), area(w, h)));

	system("pause");
	return 0;
}

Measured memory_bytes: 504
n,k = map(int, input().split())
al = list(map(int, input().split()))

res= 10**10

for i in range(n-k+1):
    st = al[i]
    en = al[i+k-1]
    if st *en <0:
        temp = min(abs(st),abs(en))*2+max(abs(st),abs(en))
    else:
        temp = max(abs(st),abs(en))
    res = min(temp,res)

print(res)

Measured memory_bytes: 19980
#include <stdio.h>

int main(void){
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);

    if(a<=c && c<=b){
        printf("Yes\n");
    }else if(b<=c && c<= a){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (lli i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n, cnt[26], mcnt[26];
string s[50];
int main() {
  cin >> n; read_n(s, n);
  fill(begin(mcnt), end(mcnt), 1e9);
  for (lli i=0; i<n; ++i) {
    fill(begin(cnt), end(cnt), 0);
    for (lli j=0; j<s[i].size(); ++j) {
      cnt[s[i][j] - 'a']++;
    }
    for (lli j=0; j<26; ++j) {
      mcnt[j] = min(mcnt[j], cnt[j]);
    }
  }

  string t;
  for (lli i=0; i<26; ++i) {
    for (lli j=0; j<mcnt[i]; ++j) {
      t.push_back(i + 'a');
    }
  }
  cout << t << '\n';
  return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define T int t, q=0; scanf("%d", &t); while(q++<t)
#define ll long long
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll x,y,z,a=0,b=0,c=0,d=0,sum,ans,total,cnt,n,m,k,p,kase,i,t;
string s1,s2;
#define N 100001
#define MX 1000000001
vector <ll> v;
map<ll,ll> mp;
set<ll> s;
map<ll,ll> :: iterator itr1, ptr1;
set<ll> :: iterator itr, ptr;


int main()
{


        cin>>s1;

        cout<<(s1=="RRR"?3:s1=="SSS"?0:s1=="RRS"||s1=="SRR"?2:1)<<endl;



    return 0;
}
// Happy Coding  (:




Measured memory_bytes: 3580
#include<iostream>
using namespace std;
#define lli long long 
#include<bits/stdc++.h>
int main(){
  lli n,flag=0;
  cin>>n;
  set<string>p;
  string s;
  cin>>s;
  p.insert(s);
  //lli si=1;
  for(lli i=1;i<n;i++){
    char c=s[s.size()-1];
    cin>>s;
    if(s[0]!=c)
      flag=1;
    p.insert(s);
    /*si++;
    if(si!=p.size())
      flag=1;
      */
  }
  if(flag)
    cout<<"No\n";
  else{
    if(n!=p.size())
      cout<<"No\n";
    else
      cout<<"Yes\n";
  }
  return 0;
}

Measured memory_bytes: 256
import Data.List

main :: IO ()
main = do
  n <- readLn :: IO Int
  putStrLn $ unwords $ map show $ take n proto 


proto :: [Int]
proto = [11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381]


Measured memory_bytes: 508
n = int(input())
ans = [0]*10**7
for i in range(1,5*10**2):
    for j in range(1,5*10**2):
        for k in range(1,5*10**2):
            ans[(i+j+k)**2-(i*j+j*k+k*i)] += 1
for i in ans[1:n+1]:
    print(i)


Measured memory_bytes: 147632
n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a_gap = 0
b_gap = 0
for i in range(n):
    if A[i]>B[i]:
        a_gap+=A[i]-B[i]
    if A[i]<B[i]:
        b_gap+=(B[i]-A[i])//2

if b_gap-a_gap<0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 40560
n,m=map(int,input().split())
a=list(map(int,input().split()))
sum=0
ans=0
for i in range(n):
  sum+=a[i]
for i in range(n):
  if a[i]*4*m>=sum:
    ans+=1
if ans>=m:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <stdio.h>
#include <numeric>
#include <algorithm>
using namespace std;
int main(){
    for(int i=0;i<3;++i){
        int a,b,c,d,e,f,n,m,r;
        cin>>a>>b>>c>>d>>e>>f;
        n=a*3600+b*60+c;
        m=d*3600+e*60+f;
        r=m-n;
        cout<<r/3600<<" ";
        r%=3600;
        cout<<r/60<<" ";
        r%=60;
        cout<<r<<endl;
    }
    return 0;
}


Measured memory_bytes: 3044
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


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;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n; cin >> n;
	vector<P>r(n), b(n);
	rep(i, n)cin >> r[i].first >> r[i].second;
	rep(i, n)cin >> b[i].first >> b[i].second;
	sort(ALL(b));
	int ans = 0;
	rep(i, n) {
		int tmp = -1; int idx = -1;
		rep(j, r.size()) {
			if (r[j].first < b[i].first&&r[j].second < b[i].second) {
				if (r[j].second > tmp) {
					tmp = r[j].second;
					idx = j;
				}
			}
		}
		if (idx >= 0) {
			ans++; r.erase(r.begin() + idx);
		}
	}
	cout << ans << endl;
	return 0;
}

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

long long N, K;

int main() {
    scanf("%d%d", &N, &K);
    int dev0 = N/K;
    int devK2 = (N + K/2)/K;
    long long pow0  = (long long)pow((double)dev0,  3.0);
    long long powK2 = (long long)pow((double)devK2, 3.0);
    long long ans = (K%2) ? pow0 : pow0 + powK2;
    cout << ans << endl;
}


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

int main() {
     int N, K;
     cin >> N >> K;
     vector<int> v(N);
     for (int i = 0; i < N;i++){
       cin >> v.at(i);
     }
     int d = 0;
     for (int i = 0; i < N; i++){
         if(v.at(i)<=K/2){
           d += 2 * v.at(i);
         }
         else{
           d += 2 * (K - v.at(i));
         }
     }
     cout << d << endl;
}


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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )

#define MAX 200005

vi road[MAX];
int sign[MAX];


void bfs( int x ) {
    queue<int> q;
    q.push(x);
    sign[1] = -1;
    int s = q.front();

    while ( !q.empty() ) {
        s = q.front();
        q.pop();
        // cout << "s -> " << s << endl;
        for ( size_t i = 0; i < road[s].size(); i++ ) {
            if ( sign[road[s][i]] == 0 ) {
                sign[road[s][i]] = s;
                q.push(road[s][i]);
            }
            if ( road[s][i] == 1 ) {
                sign[s] = 1;
            }
        }
    }
}


int main() {

    int n, m;

    cin >> n >> m;

    fo(i, m) {
        int temp1, temp2;
        cin >> temp1 >> temp2;
        road[temp1].pb(temp2);
        road[temp2].pb(temp1);
    }

    memset(sign, 0, sizeof(sign));
    bfs(1);

    if ( sign[2] == 0 ) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    for ( int i = 2; i <= n; i++ ) {
        cout << sign[i] << endl;
    }
    // for( int i = 2; i <= n; i++ ) {
    //     memset(d, -1, sizeof(d));
    //     bfs(i);
    //     if( d[1] != -1 ) {
    //         if ( !foi ) {
    //             foi = true;
    //             cout << "Yes\n";
    //         }
    //         cout << d[1] << endl;
    //     }
    // }

  return 0;
}

Measured memory_bytes: 13204
N=int(input())
c=4
d=7
ans=0
ans2=0
ans3="No"
for i in range(15):
    ans=d*i
    if ans !=N:
        for j in range(26):
            ans2=ans+c*j
            if ans2==N:
                ans3="Yes"

    else :
        ans3="Yes"

print(ans3)

Measured memory_bytes: 3060
#include <stdio.h>

typedef long long ll;

int main(){

	/*

	for(j=1;j<=49;j++){

	int x[50];

	int cnt2=0;

	for(i=0;i<=49-j;i++){
	x[cnt2]=i;
	cnt2++;
	}
	for(i=51-j;i<=50;i++){
	x[cnt2]=i;
	cnt2++;
	}
	int cnt=0;

	while(1){

	int ma=x[0];
	int idx=0;
	for(i=1;i<50;i++){
	if(ma<x[i]){ma=x[i];idx=i;}
	}
	if(ma<50){break;}
	x[idx]-=50;

	for(i=0;i<50;i++){
	if(i!=idx){
	x[i]++;
	}
	}
	cnt++;
	//for(i=0;i<7;i++){
	//printf("%d ",x[i]);
	//}
	//printf("\n");
	}
	printf("cnt=%d\n",cnt);
	}
	*/

	ll i;

	ll K;

	scanf("%lld",&K);

	ll b=K%(50ll);
	ll a=(K-b)/50ll;

	ll ans[50];

	if(b==0ll){
		for(i=0ll;i<50ll;i+=1ll){
			ans[i]=a+i;
		}
	}
	else{

		int cnt=0;

		for(i=0ll;i<=49ll-b;i+=1ll){
			ans[cnt]=a+i;
			cnt++;
		}
		for(i=51ll-b;i<=50ll;i+=1ll){
			ans[cnt]=a+i;
			cnt++;
		}
	}

	printf("50\n");

	for(i=0;i<49;i++){
		printf("%lld ",ans[i]);
	}
	printf("%lld\n",ans[49]);

	return 0;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

bool is_prime(int a){
    rep(i,2,a) if(a%i==0) return false;
    return true;
}

void solve(){
    int n;
    cin >> n;
    
    int64_t ans=1;
    rep(i,2,n+1){
        if(!is_prime(i)) continue;
        vector<int> count(100000);
        int j=i,sum=0;
        for(;;){
            int a=n/j;
            if(a==0) break;
            sum+=a;
            j*=i;
        }
        ans=((sum+1)*ans)%1000000007;
    }
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define faster_io ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mem(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define ll long long
#define pb push_back
#define pll pair<ll, ll>
using namespace std;
const ll N = 1e6 + 7, M = 1e5 + 7, mod = 1e9 + 7, inf = 1e18 + 7;
ll tc, n, m, q, a, b, c, d, i, j, k, l, sum;
ll ar[N], flag[N], fr[N];
string s;
vector < ll > vec, prm;

ll bigmod(ll base, ll pow)
{
    if(pow == 0)
        return 1;
    ll x = bigmod(base, pow / 2);
    x = (x * x) % mod;
    if(pow % 2)
        x = (x * base) % mod;
    return x;
}

void sieve()
{
    prm.pb(2);
    for(i = 3; i < N; i += 2)
    {
        if(!flag[i])
        {
            for(j = i * i; j < N; j += 2 *i)
                flag[j] = 1;
            prm.pb(i);
        }
    }
}


int main()
{
    sieve();
    cin >> n;
    for(i = 1; i <= n; i++)
    {
        cin >> ar[i];
        a = ar[i];
        for(j = 0; prm[j] * prm[j] <= a; j++)
        {
            ll cnt = 0;
            while(a % prm[j] == 0)
                a /= prm[j], cnt++;
            fr[prm[j]] = max(fr[prm[j]], cnt);
        }
        if(a != 1)
            fr[a] = max(fr[a], 1LL);
    }
    ll LCM = 1;
    for(i = 0; i < prm.size(); i++)
        if(fr[prm[i]])
            LCM = (LCM * bigmod(prm[i], fr[prm[i]])) % mod;
    ll ans = 0;
    for(i = 1; i <= n; i++)
        ans = (ans + (LCM * bigmod(ar[i], mod - 2)) % mod) % mod;
    cout << ans << endl;
}


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

static vector<int> stepList;
static vector<int> retList;

int main() {
  // 入力受け取り
  int N;
  cin >> N;
  stepList.resize(N);
  retList.resize(N);
  for (int i=0; i<N; i++) cin >> stepList.at(i);
  
  // dp
  retList[0]=0;
  retList[1]=abs(stepList[1]-stepList[0]);
  for(int i=2; i <N; i++) {
    retList[i]=min(retList[i-1]+abs(stepList[i]-stepList[i-1]),retList[i-2]+abs(stepList[i]-stepList[i-2]));
  }
  
  // 出力
  cout << retList[N-1] << endl;
}


Measured memory_bytes: 1024
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const LL M=1e9+7;
const int L=1000;
int A[L];
int B[L];
int main() {
	int H,W;
	cin >> H >> W;
	for(int i=0;i<H;i++){
		cin >> A[i];
	}
	sort(A,A+H,greater<int>());
	for(int j=0;j<W;j++){
		cin >> B[j];
	}
	sort(B,B+W,greater<int>());
	if(A[0]!=B[0]||A[0]!=W*H){
		cout << 0 << endl;
		return 0;
	}
	int r=0;
	int c=1;
	LL ret=1;
	int f=0;
	int done[6];
	for(int i=H*W-1;i>=1;i--){
		//cerr << i <<  ", " << r << ", " << c << ": " << ret << ", " << f << endl;
		if(i>=A[r]||(c<W&&i<B[c])||(r+1<H&&i<A[r+1])){
			//cerr << "a" << endl;
			done[0]=1;
			ret=0;
			break;
		}
		if(r+1<H&&A[r+1]==i){
			f+=c;
			r++;
			if(B[c]==i){
				//cerr << "b" << endl;
				done[1]=1;
				c++;
				f+=r;
			}
			else{
				//cerr << "c" << endl;
				done[2]=1;
				ret*=c;
				ret%=M;
				f--;
			}
		}
		else if(c<W&&B[c]==i){
			//cerr << "d" << endl;
			done[3]=1;
			ret*=r+1;
			ret%=M;
			c++;
			f+=r;
		}
		else {
			//cerr << "d" << endl;
			done[4]=1;
			ret*=f;
			ret%=M;
			f--;
		}
	}
	if(r!=H&&c!=W){
		ret=0;
	}
#if 0
	for(int i=0;i<6;i++){
		cerr << done[i];
	}
	cerr << endl;
#endif
	cout << ret << endl;
	


	return 0;
}



Measured memory_bytes: 256
n, m = map(int, input().split())
s = sorted([tuple(map(int, input().split())) for _ in range(n)])
ans = 0
for i in range(n):
  ans += s[i][0]*s[i][1]
  if m-s[i][1]>0:
    m -= s[i][1]
  else:
    ans -= abs(m-s[i][1])*s[i][0]
    break
print(ans)

Measured memory_bytes: 17756
using System;

public class Don    
{
    public Don() { }
    private Reader r = new Reader();

    public void Solve()
    {
        var N = r.nextLong();
        var X = r.nextLong();
        X = Math.Min(X, N - X);

        var a = N - X;
        var b = X;
        long ans = 0;
        while (b != 0)
        {
            var div = a / b;
            ans += b * div;
            var mod = a % b;
            a = b;
            b = mod;
        }

        Console.WriteLine(3 * ans);
    }

    public static void Main(string[] args)
    {
        new Don().Solve();
    }

}

class Reader
{
    string[] s;
    int i;
    char[] cs = new char[] { ' ' };

    public Reader()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length)
            return s[i++];
        var input = Console.ReadLine();
        while (input == "")
            input = Console.ReadLine();
        s = input.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return next();
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 2648
#include<cstdio>

int main(){
    long long m,n,l,i,j,k,s;
    scanf("%lld%lld%lld",&n,&m,&l);
    long long a[n][m],b[m][l];
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%lld",&a[i][j]);/*Aの入力*/
        }
            }
            for(i=0;i<m;i++){
                for(j=0;j<l;j++){
                    scanf("%lld",&b[i][j]);/*Bの入力*/
                }
                    }
                    for(i=0;i<n;i++){

                        for(j=0;j<l;j++){
                            s = 0;
                            for(k=0;k<m;k++){
                                s = s + a[i][k] * b[k][j];
                            }
                            if(j==l-1){
                                printf("%lld",s);
                            }
                            else{
                                printf("%lld ",s);
                            }
                        }
                        printf("\n");
                    }
               
return 0;    
}


Measured memory_bytes: 2748
while true
  a, op, b = gets.chomp.split
  a = a.to_i
  b = b.to_i
  break if op == "?"
  case op
  when "+"
    puts a + b
  when "-"
    puts a - b
  when "*"
    puts a * b
  when "/"
    puts a / b
  end
end

Measured memory_bytes: 8672
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin>>N;
    vll A(N);
    for (size_t i = 0; i < N; i++)
    {
        cin>>A[i];
    }
    sort(all(A));
    vll acc(N);
    partial_sum(all(A),acc.begin());
    int ans=0;
    ll Min = A.back();
    for (int i = N-1; i >=0; i--)
    {
        if(i==N-1)
        ans++;
        else if(2*acc[i] >= Min)
        {
            chmin(Min,A[i]);
            ans++;
        }
        
    }
    cout<<ans<<endl;    
    return 0;
}

Measured memory_bytes: 4844
N=int(input())
x=[input() for _ in range(N)]
flag=0

if len(x)!=len(list(set(x))):
  flag=1

for i in range(N-1):
  if x[i][-1]!=x[i+1][0]:
    flag=1
if flag==0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 1 << 100
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


def gcd(i, j):
    while j:
        i, j = j, i % j
    return i


a, b = LI()
print(a * b // gcd(a, b))

Measured memory_bytes: 39664
#include<bits/stdc++.h>
#define endl "\n"

using namespace std;

vector< int > tab[100010];
int  x, n, k, ans, g[100010];
bool met[100010];

void dfs( int w )
{
	met[w] = 1;
	for( int a = 0; a < tab[w].size(); a++ )
	{
		if( !met[tab[w][a]] )
		{
			dfs( tab[w][a] );	
			if( w != 1 && g[tab[w][a]] == k-1 )
			{
				ans++;
			}
			else g[w] = max( g[w] , g[tab[w][a]] + 1 );
		}
	}
}
int main()
{
	ios_base::sync_with_stdio( 0 );
	cin.tie( 0 );
	cin>>n>>k;
	cin>>x;
	if( x != 1 )ans++;
	for( int a = 2; a <= n; a++ )
	{
		cin>>x;
		tab[x].push_back( a );	
	}
	dfs( 1);
	cout<<ans<<endl;
	return 0;	
}

Measured memory_bytes: 12416
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        E solver = new E();
        solver.solve(1, in, out);
        out.close();
    }

    static class E {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            char[] c = in.next().toCharArray();
            int n = c.length;

            int len = 1;
            int[] st = new int[n + 1];
            st[0] = n;
            boolean[] u = new boolean[26];
            int left = 26;
            int[][] first = new int[26][n + 1];
            for (int j = 0; j < 26; j++) {
                first[j][n] = n;
            }
            for (int i = n - 1; i >= 0; i--) {
                int v = c[i] - 'a';
                if (!u[v]) {
                    u[v] = true;
                    left--;
                }
                for (int j = 0; j < 26; j++) {
                    first[j][i] = first[j][i + 1];
                }
                first[v][i] = i;
                if (left == 0) {
                    st[len] = i;
                    len++;
                    Arrays.fill(u, false);
                    left = 26;
                }
            }
            StringBuilder ans = new StringBuilder();
            int p = 0;
            for (int i = len - 1; i >= 0; i--) {
                for (int j = 0; j < 26; j++) {
                    if (first[j][p] >= st[i]) {
                        p = first[j][p] + 1;
                        ans.append((char) ('a' + j));
                        break;
                    }
                }
            }
            out.println(ans);
        }

    }
}



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

int main(void){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = n - 1; i >= 0; i--){
        cout << a[i];
        if(i == 0)  cout << endl;
        else cout << " ";
    }
    return 0;
}



Measured memory_bytes: 3084
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int N = 1010;
int par[N], visit[N];
VI e[N];

P dfs(int now, int past){
    visit[now] = 1;
    par[now] = past;
    for (int next : e[now]){
        if (visit[next]){
            return P(now, next);
        }
        P x = dfs(next, now);
        if (x != P(-1, -1)) return x;
    }
    visit[now] = 0;
    par[now] = -1;
    return P(-1, -1);
}

int main() {
    int n, m;
    cin >> n >> m;
    REP(i,m){
        int u = in() - 1, v = in() - 1;
        e[u].push_back(v);
    }

    VI loop;
    REP(i,n){
        REP(j,n) visit[i] = 0;
        P p = dfs(i, -1);
        if (p == P(-1, -1)) continue;
        int x = p.first, y = p.second;
        loop.push_back(x);
        while (x != y){
            x = par[x];
            loop.push_back(x);
        }
        reverse(ALL(loop));
        break;
    }

    if (loop.empty()){
        cout << -1 << endl;
        return 0;
    }

    while (true){
        // for (int x : loop) cout << x + 1 << " ";
        // cout << endl;
        VI p(n, -1);
        REP(i,loop.size()) p[loop[i]] = i;
        int from = -1, to = -1;
        REP(i,loop.size()){
            int x = loop[i];
            for (int y : e[x]){
                if (p[y] != -1 && p[y] != (i + 1) % loop.size()){
                    from = i;
                    to = p[y];
                    break;
                }
            }
            if (from != -1) break;
        }
        if (from == -1) break;
        // cout << from << " " << to<< endl;
        VI loop_next;
        if (from < to){
            REP(i,loop.size()){
                if (i <= from || i >= to) loop_next.push_back(loop[i]);
            }
        }else{
            FOR(i,to,from) loop_next.push_back(loop[i]);
        }
        loop = loop_next;
        if (loop.size() == 2) break;
    }
    cout << loop.size() << endl;
    for (int x : loop) cout << x + 1 << endl;

    return 0;
}


Measured memory_bytes: 384
n = int(input())
S = list(int(input()) for _ in range(n))

cnt = 0
res = 0
t = []
for i in range(n):
    if S[i] % 10 == 0:
        cnt += 1
    else:
        t.append(S[i])
    res += S[i]

if cnt == n:
    print(0)
else:
    if res % 10 != 0:
        print(res)
    else:
        print(res - min(t))

Measured memory_bytes: 3064
import collections

n = int(input())
s = [input() for i in range(n)]

c = collections.Counter(s)
common = c.most_common()

count = common[0][1]
ans = []
for i in common:
  if i[1] == count:
    ans.append(i[0])
  else:
    break
ans.sort()
print(*ans,sep='\n')  


Measured memory_bytes: 50172
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int mod=998244353,N=1e6+5;
int ans=1,cnt[N],d[N],ma,n;

void GG(){
	write(0);
	exit(0);
}

signed main(){
	read(n);
	for(int i=1;i<=n;i++) ma=max(ma,read(d[i])),cnt[d[i]]++;
	for(int i=2;i<=n;i++) if(!d[i]) GG();
	for(int i=0;i<=ma;i++) if(!cnt[i]) GG();
	for(int i=1;i<=ma;i++) for(int j=1;j<=cnt[i];j++) ans=1ll*ans*cnt[i-1]%mod; 
	write(ans);
}

Measured memory_bytes: 4300
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T &  a, U &  ... b) { cin >> a; IN_(b ...); };
template<typename T                > void OUT(T && a            ) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

int main() {
	IN(int, n);
	OUT(n >= 30 ? "Yes" : "No");
}


Measured memory_bytes: 3644
import sys
read = sys.stdin.read
def main():
    def factorization(n):
        arr = []
        temp = n
        for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
            if temp % i == 0:
                cnt = 0
                while temp % i == 0:
                    cnt += 1
                    temp //= i
                arr.append([i, cnt])
        if temp != 1:
            arr.append([temp, 1])
        if not arr:
            arr.append([n, 1])
        return arr

    n = int(input())
    if n == 1:
        print(0)
        sys.exit()
    ps = [1] * 101
    for i1 in range(2, n + 1):
        i1fac = factorization(i1)
        for face in i1fac:
            ps[face[0]] += face[1]
    o3 = 0
    o5 = 0
    o15 = 0
    o25 = 0
    o75 = 0
    for pse in ps:
        o3 += pse >= 3
        o5 += pse >= 5
        o15 += pse >= 15
        o25 += pse >= 25
        o75 += pse >= 75
    r = o75
    r += o25 * (o3 - 1)
    r += o15 * (o5 - 1)
    if o5 >= 2:
        r += (o5 * (o5 - 1) // 2) * (o3 - 2)
    print(r)

if __name__ == '__main__':
    main()

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

main(){
	int n,k;
	int a[30],b[30];
	long long ans;
	
	ans = 0;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++){
		cin>>k;
		ans += k;	
	}
	for(int i=1;i<n;i++)
		cin>>b[i];
	for(int i=2;i<=n;i++){
		if(a[i] == a[i-1] +1)
			ans += b[a[i]-1];
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()


int main(){
  ll N;cin>>N;
  vll A(N);rep(i,N)cin>>A[i];
  deque<int> d;
  for(int i=0;i<N;++i){
    int p = lower_bound(all(d),A[i]) - d.begin();
    if(p==0) d.push_front(A[i]);
    else d[p-1] = A[i];
  }
  cout<<d.size()<<endl;
}

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

int dubling[70][200001];

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

  ll n, k;
  cin >> n >> k;

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

  for (int i = 0; i < 69; ++i) {
    for (int j = 0; j < n; ++j) {
      dubling[i+1][j] = dubling[i][dubling[i][j]];
    }
  }

  int now = 0;
  for (int i = 0; k > 0; ++i) {
    if (k & 1) now = dubling[i][now];
    k = k >> 1LL;
  }

  cout << now + 1 << '\n';

  return (0);
}


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

using namespace std;
using ll = long long;


int main(){
  string s;
  cin >> s;
  vector<ll> c(s.size(), 0);
  
  int i, j;
  i = 0; j = 1;
  while(true){
    if(s[j]=='L'){
      if((j-i)%2==0){
        c[j-1] += (j-i)/2;
        c[j] += (j-i)/2;
      }else{
        c[j-1] += ((j-i)/2)+1;
        c[j] += (j-i)/2;
      }
      i = j+1;
    }
    j++;
    if((i+1)>=s.size()) break;
  }
  
  i = s.size()-1; j = i-1;;
  while(true){
    if(s[j]=='R'){
      if((i-j)%2==0){
        c[j+1] += (i-j)/2;
        c[j] += (i-j)/2;
      }else{
        c[j+1] += ((i-j)/2)+1;
        c[j] += (i-j)/2;
      }
      i = j-1;
    }
    j--;
    if(i<=0) break;
  }
  
  
  
  
  for(int i=0; i<s.size(); i++) cout << c[i] << " ";
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 4316
#include <iostream>
 
using namespace std;
int n;
 
int main() {
  cin >> n;
  cout << n << ":";
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      n /= i;
      cout << " " << i;
    }
  }
  if (n != 1) cout << " " << n << endl;
  else cout << endl;
  return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

vector<ll> vec;
vector<ll> vec2;

void init(){
  ll x = 1;
  ll x2 = 1;
  while(x<10000000000){
    vec.push_back(x);
    x2*=4;
    x+=x2;
  }
  ll y = 0;
  ll y2 = 2;
  while(y>-10000000000){
    vec2.push_back(y);
    y-=y2;
    y2*=4;
  }
}

vector<ll> ans(33,0);

void solve(ll N){
  if(N==1){
    ans.at(0)=1;
  }else if(N==0){
    ans.at(0)=0;
  }else if(N>1){
    REP(i,vec.size()){
      if(N<=vec.at(i)){
        ans.at(i*2)=1;
        solve(N-pow(2,i*2));
        break;
      }
    }
  }else if(N<0){
    REP(i,vec2.size()){
      if(vec2.at(i)<=N){
        ans.at(i*2-1)=1;
        solve(N+pow(2,i*2-1));
        break;
      }
    }
  }
}

int main()
{
  ll N;
  cin >> N;
  init();
  solve(N);

  int flag = 0;


  REPR(i,32){
    if(ans.at(i)==1&&flag==0){
      flag=1;
    }
    if(flag==1){
      cout << ans.at(i);
    }
  }
  if(flag==0){
    cout << 0;
  }
  cout << endl;
}

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

int main()
{
  std::string s;
  std::cin >> s;
  int n1{std::count_if(s.begin(), s.end()-1, [&s](const char c){ return c == *s.begin(); })};
  int n2{std::count_if(s.rbegin(), s.rend()-1, [&s](const char c){ return c == *s.rbegin(); })};
  std::cout << ((n1<3 && n2<3) ? "No" : "Yes") << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <bits/stdc++.h>
#include<stdbool.h>
#include<math.h>
#include<string.h>
#define ll long long
#define db double
#define sz 500000005
using namespace std;

char s[200005], t[200005];


int main()
{
    ll n, i, cnt=0;
    scanf("%s", s);
    scanf("%s", t);
    n=strlen(s);
    for(i=0; i<n; i++)
    {
        if(s[i]!=t[i])
            cnt++;
    }
    printf("%I64d", cnt);
    return 0;
}


Measured memory_bytes: 4220
n = gets.chomp.to_i
a_arr = gets.chomp.split(" ").map(&:to_i)

count = 0
while a_arr.length > 0 do
  tmp_arr = []
  a_arr.each do |a|
    if a % 2 == 0 then
      tmp_arr << a / 2
      count += 1
    end
  end
  a_arr = tmp_arr
end

puts count


Measured memory_bytes: 4732
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    ll ans = 0;
    rep(i,0,N){
        int a;
        cin >> a;
        ans += a-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

alias Edge = Tuple!(int, "u", int, "v");

long[] f(long x) {
    if (x == 0) {
        long[] ans = new long[](42);
        return ans;
    } else if (x == 1) {
        long[] ans = new long[](42);
        ans[0] = 1;
        return ans;
    }

    long b = x;
    long[] ans;

    if (b % 4 == 0 || b % 4 == 3) {
        ans ~= 0;
    } else {
        ans ~= 1;
    }

    foreach (i; 1..42) {
        long v = 1L << (i + 1);
        if (b % v < v / 2) {
            ans ~= 0;
        } else if (b % v % 2 == 0) {
            ans ~= 1;
        } else {
            ans ~= 0;
        }
    }

    return ans;
}

void main() {
    auto s = readln.split.map!(to!long);
    auto A = s[0];
    auto B = s[1];

    A = max(0L, A-1);
    long ans = 0;
    long[] fa = f(A);
    long[] fb = f(B);


    foreach (i; 0..fa.length) {
        ans |= (fa[i] ^ fb[i]) << i;
    }

    ans.writeln;
}


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

using namespace std;

int main() {
  int n;
  scanf("%d",&n);
  int d=1;
  while ((d<<1)<=n) d<<=1;
  if (d==n) {
  	puts("No");
  	return 0;
  }
  puts("Yes");
  for(int i=2;i<n;i+=2) {
  	printf("%d %d\n",1,i);
  	printf("%d %d\n",i,i+1);
  	printf("%d %d\n",1,i+1+n);
  	printf("%d %d\n",i+1+n,i+n);
  }
  if (!(n&1)) {
  	int u=d,v=(n^d);
  	printf("%d %d\n",u,n);
  	printf("%d %d\n",v+1+n,2*n);
  }
  printf("%d %d\n",3,n+1);
  return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
ll sz(string &s){ return (ll)s.size(); }
ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b; }
bool checkindex(ll i,ll n){ return (i < n && i >= 0); }



int main(){
    ll n;
    cin >> n;
    ll a[n] = {};

    rep(i,0,n){
        cin >> a[i];
    }
    sort(a,a+n);
    ll cnt = 0;
    rep(i,0,n){
        if(i == n-1){
            if(cnt % 2 == 1) cnt++;
        }
        else if(a[i] == a[i+1]) cnt++;
    }
    cout << n - cnt << endl;
}


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

const int MAXN = 4e5+5;

int h, w;
pii s[MAXN];
int cth, ctw;

int main() {
    cin >> w >> h;
    for (int i = 0; i < w; ++i) {
        int x; cin >> x;
        s[i] = pii(x, 0);
    } for (int j = 0; j < h; ++j) {
        int x; cin >> x;
        s[j+w] = pii(x, 1);
    }

    sort(s, s+w+h);
    ll tot = 0;

    for (int i = 0; i < w+h; ++i) {
        pii t = s[i];
        if (t.second == 0) {
            tot += t.first*(h+1-cth);
            ctw++;
        } else {
            tot += t.first*(w+1-ctw);
            cth++;
        }
    }

    cout << tot << endl;
}

Measured memory_bytes: 3328
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>

  using namespace std;
   

//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ
  typedef long long ll;
  typedef long double lld;
  typedef string str;
  typedef unsigned long long ull;
  ll INF = INT_MAX;
  // ll mod = 998244353;
  lld PI = 3.141592653;

// const int N = 2e5 + 5;

// int a[N];
// int n,k;



// void solve(){

// string s;
// cin>>s;


// }
 


  int main()
  {
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
      
   int n;
   cin>>n;
   vector<int> a(n);
   // multiset<int> b;
   vector<int> b(1000005);
   for (int i = 0;i<n;i++) {cin>>a[i]; b[a[i]]++;}
    sort(a.begin(), a.end());

  vector<bool> dp(a[n-1]+10, true);
  for (int i = 0;i<n;i++){
    int v = a[i];
    if (dp[v]){
      // if (v*v<=a[n-1]+2){
        for (int j = v*2; j<= a[n-1]+2;j+=v) {dp[j] = false; }
      // }
    }
  }
  int ans = 0;

  for (int i = 0;i<n;i++){
    if (dp[a[i]] && b[a[i]]==1) {ans++; }
  }
  // cout<<endl;
cout<<ans<<"\n";

}



Measured memory_bytes: 7628
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov

int main(){
    ll x;
    cin >> x;
    ll v=100;
    ll count=0;
    while(v<x){
        count++;
        v+=v/100;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3624
# ABC 144: B – 81
N = int(input())

canExpress = 'No'

for i in [1, 2, 3, 4, 5, 6, 7, 8, 9]:
    if N % i == 0 and N // i < 10:
        canExpress = 'Yes'
        break

print(canExpress)

Measured memory_bytes: 3064