akhauriyash/Code-Regression huggingface dataset:
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(
        N : u32,
        arr : [u32; N],
    );
//    let N: u32;
//    let arr :[u32; N];

    println!("{}",arr.iter().map(|x| x.trailing_zeros()).min().unwrap());
}

Measured memory_bytes: 4352
import sys

while True:
	n, x = [ int( val ) for val in sys.stdin.readline().split( " " ) ]
	if 0 == n and 0 == x:
		break
		
	cnt = 0
	ave = x / 3
	for i in range( 1, ave ):
		for j in range( i+1, n ):
			if  x <= ( i+j ):
				break
			for k in range( j+1, n+1 ):
				s = ( i + j + k )
				if x == s:
					cnt += 1
					break
				elif   x < s:
					break
	
	print( cnt )

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

X = input().split()
#import pdb; pdb.set_trace()
i = 0
sum = 0

while i < N:
  x = int(X[i])
  sum += x
  i += 1

P = round(sum / N)

dis = 0
i = 0


while i < N:
  z = int(X[i])
  dis += (P - z) ** 2
  i += 1

print(dis)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdlib>
int gcd(int x,int y)
{
  int r;
  if(x>y){
    do{
      r=x%y;
      x=y;
      y=r;
    }while(r>0);
    return x;
  }else{
    do{
      r=y%x;
      y=x;
      x=r;
    }while(r>0);
    return y;
  }
}
int main()
{
  int a,b;
  std::cin>>a>>b;
  std::cout<<gcd(a,b)<<'\n';
  return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int x, a;

int main(void) {
  // Here your code !
  scanf("%d %d", &x, &a);

  printf("%d\n", (x < a) ? 0 : 10);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
#include<tuple>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tpl;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 1500

const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int h, w;

template<typename T>
T maxSquare(vector< vector<T> > board) {
	T H = board.size(), W = board[0].size();
	vector< vector<T> > dp(H, vector<T>(W));

	T ret = 0;
	for(int i = 0;i < H;i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (board[i][j] == 1) continue;
			if (i == 0 || j == 0) dp[i][j] = 1;
			else {
				dp[i][j] = min(dp[i - 1][j - 1], min(dp[i][j - 1], dp[i - 1][j])) + 1;
			}
			ret = max(ret, dp[i][j] * dp[i][j]);
		}
	
	}
	return ret;
}

int main() {

	cin >> h >> w;
	vector<vector<int> > mp(h, vector<int>(w));
	for (int i = 0; i < h; i++)
	{
		for (int j = 0; j  < w; j ++)
		{
			cin >> mp[i][j];
		}
	}

	cout << maxSquare(mp) << endl;
}


Measured memory_bytes: 26104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD (int) (1e9+7)
#define INF (int) 2e9

int main(){
    int h, w, d;
    cin >> h >> w >> d;

    vector<P> v(h*w);

    rep(i, h){
        rep(j, w){
            P p = P(i, j);
            int a; cin >> a;
            v[--a] = p;
        }
    }

    // 累積和 ll?
    ll s[h*w+5];
    
    for (int i = 0; i < d; i++){
        s[i] = 0;
        int x = v[i].first;
        int y = v[i].second;
        for (int j = i+d; j < h*w; j+=d) {
            int xx = v[j].first;
            int yy = v[j].second;

            s[j] = s[j-d] + abs(x-xx)+abs(y-yy);
            x = xx;
            y = yy;
        }
    }
    
    int q; cin >> q;
    rep(i, q){
        int l, r;
        cin >> l >> r;
        // printf("%d %d\n", s[r-1], s[l-1]);
        cout << s[--r] - s[--l] << endl;
    }
    return 0;
}

Measured memory_bytes: 2560
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:16777216")
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <stack>
#include <iomanip>
#include <set>
#include <queue>
#include <unordered_map>

using namespace std;

#define ff first
#define ss second

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int maxn = 1e5 + 7;
const int inf = 2e9 + 7;
const ll infl = 1e18 + 7;
const long double eps = 1e-9;
const ll mod = 1e9 + 7;

int main() {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif // _DEBUG

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<bool> dp(k + 1, 0);
	for (int i = 1; i <= k; i++) {
		int cnt = 0;
		for (int j = 0; j < n; j++) {
			if (i - a[j] >= 0 && dp[i - a[j]] == false) cnt++;
		}
		if (cnt) dp[i] = true;
	}
	if (dp[k]) cout << "First";
	else cout << "Second";
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i,N) for(int(i)=0;(i)<(N);++(i))
#define all(v) (v).begin() , (v).end()
using P = pair<int,int>;

int main(){
    int W,H;
    char c;
    cin >> W >> H >> c;

    vector<vector<char>> flag(H,vector<char>(W));

    for(int h = 0;h < H;++h){
        for(int w = 0;w < W;++w){
            if((h == 0 || h == H-1) && (w==0 || w == W-1)){
                flag[h][w] = '+';
            }
            else if(h==0 || h == H-1) flag[h][w] = '-';
            else if(w == 0 || w == W-1) flag[h][w] = '|';
            else flag[h][w] = '.';
        }
    }

    flag[H/2][W/2] = c;

    for(int h = 0;h<H;++h){
        for(int w = 0;w<W;++w){
            cout << flag[h][w];
        }
        cout << endl;
    }

}


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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> c(M);
	vector<char> s(M);
	rep(i, M) cin >> c[i] >> s[i];

	
	int ans = -1;
	rep(i, 1000) {
		string I = to_string(i);
		if (I.size() != N) {
			continue;
		}

		bool valid = true;
		rep(j, M) {
			if (I[c[j] - 1] != char(s[j])) {
				valid = false;
				continue;
			}
		}
		if (!valid) {
			continue;
		}

		ans = i;
		break;
	}

	cout << ans << endl;
}

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

int main(){
    double x;
    double pi = 3.1415;
    scanf("%lf",&x);
    double result = 2 * x * pi;

    printf("%lf",result);    
}

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

typedef pair<int, int> Ginkgo;

map<int, int> sq;

int main(){
    for(int i=0; i<200; i++)
        sq[i*i] = i;
    
    int N; cin >> N;
    while(N--){
        set<Ginkgo> divs;
        int p, q; cin >> p >> q;
        for(int i=1; i<=p*p + q*q; i++){
            for(int m=-200; m<200; m++) if(i - m*m >= 0){
                int n2 = i - m*m;
                if(sq.count(n2) == 0) continue;
                
                for(auto n: {-sq[n2], sq[n2]}){
                    if((m*p+n*q)%i == 0 && (m*q-n*p)%i == 0){
                        divs.insert({n, m});
                    }
                }
            }
        }
        cout << (divs.size() == 8? "P": "C") << endl;
    }
}

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

 int main(){
 int N;
 double ans = 0.0, A;
 cin >> N;
 for(int i = 1; i <= N; ++i){
 cin >> A;
 ans += 1.0 / A;
 }
 ans = 1.0 / ans;
 cout << setprecision(16) << ans << endl;
 }

Measured memory_bytes: 3792
N = int(input())
a = list(map(int, input().split()))
 
color = ["gray","braun","green","watter","bruee","yellow","orange","red"]
 
lis = []
 
count = 0
 
for i in a:
    if 1 <= i <=399:
        lis.append("gray")
    
    if 400 <= i <= 799:
        lis.append("braun")
    
    if 800 <= i <= 1199:
        lis.append("green")
    
    if 1600 <= i <= 1999:
        lis.append("bruee")
 
    if 1200 <= i <= 1599:
        lis.append("watter")
    
    if 2000 <= i <= 2399:
        lis.append("yellow")
    
    if 2400 <= i <= 2799:
        lis.append("orange")
 
    if 2800 <= i <= 3199:
        lis.append("red")
    if 3200 <= i:
        count = count + 1
 
mincase = len(set(lis))
 
if len(set(lis)) == 0:
    mincase = 1
else:
    mincase = len(set(lis))
 
maxcase = len(set(lis)) + count
 
print(mincase , '', maxcase)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<string>
#define N 1002
using namespace std;
bool vis[N];
int main()
{
	int n,k;
	int i;
	cin>>n>>k;
	int j;
	for(i=1;i<=k;i++)
	{
		int d;
		scanf("%d",&d);
		for(j=1;j<=d;j++)
		{
			int x;
			scanf("%d",&x);
			vis[x]=1;
		}
	}	
	int ans=0;
	for(i=1;i<=n;i++)
	{
		if(!vis[i])
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <valarray>
#include <iterator>
#include <stack>
#include <set>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <list>
#include <map>
#include <strstream>
#include <streambuf>
#include <string>
#include <sstream>
//#include "graph.cpp"

#define vi vector<int>
#define vii vector< pair<int,int> >
#define last(arr) arr.size()-a
#define loop(i,n) for(ll i=0 ; i<n ; ++i)
#define all(v) ((v).begin()),((v).end())
#define pb push_back
#define ll long long
#define iteloop(type,data,name,it) for(type<data>::iterator it=name.begin() ;it!=name.end() ; ++it)

using namespace std;

int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int maximum=max(a,max(b,c));
    int sum=a+b+c-maximum;
    while(k--){
        maximum*=2;
    }
    cout<<sum+maximum<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MM 200100
#define MN 15
int M,N;
int w[MM],t[MM];
int c[MN],b[MN];
int dp[1<<(MN)];
bool used[1<<(MN)];
int pre[MN][MM];
int preculc(int stage,int pos){
	int l = pos-1,r = M+1;
	while(r-l>1){
		int mid = (l+r)/2;
		if(w[mid]-w[pos-1]<=c[stage]&&t[mid]-t[pos-1]<=b[stage]){
			//printf("mid %d\n",mid);
			//printf("%d %d %d %d\n",w[mid]-w[pos-1],c[stage],t[mid]-t[pos-1],b[stage]);
			l=mid;
		}
		else r = mid;
	}
	pre[stage][pos]=l;
	//cout << stage << ' ' << pos << ' ' << l << endl;
}
int main(){
	scanf("%d %d",&M,&N);
	for(int i=1;i<=M;i++)scanf("%d %d",&w[i],&t[i]);
	for(int i=1;i<M;i++)w[i+1]+=w[i];
	for(int i=1;i<M;i++)t[i+1]+=t[i];
	for(int i=0;i<N;i++)scanf("%d %d",&c[i],&b[i]);
	for(int i=0;i<N;i++){
		for(int j=1;j<=M;j++)preculc(i,j);
	}
	memset(dp,-1,sizeof(dp));
	//cout << pre[0][1] << endl;
	dp[(1<<N)-1]=0;
	queue<int> q;
	q.push((1<<N)-1);
	int ans = 0;
	while(!q.empty()){
		int S = q.front();
		q.pop();
		if(used[S])continue;
		//cout << S << endl;
		used[S]=true;
		for(int i=0;i<N;i++){
			if((S>>i)&1){
				int T = S-(1<<i);
				//printf("i %d S %d dp[S]+1 %d\n",i,S,dp[S]+1);
				dp[T]=max(dp[T],pre[i][dp[S]+1]);
				ans = max(ans,dp[T]);
				q.push(T);
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 16844
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP (i,m,n) for(int i=( int)m ; i < (int ) n ; ++i )
#define rep (i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

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



int main() {
	int k, a, b;
	cin >> k >> a >> b;
	for (int i = a; i <= b; i++) {
		if (i%k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  if (n % 1000) {
    cout << 1000 - n % 1000 << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}


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

int bubbleSort(int A[], int N) {
        int sw = 0;
        bool flag = 1;
        while ( flag ) {
                flag = 0;
                for ( int j = N - 1; j > 0; j-- ) {
                        if ( A[j] < A[j - 1] ) {
                                swap(A[j], A[j - 1]);
                                flag = 1;
                                sw++;
                        }
                }
        }
        return sw;
}

int main() {
        int A[100], N, sw;

        cin >> N;
        for ( int i = 0; i < N; i++ ) cin >> A[i];

        sw = bubbleSort(A, N);

        for ( int i = 0; i < N; i++ ) {
                if (i) cout << " ";
                cout << A[i];
        }
        cout << endl;
        cout << sw << endl;

        return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
using namespace std; //std::の省略のため
using ll = long long;

ll MOD = 1000000007;

int main()
{
    string s;
    cin >> s;

    ll sum = 0;
    ll ans = 0;

    ll n = s.size();

    for(ll i=0; i<n; i++){
        for(ll j=i; j<n; j++){
            if(s[j] == 'R'){
                sum++;
            }
            else{
                break;
            }
        }

        if(sum > ans){
            ans = sum;
        }
        sum = 0;
    }
    

    cout << ans << endl;

}


Measured memory_bytes: 3624
# integrotS
N, K = map(int, input().split())
S = format(K, "0%ib" % 30)

d = []
use = []
for i in range(N):
    x, y = map(int, input().split())
    d.append((x, y))
for i in range(30):
    if S[i] == "1":
        que = S[:i] + "0" + "1"*(29-i)
        use.append(int(que, 2))

use.append(int(S, 2))
use = set(use)
ans = 0

for some in use:
    s=0
    for num, value in d:
        if num|some == some:
            s += value
    ans = max(s, ans)
print(ans)

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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

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

int c = 0;

void bubbleSort(vi& A, int N)
{
    bool frag = true;
    while(frag)
    {
        frag = false;
        for(int j = N-1; j > 0; j--)
        {
            if(A[j] < A[j-1]) 
            {
                swap(A[j], A[j-1]);
                c++;
                frag = true;
            }
        }
    }
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N; cin >> N;
    vi A(N); REP(i, N) cin >> A[i];
    bubbleSort(A, N);
    cout << A[0];
    for(int i = 1; i < N; i++) cout << " " << A[i];
    cout << endl;
    cout << c << endl;
}


Measured memory_bytes: 3236
//#pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(int i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(int i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(int i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    #define mp make_pair
    #define pb push_back
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 100224;

    ll a[5];
    
    void solve(){
      rep(i,3){
        ll x,y;
        cin>>x>>y;
        a[x]++;
        a[y]++;
      }
      sort(a,a+5);
      if(a[1] == 1 && a[2] ==1 && a[3]== 2 &&  a[4] ==2) cout<<"YES"<<endl;
      else cout<<"NO"<<endl;
    } 
    
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      solve();
      return 0;
    } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;
ll a[maxn],sum[maxn];int cnt=0;
map<ll,int> mp;
vector<int> vec[maxn];
int main()
{
	int n;ll k;scanf("%d%lld",&n,&k);ll ans=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		a[i]--;
		a[i]=a[i]%k;
		sum[i]=sum[i-1]+a[i];
		sum[i]%=k;
		if(!mp.count(sum[i])) mp[sum[i]]=++cnt;//,cout<<sum[i]<<" "<<cnt<<endl;
		if(sum[i]==0&&i<k) ans++;
		vec[mp[sum[i]]].push_back(i);
	}
	//cout<<cnt<<endl;
	for(int i=1;i<=cnt;i++)
	{
		int sz=vec[i].size();
		for(int j=0;j<sz;j++)
		{
			int pos=lower_bound(vec[i].begin(),vec[i].end(),vec[i][j]+k-1)-vec[i].begin();
			//cout<<i<<" "<<j<<" "<<pos<<" "<<sz<<endl;
			if(pos==sz)
			{
				ans+=pos-1-j;
			}
			else if(vec[i][pos]==vec[i][j]+k-1)
			{
				ans+=pos-j;
			}
			else ans+=(pos-1-j);
			//cout<<ans<<endl;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 26752
N = int(input())
v = [i for i in map(int,input().split())]
import heapq
heapq.heapify(v)

while len(v) >= 2:
  a = heapq.heappop(v)
  b = heapq.heappop(v)
  heapq.heappush(v,(a+b)/2)
  
print(heapq.heappop(v))

Measured memory_bytes: 3060
import collections
import math
import operator as op
from functools import reduce

import numpy as np
import math
import bisect


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def main():
    A, B = list(map(int, input().split()))

    # common_divisors = []
    # if A > B:
    #     A, B = B, A
    # for i in range(1, int(A**0.5)+1):
    #     if A % i == 0 and B % i == 0:
    #         common_divisors.append(i)
    #         j = A // i
    #         if j != i and B % j == 0:
    #             common_divisors.append(j)
    # common_divisors
    # print(common_divisors)

    fact_A = {i: cnt for i, cnt in factorization(A)}
    fact_B = {i: cnt for i, cnt in factorization(B)}
    fact_A.update({1:1})
    fact_B.update({1:1})

    ans = 0
    for k in fact_A.keys():
        if k in fact_B:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 12492
#include <stdio.h>
int main(void){
    long long int X,Y;
    scanf("%lld %lld",&X,&Y);
    int ans=1;
    while(1){
        X*=2;
        if(X>Y)break;
        else ans++;
    }
    printf("%d",ans);
    return 0;
    
}


Measured memory_bytes: 128
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

long  long MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    map<int, int>mp;

    for (int i = 2; i <= N; i++) {
        int x = i, a = 2;
        while (a*a<=x) {
            if (x%a == 0) {
                mp[a]++;
                x /= a;
            }
            else a++;
        }
        mp[x]++;
    }

    long long ans = 1;
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        ans = (ans*(itr->second + 1)) % MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import numpy as np

h, w = map(int, input().strip().split())
table = np.array([list(input().strip()) for _ in range(h)])


def compress_row(table):
    new_table = []
    compressed = False
    for row in table:
        if all([c == '.' for c in row]):
            compressed = True
            continue
        else:
            new_table.append(row)

    return compressed, np.array(new_table)


def compress_col(table):
    tr_table = table.T
    compressed, new_tr_table = compress_row(tr_table)
    return compressed, new_tr_table.T


while True:
    row_compressed, table = compress_row(table)
    col_compressed, table = compress_col(table)

    if (not row_compressed) and (not col_compressed):
        break

for row in table:
    print(''.join(row))


Measured memory_bytes: 12324
#include <iostream>
#include <string>

int main(){
    std::string a, b, c;
    std::cin >> a >> b >> c;

    if(*(a.end() - 1) == *b.begin() && *(b.end() - 1) == *c.begin()){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }
}


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

using namespace std;
typedef long long int lli;

#define all(arr) arr.begin(),arr.end()
#define f first
#define s second
#define debug1(x) cout<<x<<"\n"
#define debug2(x,y) cout<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define nl cout<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cout<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define MOD 1000000007

template <typename T>
void input(vector<T> &arr,lli n) {
  T temp;
  for(lli i=0;i<n;i++) cin>>temp, arr.push_back(temp);
}

template <typename T>
void output(vector<T> arr) {
  for(auto x:arr) cout<<x<<" ";
  cout<<endl;
}


template <typename T>
void input_set(set<T> &arr,lli n) {
  T temp;
  for(lli i=0;i<n;i++) cin>>temp, arr.insert(temp);
}

lli mul(lli a, lli b) {
  return (a%MOD*b%MOD)%MOD;
}

lli power(lli num,lli base) {
  lli ans = 1;
  while(base>0) {
    if(base&1)
      ans = mul(ans, num);

    num = mul(num, num);
    base >>= 1;
  }

  return ans;
}

lli ceil(lli a, lli d) {
  if(a%d)
    return a/d + 1;
  return a/d;
}

void solve() {
  lli a, b, c, d;
  cin >> a >> b >> c >> d;
  lli total = b-a+1;
  lli factor_c = 0, factor_d = 0, factor_cd = 0;
  if(b-ceil(a,c)*c >= 0) {
    factor_c = (b-ceil(a, c)*c)/c + 1;
  }

  if((b-ceil(a, d)*d) >= 0) {
    factor_d = (b-ceil(a, d)*d)/d + 1;
  }

  c=c*d/__gcd(c, d);

  if(b-ceil(a,c)*c >= 0) {
    factor_cd = (b-ceil(a, c)*c)/c + 1;
  }

  factor_c = max(factor_c, 0LL);
  factor_d = max(factor_d, 0LL);
  factor_cd = max(factor_cd, 0LL);

  //cout << factor_c << " " << factor_d << " " << factor_cd << endl;
  cout << total - factor_c - factor_d + factor_cd << endl;
  
}

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

  lli testcases=1;
  while(testcases--) {
    solve();
  }
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define plint pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int gcd(int a, int b) {
  if(a < b) return gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main(){
    int k,res=0;
    cin >> k;
    FOR(a,1,k+1){
        FOR(b,1,k+1){
            FOR(c,1,k+1){
                res += gcd(gcd(a,b),c);
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    vector<int> a(3);
    rep(i,3) cin >> a[i];
    sort(a.begin(), a.end());
    int ans = 0;
    rep(i,2){
        ans += a[i+1] - a[i];
    }
    cout << ans<< endl;
    return 0;
}

Measured memory_bytes: 3688
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    int a,b,c;
    cin >> a >> b >> c;
    // 出力
    if(a+b>=c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N, D, X;
  cin >> N >> D >> X;

  vector<long> A(N);
  rep (i, N) cin >> A[i];

  long ans = X;
  rep (i, N) ans += (D - 1) / A[i] + 1;

  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = int(1e9);
typedef long long int ll;

int main(){
    int K, N;cin >> K >> N;
    int A[N];rep(i, N)cin >> A[i];
    int maxv = K - A[N - 1] + A[0];
    for(int i = 0;i < N - 1;++i){
        maxv = max(A[i + 1] - A[i], maxv);
    }
    cout << K - maxv;
}


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

ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}
ll mpower(ll a,ll b,ll c){
  int z;
  if(b==0){
    z=1;
    z%=c;
    return z;
  }
  if(b==1){
    z=a;
    z%=c;
    return z;
  }
  else{
    return (((mpower(a,b/2,c))*(mpower(a,b/2,c))%c)*mpower(a,b%2,c)%c);
  }
}
 
int main(){
  int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;
  ll ans=0;
  ll veca[a],vecb[b],vecc[c];
  for(int i=0;i<a;i++){
    cin>>veca[i];
  }
  for(int i=0;i<b;i++){
    cin>>vecb[i];
  }
  for(int i=0;i<c;i++){
    cin>>vecc[i];
  }
  sort(veca,veca+a);
  reverse(veca,veca+a);
  sort(vecb,vecb+b);
  reverse(vecb,vecb+b);
  sort(vecc,vecc+c);
  reverse(vecc,vecc+c);
  
  int p=x-1,q=y-1;
  ll amin=veca[p],bmin=vecb[q];
  for(int i=0;i<c;i++){
    if(vecc[i]<amin&&vecc[i]<bmin){
      break;
    }
    if(p<0&&q<0){
      break;
    }
    //cout<<amin<<" "<<bmin<<endl;
    
    if(p>=0&&q>=0){
      if(bmin<amin){
        if(vecc[i]>bmin){
          vecb[q]=vecc[i];
          q--;
          if(q>=0){
            bmin=vecb[q];
          }
          continue;
        }
      }
      if(vecc[i]>amin){
        veca[p]=vecc[i];
        p--;
        if(p>=0){
          amin=veca[p];
        }
      }
      continue;
    }
    if(p>=0){
      if(vecc[i]>amin){
        veca[p]=vecc[i];
        p--;
        if(p>=0){
          amin=veca[p];
        }
      }
      continue;
    }
    if(q>=0){
      if(vecc[i]>bmin){
        vecb[q]=vecc[i];
        q--;
        if(q>=0){
          bmin=vecb[q];
        }
      }
      continue;
    }
  }
  
  for(int i=0;i<x;i++){
    ans+=veca[i];
    //cout<<veca[i]<<" ";
  }
  for(int j=0;j<y;j++){
    ans+=vecb[j];
    //cout<<vecb[j]<<" ";
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
# include <iostream>
# include <cstdio>
# include <algorithm>
# include <queue>
# include <cstring>
# include <stack>
using namespace std;

priority_queue<long long> q;
long long A[300000];
int main(void)
{
    // freopen("aaa.in","r",stdin);
    int n;
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        scanf("%lld",&A[i]);
    }
    long long ans = 0;
    sort(A+1,A+n+1);
    q.push(A[n]);
    for (int i=n-1;i>=1;i--)
    {
        int x = q.top();
        ans+=x;
        // cout<<x<<endl;
        q.pop();
        q.push(A[i]);
        q.push(A[i]);
    }
    printf("%lld\n",ans);

    return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    
    int x = 1000 - (n % 1000);
    if (x == 1000)
        cout << 0 << endl;
    else
        cout << x << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N, M, ans;

int main()
{
    cin >> N >> M;
    vector<pair<int, int>> p;
    for (int i = 0; i < N; i++)
    {
        int a, b;
        cin >> a >> b;
        p.emplace_back(a, b);
    }
    sort(p.begin(), p.end());
    int index = 0, now = 0;
    priority_queue<int> value;
    while (now <= M)
    {
        while (index < N && p[index].first <= now)
        {
            value.push(p[index].second);
            index++;
        }
        if (!value.empty())
        {
            int v = value.top();
            value.pop();
            ans += v;
        }
        now++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1908
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

#define LINE_BUF_SIZE 256

int main(){

    int i,j,k;
    int A,B,X,D;
    char line[LINE_BUF_SIZE];

    fgets(line,sizeof(line),stdin);
    sscanf(line,"%d %d %d", &A,&B,&X);

    if(X >= A){
        if(A+B>=X){
            printf("YES");
            return 0;
        }
        else{
            printf("NO");
            return 0;
        }
    }

    else printf("NO");

    return 0;

}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

ll vs[200000+10];
ll ss[200000+10];

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    scanf("%lld", &vs[i]);
    ss[i+1] = ss[i] + vs[i];
  }
  ll sum = ss[n];
  ll res = 1e18;
  for(int i = 1; i < n; ++i) {
    ll x = ss[i];
    ll y = sum-x;
    res = min(res, abs(x-y));
  }
  printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
ll a[200005];
int main(){
    ll n;   
    boost;
    cin>>n;
    ll s=0;
    for(ll i=1;i<=n;i++)cin>>a[i],s+=a[i];
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	ll ans=a[1];
	ll num=n-2;
	for(ll i=2;i<=n;i++){
		
		if(num<=0)break;
		
		if(num<2)ans+=a[i],num--;
		else ans+=2*a[i],num-=2;
		
		
	}
	cout<<ans;
		
    
			
}

Measured memory_bytes: 5220
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#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 VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int N,tem,Alice=0,Bob=0;
	vector<int> ve;
	
	cin>>N;
	REP(i,N){
		cin>>tem;
		ve.pb(tem);
	}
	DVSORT(ve);

	RREP(i,N){
		if(i%2==0) Alice+=ve[i];
		else Bob+=ve[i];
	}
	print(Alice-Bob);
	return 0;
}


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

using namespace std;

int main(){
  string s;
  int sum  = 0;
  bool f = true;
  while(cin >> s){
    f = true;
    for(int i = 0;i < s.size()/2;i++){
      if(s[i] != s[s.size()-1-i]){
	f = false;
	//break;
      }
      
    }
    if(f)
	sum++;
    
    
    //cout << sum << endl;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3020
#include<bits/stdc++.h>
using namespace std;
struct kkk{
  int num,i;
};
bool cmp(kkk a,kkk b){
  return a.num>b.num;
}
int main()
{
  int n;
  cin>>n;
  kkk a[n];
  for(int i=0;i<n;i++){
    cin>>a[i].num;
    a[i].i=i;
  }
  sort(a,a+n,cmp);
  for(int i=0;i<n;i++){
    if(i==a[0].i) cout<<a[1].num<<'\n';
    else cout<<a[0].num<<'\n';
  }
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    sort(v.begin(),v.end());
    int l = v[0];
    int r = v[n-1];
    int ans = 1000000000;
    for(int i = l; i <= r; i++){
        int sum = 0;
        rep(j,n){
            sum += (v[j] - i) * (v[j] - i);
        }
        ans = min(ans,sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
long long a,b,c;
inline bool check(){
	if(c<=a || c<=b)return false;
	__int128 x=c-a-b,y=4*a*b;
	if(x<0)return false;
	return y<x*x;
}
int main(){
	scanf("%lld%lld%lld",&a,&b,&c);
	puts(check()?"Yes":"No");
	return 0;
}

Measured memory_bytes: 128
R, G, B, N = map(int, input().split())
ans = 0
for i in range(N+1):
    if i % R:
        continue
    for j in range(0, N-i+1):
        if j % G:
            continue
        if (N - i - j) % B:
            continue
        ans += 1
print(ans)

Measured memory_bytes: 40560
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/

signed main(){
	int n,m,x;
	cin>>n>>m>>x;
	vi c(n);
	vector<vi> a(n,vi(m));
	rep(i,n){
		cin>>c[i];
		rep(j,m)cin>>a[i][j];
	}

	int ans=INF;

	rep(bit,1<<n){
		vi rikai(m,0);
		int sum=0;
		rep(i,n)if(bit&(1<<i)){
			sum+=c[i];
			rep(j,m){
				rikai[j]+=a[i][j];
			}
		}
		bool ok=1;
		rep(j,m) if(rikai[j]<x) ok=0;
		if(ok) chmin(ans,sum);
	}
	if(ans<INF) cout<<ans<<endl;
	else cout<<-1<<endl;
	return 0;
}



Measured memory_bytes: 3632
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		new Main().solve();
	}
	int a,b,c;
	void solve(){
		Scanner sc=new Scanner(System.in);
		a=sc.nextInt();
		b=sc.nextInt();
		c=sc.nextInt();
		
		if(a==b && b==c && a%2==0){
			System.out.println(-1);
			return;
		}
		int count=0;
		while(a%2==0 && b%2==0 && c%2==0){
			int tempa=a;
			int tempb=b;
			int tempc=c;
			a=(tempb+tempc)/2;
			b=(tempa+tempc)/2;
			c=(tempa+tempb)/2;
			count++;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 23764
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstring>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define M 1000001
#define L 14

char H[M][L];

int getChar(char ch) {
  if (ch == 'A')
    return 1;
  else if (ch == 'C')
    return 2;
  else if (ch == 'G')
    return 3;
  else if (ch == 'T')
    return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]) {
  long long sum = 0, p = 1, i;
  for (i = 0; i < strlen(str); i++) {
    sum += p * (getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return key % M; }

int find(char str[]) {
  ll key, i, h;
  key = getKey(str);
  for (i = 0;; ++i) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0)
      return 1;
    else if (strlen(H[h]) == 0)
      return 0;
  }
}

int insert(char str[]) {
  ll key, i, h;
  key = getKey(str);
  for (i = 0;; ++i) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0)
      return 1;
    else if (strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
}

int main() {
  int i, n;
  char str[L], com[9];
  for (i = 0; i < M; i++)
    H[i][0] = '\0';

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%s %s", com, str);

    if (com[0] == 'i') {
      insert(str);
    } else {
      if (find(str)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }

  return 0;
}



Measured memory_bytes: 16796
#include <stdio.h>

int main()
{
	int x[6];
	int i,j;
	int tmp;
	
	for(i=0;i<5;i++){
		scanf("%d",&x[i]);
	}

	for(i=0;i<4;i++){
		for(j=i+1;j<5;j++){
			if(x[i]<x[j]){
				tmp=x[i];
				x[i]=x[j];
				x[j]=tmp;
			}
		}
	}
	for(i=0;i<4;i++){
		printf("%d ",x[i]);
	}
	printf("%d\n",x[i]);
	return 0;
}

Measured memory_bytes: 0
using System;
namespace B_009_52
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            new Logic_A().Start();//

        }

  
        public class Logic_A
        {
            public void Start()
            {
                var str = Console.ReadLine().Split(' ');
                var A = Convert.ToInt32(str[0]);
                var B = Convert.ToInt32(str[1]);
                var C = Convert.ToInt32(str[2]);
                var D = Convert.ToInt32(str[3]);
                Console.WriteLine(Math.Max(A * B, C * D));
            }
        }
    }
}

Measured memory_bytes: 13268
# -*- coding: utf-8 -*-
"""
Created on Sun May 19 16:57:17 2019

@author: Yamazaki Kenichi
"""

N, X = map(int,input().split())

dp = [[1,1] for i in range(N+1)]
for i in range(1,N+1):
    dp[i][0] = dp[i-1][0]*2 + 1
    dp[i][1] = dp[i-1][1]*2 + 3

ans = 0
for i in range(2,N+2):
    if X - (dp[-i][1] + 2) >= 0:
        ans += dp[-i][0] + 1
        X -= (dp[-i][1] + 2)
#        print(ans,X,dp[-i])
    else:
        X -= 1
#        print(ans,X,dp[-i])
    if i == N+1 and X >= 1:
        ans += 1
#        print(ans,X,dp[-i])
print(ans)

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

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define MAXN 1100013
#define LLINF 2696969696969696969

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

int N;
ll C;
ll arr[MAXN];
ll dp[MAXN];
pll stor[MAXN << 1];

ll f(pll p, ll x)
{
	return p.fi * x + p.se;
}
void ins(int w, int L, int R, pll p)
{
	if (L == R)
	{
		if (f(p, L) <= f(stor[w], L))
		{
			stor[w] = p;
		}
		return;
	}
	int mid = (L + R) >> 1;
	bool b = f(p, mid) < f(stor[w], mid);
	if (b)
	{
		swap(stor[w], p);
	}
	if (f(p, L) < f(stor[w], L))
	{
		ins(w << 1, L, mid, p);
	}
	else
	{
		ins(w << 1 | 1, mid + 1, R, p);
	}
}
ll query(int w, int L, int R, int x)
{
	ll res = f(stor[w], x);
	if (L == R)
	{
		return res;
	}
	int mid = (L + R) >> 1;
	if (x <= mid) ckmin(res, query(w << 1, L, mid, x));
	else ckmin(res, query(w << 1 | 1, mid + 1, R, x));
	return res;
}

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N >> C;
	FOR(i, 0, N)
	{
		cin >> arr[i];
	}
	FOR(i, 0, (MAXN << 1)) stor[i] = {0, LLINF};
	dp[0] = 0;
	FOR(i, 1, N)
	{
		ins(1, 0, 1000000, {-2 * arr[i - 1], dp[i - 1] + arr[i - 1] * arr[i - 1]});
		dp[i] = query(1, 0, 1000000, arr[i]) + arr[i] * arr[i] + C;
		// cerr << dp[i] << ' ';
	}
	// cerr << endl;
	cout << dp[N - 1] << '\n';
	return 0;
}


Measured memory_bytes: 41216
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
 
P = (A1 - B1) * T1
Q = (A2 - B2) * T2
if P > 0:
	P *= -1
	Q *= -1
 
if P + Q < 0:
	print(0)
elif P + Q == 0:
	print("infinity")
else:
	S = (-P) // (P + Q)
	T = (-P) % (P + Q)
	if T != 0:
		print(S * 2 + 1)
	else:
		print(S * 2)

Measured memory_bytes: 38384
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>

using namespace std;

int main()
{
	while (!feof(stdin))
	{
		int node[101];
		memset(node, 0, sizeof(node));
		node[1] = node[2] = 1;
		int a, b;
		a = -1;
		while (true)
		{
			scanf("%d %d", &a, &b);
			if (a == 0 && b == 0)
				break;
			else if (a == -1)
				goto End;
			++node[a];
			++node[b];
		}

		bool ok = true;
		for (int i = 1; i < 101; ++i)
		{
			if (node[i] & 1)
			{
				ok = false;
				break;
			}
		}
		if (ok)
			puts("OK");
		else
			puts("NG");
	}
End:
	return 0;
}

Measured memory_bytes: 0
/**
 *    author:  FromDihPout
 *    created: 2020-08-10
**/

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

const int INF = 2e9;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    const int DAYS = 10;
    int n;
    cin >> n;
    vector<int> a(n);
    vector<vector<int>> p(n, vector<int> (DAYS + 1));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < DAYS; j++) {
            int x;
            cin >> x;
            a[i] *= 2;
            a[i] += x;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < DAYS + 1; j++) {
            cin >> p[i][j];
        }
    }
    
    int ans = -INF;
    for (int open = 1; open < 1<<DAYS; open++) {
        int profit = 0;
        for (int i = 0; i < n; i++) {
            int cnt = 0;
            for (int d = 0; d < DAYS; d++) {
                if ((1<<d) & open & a[i]) {
                    cnt++;
                }
            }
            profit += p[i][cnt];
        }
        ans = max(ans, profit);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Main {
public:
    Main() {
        int H, W, K;
        cin >> H >> W >> K;
        vector<string> s(H);
        vector<vector<int>> a(H, vector<int>(W));
        int max_a = 0;
        int up = -1;
        vector<int> non_sharp(H);
        REP(i, H) {
            cin >> s[i];
            if (s[i] == string(W, '.')) {
                non_sharp[i] = 1;
                continue;
            }
            if (up < 0) up = i;
            int cnt = 0;
            REP(j, W) {
                cnt += s[i][j] == '#';
                a[i][j] = max_a + max(1, cnt);
            }
            max_a += cnt;
        }
        REP(i, up) {
            a[i] = a[up];
        }
        FOR(i, up + 1, H) {
            if (non_sharp[i]) {
                a[i] = a[i - 1];
            }
        }
        REP(i, H) {
            REP(j, W) {
                cout << a[i][j] << " ";
            }
            cout << endl;
        }
    }
};

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

    Main ans;

    return 0;
}


Measured memory_bytes: 4092