akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

int syakutori(const vector<int>& a, int x) {
    const int n = a.size();
    int count = 0;

    for (int l = 0, r = 0, sum = 0; l < n; sum -= a[l++]) {
        for (; r < n && sum + a[r] <= x; sum += a[r++])
            ;

        count += r - l;
    }
    return count;
}

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

    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> x(q);
    for (int i = 0; i < q; i++) cin >> x[i];

    for (int i = 0; i < q; i++) {
        cout << syakutori(a, x[i]) << endl;
    }
}



Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
const int mod = (int)1e9 + 7;
const int maxN = 2e5+5;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int n;
	cin >> n;
	vector<int> arr(n);
	for(int i=0; i<n; i++) cin >> arr[i];
	int g1 = arr[0];
	for(int i=1; i<n; i++){
		g1 = __gcd(g1, arr[i]);
	}
	if(g1 != 1){
		cout << "not coprime";
		return 0;
	}
	set<int> all;
	int c = 0;
	for(int i: arr){
		int tmp = i;
		unordered_set<int> st;
		while(tmp%2==0){
			tmp/=2;
			st.insert(2);
		}
		for(int j=3; j*j<= tmp; j+=2){
			while(tmp%j==0){
				st.insert(j);
				tmp/=j;
			}
		}
		if(tmp>1) st.insert(tmp);
		c+=st.size();
		for(int k:st){
			all.insert(k);
		}
	}
	if(all.size()==c) {
		cout << "pairwise coprime";
		return 0;
	}
	cout << "setwise coprime";
	//cout << "Hello World\n";
	return 0;
}

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

using namespace std;

#define INF 1000000007
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define maxn 15

signed main()
{
    int N, M;
    cin >> N >> M;
    int L, R;
    int Min = INF;
    int Max = 0;
    rep(i, M)
    {
        cin >> L >> R;
        Min = min(R, Min);
        Max = max(L, Max);
    }
    if ((Min - Max + 1) < 0)
    {
        cout << "0" << endl;
        return 0;
    }
    cout << Min - Max + 1 << endl;
}


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

int partition(int *, int, int);

int main()
{
  int a, i, n;
  int *A;
  
  scanf("%d",&n);

  A = (int *)malloc(sizeof(int)*n+1);
  
  for( i=0 ; i<n ; i++ )
    scanf("%d",&A[i]);

  a = partition(&A[0],0,n-1);

  for( i=0 ; i<n-1 ; i++ ){
    if(a==i) printf("[%d] ",A[i]);
    else printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);

  free(A);

  return 0;
}

int partition(int *A, int p, int r)
{
  int x, str, i, j;
  x = A[r];
  i = p-1;
  for( j=p ; j<=r-1 ; j++ ){
    if(A[j]<=x){
      i++;
      str = A[i];
      A[i] = A[j];
      A[j] = str;
    }
  }
  A[r] = A[i+1];
  A[i+1] = x;
  return i+1;
}

Measured memory_bytes: 888
#include <iostream>
#include <queue>
#define int long long

using namespace std;

signed main() {
	int k;
	cin >> k;
	
	queue<int> q;
	for (int i = 1; i <= 9; i++) q.push(i);
	while (!q.empty()) {
		int x = q.front(); q.pop(); k--;
		if (k == 0) {
			cout << x << '\n';
			break;
		}
		
		for (int y = (x % 10) - 1; y <= (x % 10) + 1; y++) {
			if (y < 0 || y > 9) continue;
			q.push(x * 10 + y);
		}
	}
	
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main() {
	int n;cin>>n;
	vector<pair<long long,int>> x(n),y(n),r(n),u(n),d(n),l(n);
	for(int i=0;i<n;i++){
		cin>>x[i].first>>y[i].first;
		x[i].second=y[i].second=i;
	}
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	l[x[0].second].second=-1;
	r[x[n-1].second].second=-1;
	u[y[n-1].second].second=-1;
	d[y[0].second].second=-1;
	for(int i=0;i<n-1;i++){
		r[x[i].second].second=x[i+1].second;
		r[x[i].second].first=x[i+1].first-x[i].first;
		l[x[i+1].second].second=x[i].second;
		l[x[i+1].second].first=x[i+1].first-x[i].first;
		u[y[i].second].second=y[i+1].second;
		u[y[i].second].first=y[i+1].first-y[i].first;
		d[y[i+1].second].second=y[i].second;
		d[y[i+1].second].first=y[i+1].first-y[i].first;

	}
	long long ans=0;
	priority_queue<pair<long long,int>,vector<pair<long long,int>>,greater<pair<long long,int>>> q;
	pair<long long,int> p,pt;
	vector<int> use(n,1);
	use[0]=0;
	if(r[0].second!=-1){
		q.push(r[0]);
	}
	if(l[0].second!=-1){
		q.push(l[0]);
	}
	if(u[0].second!=-1){
		q.push(u[0]);
	}
	if(d[0].second!=-1){
		q.push(d[0]);
	}
//	for(int i=0;i<n;i++){
//		cout<<r[i].first<<' '<<r[i].second<<endl;
//	}
	for(int i=1;i<n;i++){
		while(1){
			pt=q.top();
			q.pop();
			if(use[pt.second]){
				use[pt.second]=0;
				break;
			}
		}
		ans+=pt.first;
		if(r[pt.second].second!=-1){
			q.push(r[pt.second]);
		}
		if(l[pt.second].second!=-1){
			q.push(l[pt.second]);
		}
		if(u[pt.second].second!=-1){
			q.push(u[pt.second]);
		}
		if(d[pt.second].second!=-1){
			q.push(d[pt.second]);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

static const int MAX = 100000;
static const int NIL = -1;
int n;
int color[MAX];
vector<int> G[MAX];


void dfs(int r,int c){
    stack<int>S;
    S.push(r);
    color[r]=c;
    while(!S.empty()){
        int u = S.top();
        S.pop();
        for(int i = 0;i<G[u].size();i++){
            int v = G[u][i];
            if(color[v]==NIL){
                color[v] = c;
                S.push(v);
            }
        }
    }
}
void assignColor(){
    int id = 1;
    for (int i = 0; i < n; i++)
    {
        color[i] = NIL;     
    }
    for (int u = 0; u < n; u++)
    {
        if(color[u]==NIL){
            dfs(u,id++);    
        }
    }
}

int main(){
    int s,t,m,q;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    assignColor();
    cin>>q;
    for (int  i = 0; i < q; i++)
    {
        cin >> s >>  t;
        if(color[s] == color[t]){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 8920
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i < n; i ++)
#define _min(x, y) x = min(x, y)
using namespace std;


int main() {
  int n, T;
  cin >> n >> T;
  int best = 10000;
  rep(i, n) {
    int c, t; cin >> c >> t;
    if (t <= T) {
      _min(best, c);
    }
  }
  if (best == 10000) {
    cout << "TLE" << endl;
  } else {
    cout << best << endl;
  }
  return 0;
}


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

using namespace std;
#define ll long long
int main(){
    int ans=0;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin >>a;
        ans+=a-1;
    }
    cout <<ans<<endl;
    return 0;
}

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

struct Edge {
  int id, to;
};

vector<vector<Edge>> graph;
vector<int> k;

void dfs(int node, int color = -1, int parent = -1) {
  int paint = 1;
  rep(i, graph[node].size()) {
    Edge edge = graph[node][i];
    int child = edge.to;
    if (child == parent) continue;
    if (paint == color) ++paint;
    k[edge.id] = paint++;
    dfs(child, k[edge.id], node);
  }
}

int main() {
  int n;
  cin >> n;
  graph.resize(n);
  k.resize(n - 1);
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    graph[a].push_back((Edge){i, b});
    graph[b].push_back((Edge){i, a});
  }
  dfs(0);
  int maxv = 0;
  rep(i, k.size()) { maxv = max(maxv, k[i]); }
  cout << maxv << endl;
  rep(i, k.size()) { cout << k[i] << endl; }
}

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

int main(){
  int N,K,count = 0;
  cin >> N >> K;
  vector<int> h(N);
  for(int i = 0; i < N; i++){
    cin >> h[i];
    if(h[i] >= K) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}


int main(){
	int n;
	cin>>n;
	ll lcm = 1;
	rep(i, n){
		ll x;
		cin>>x;
		ll g = __gcd(lcm, x);
		lcm *= x/g;
	}
	cout<<lcm<<endl;
	return 0;
}


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

string f(char* s, int n)
{
    if((n%2) == 0)
    {
        for(int i=0; i<(n/2); i++)
        {
            if(s[i] != s[n/2 + i]) return "No";
        }
    }
    else{
        return "No";
    }
    return "Yes";
}
 
int main(){
    int n;
    cin >> n;
    char s[n];
    cin >> s;
    cout << f(s,n);

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    char str[100];
    stack <int > S;
    
    while( scanf("%s", str)!= EOF )
    {
        if( isdigit ( str[0] ) )
            S.push( atoi(str) );
        else if ( str[0] == '+' )
        {
            int a=S.top();
            S.pop();
            int b=S.top();
            S.pop();
            S.push( a+b );
        }
        else if( str[0] == '-' )
        {
            int b=S.top();
            S.pop();
            int a=S.top();
            S.pop();
            S.push(a-b);
        }
        else if( str[0] == '*' )
        {
            int a=S.top();
            S.pop();
            int b=S.top();
            S.pop();
            S.push(a*b);
        }
    }
    cout << S.top() <<endl;
    return 0;
}

Measured memory_bytes: 3284
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>

using MyTuple = std::tuple<long long, long long, long long>;
using MyVect = std::vector<MyTuple>;

int main()
{
	int n, m;
	std::cin >> n >> m;
	MyVect v[8];

	for ( int i = 0; i < n; i++ )
	{
		long long x, y, z;
		std::cin >> x >> y >> z;
		v[0].emplace_back( std::make_tuple( x, y, z ) );
	}

	// 正負それぞれで絶対値の大きさを決めるため、全8パターン分のvectorを用意する
	v[1] = v[2] = v[3] = v[4] = v[5] = v[6] = v[7] = v[0];

	// 1. ( +, +, + )
	std::sort( v[0].begin(), v[0].end(), []( MyTuple a, MyTuple b ) {
			return ( 
				std::get<0>( a ) + std::get<1>( a ) + std::get<2>( a )
				 <
				std::get<0>( b ) + std::get<1>( b ) + std::get<2>( b )
			);
		} );

	// 2. ( +, +, - )
	std::sort( v[1].begin(), v[1].end(), []( MyTuple a, MyTuple b ) {
			return ( 
				std::get<0>( a ) + std::get<1>( a ) - std::get<2>( a )
				 <
				std::get<0>( b ) + std::get<1>( b ) - std::get<2>( b )
			);
		} );

	// 3. ( +, -, + )
	std::sort( v[2].begin(), v[2].end(), []( MyTuple a, MyTuple b ) {
			return ( 
				std::get<0>( a ) - std::get<1>( a ) + std::get<2>( a )
				 <
				std::get<0>( b ) - std::get<1>( b ) + std::get<2>( b )
			);
		} );

	// 4. ( +, -, - )
	std::sort( v[3].begin(), v[3].end(), []( MyTuple a, MyTuple b ) {
			return ( 
				std::get<0>( a ) - std::get<1>( a ) - std::get<2>( a )
				 <
				std::get<0>( b ) - std::get<1>( b ) - std::get<2>( b )
			);
		} );

	// 5. ( -, +, + )
	std::sort( v[4].begin(), v[4].end(), []( MyTuple a, MyTuple b ) {
			return ( 
				std::get<1>( a ) + std::get<2>( a ) - std::get<0>( a )
				 <
				std::get<1>( b ) + std::get<2>( b ) - std::get<0>( b )
			);
		} );

	// 6. ( -, +, - )
	std::sort( v[5].begin(), v[5].end(), []( MyTuple a, MyTuple b ) {
			return ( 
				std::get<1>( a ) - std::get<2>( a ) - std::get<0>( a )
				 <
				std::get<1>( b ) - std::get<2>( b ) - std::get<0>( b )
			);
		} );

	// 7. ( -, -, + )
	std::sort( v[5].begin(), v[5].end(), []( MyTuple a, MyTuple b ) {
			return ( 
				std::get<2>( a ) - std::get<0>( a ) - std::get<1>( a )
				 <
				std::get<2>( b ) - std::get<0>( b ) - std::get<1>( b )
			);
		} );

	// 8. ( -, -, - )
	std::sort( v[5].begin(), v[5].end(), []( MyTuple a, MyTuple b ) {
			return ( 
				-std::get<0>( a ) - std::get<1>( a ) - std::get<2>( a )
				 <
				-std::get<0>( b ) - std::get<1>( b ) - std::get<2>( b )
			);
		} );

	//	合計の最大値を計算する
	long long total = 0;
	for ( int i = 0; i < 8; i++ )
	{
		long long tmp;

		long long t1 = 0, t2 = 0, t3 = 0;
		for ( int j = 0; j < m; j++ )		//	m個選ぶ
		{
			t1 += std::get<0>( v[i][j] );
			t2 += std::get<1>( v[i][j] );
			t3 += std::get<2>( v[i][j] );
		}

		auto myAbs = []( long long x ) {
				return ( x < 0 ? -x : x );
		};

		auto tmpAbs = myAbs( t1 ) + myAbs( t2 ) + myAbs( t3 );
		if ( tmpAbs > total )
		{
			// 計算結果が大きければ更新
			total = tmpAbs;
		}
	}

	std::cout << total << std::endl;

	return ( 0 );
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N;
    cin >> N;
    vector<int> b(N);
    vector<int> t(N);
    rep(i, N) cin >> b[i];
    rep(i, N) t[i] = (i+1);
    bool is = true;
    rep(i, N){
        if(b[i] > t[i]){
            is = false;
            break;
        }
    }
    if(!is){
        cout << -1 << endl;
        return 0;
    }
    vector<int> ans(N);
    rep(i, N){
        int len = N - i;
        vector<int> a(len);
        rep(j, len) a[j] = (j+1);
        for(int j = len-1; j >= 0; j--){
            if(a[j] == b[j]){
                ans.push_back(a[j]);
                b.erase(b.begin() + j);
                break;
            }
        }
    }
    reverse(ans.begin(), ans.end());
    rep(i, N){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3608
#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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define d long double
#define pii pair<int,int>
#define pb push_back
#define pf push_front
#define cases int t;cin>>t;while(t--)
#define N 200003
#define M 1003
//typedef tree<int,null_type,less_equal <int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;    //multiset
//typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>ordered_set;        //set
//*X.find_by_order("index")
//X.order_of_key("key")
int mod=1e9+7;
//int mod=998244353;

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

    int n;
    cin>>n;
    int sum[N]={0};
    int x,y,i,j;
    vector<int> a;  a.clear();
    cin>>x;
    a.pb(x);
    for(i=2;i<=n;++i)
    {
        cin>>y;
        if(x!=y)
        {
            x=y;
            a.pb(x);
        }
    }

    n=a.size();
    int dp[N]={0};
    dp[n]=1;
    for(i=n-1;i>=0;--i)
    {
        dp[i]=(dp[i+1]+sum[a[i]])%mod;
        sum[a[i]]=dp[i];
    }
    cout<<dp[0];


    return 0;
}


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

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define forn(i,n) for(ll i=0;i<n;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define ford(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265

/******************************************************************************************************/
void file(){
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
}
/******************************************************************************************************/

const ll nax=2e5+1,mod=1e9+7;



int main(){

    sync
   // file();
    
    int n;
    cin>>n;
    map<string,ll> mapp;
    while(n--){
        string s;
        cin>>s;
        sort(all(s));
        mapp[s]++;
    }
    ll ans = 0;
    for(auto it:mapp){
        ans+=(it.se*(it.se-1))/2;
    }
    cout<<ans;



  return 0;
}

Measured memory_bytes: 11264
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1001001001;
const ll LONGINF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int X, A, B; cin >> X >> A >> B;
    int N; cin >> N;
    vector<string> vs(N);
    for(int i=0; i<N; i++) cin >> vs[i];

    int len = X;
    for(int i=0; i<N; i++) {
        if(vs[i] == "nobiro") len += A;
        if(vs[i] == "tidime") len += B;
        if(vs[i] == "karero") len = 0;

        len = max(0, len);
    }
    cout << len << endl;
    return 0;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

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

  int ans = 0;
  int cnt = 0;
  for (int i = 0; i < n; i ++) {
    if (s[i] == 'x' && cnt == 1) break;
    else if (s[i] == 'x') cnt = 1;
    else cnt = 0;
    
    ans ++;
  }

  cout << ans << endl;
}



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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < (int)k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[] = {0, 0, 1, -1};
const int dx[] = {1, -1, 0, 0};

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); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

int dp[1001][1001];

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

    string s, t;
    cin >> s >> t;

    dp[0][0] = 1;
    rep(i, s.size() + 1) {
    	rep(j, t.size() + 1) {
    		if(i < s.size()) dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % MOD;
    		if(i < s.size() && j < t.size() && s[i] == t[j]) {
    			dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % MOD;
    		}
    	}
    }
    cout << dp[s.size()][t.size()] << endl;
    return 0;
}

Measured memory_bytes: 7144
import sys

sys.setrecursionlimit(10 ** 8)
ni = lambda: int(sys.stdin.readline())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
ns = lambda: sys.stdin.readline().rstrip()

R, G, B, N = nm()


def solve():
    ans = 0
    for r in range(N // R + 2):
        for g in range(N // G + 2):
            k = N - (r * R + g * G)
            if k < 0:
                break
            if k % B == 0:
                ans += 1
    return ans


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 39152
def main():
    import sys
    S = input()
    T = input()
    a = {}
    b = {}
    flag = 0
    for i in range(len(S)):
        if not S[i] in a:
            a[S[i]] = T[i]
        if a[S[i]] != T[i]:
            flag = 1
        if not T[i] in b:
            b[T[i]] = S[i]
        if b[T[i]] != S[i]:
            flag = 1
    if flag == 0:
        print("Yes")
    else:
        print("No")
    
main()

Measured memory_bytes: 42444
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
using namespace std;

struct node{
  int key;
  node *right,*left,*parent;
};

node *root, *NIL;

//insert/////
void insert(int k){
  node *y= NIL;
  node *x= root;
  node *z;

  z = (node *)malloc(sizeof(node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x= x->left;
    }
    else {
      x= x->right;
    }
  }

  z->parent =y;
  if(y== NIL){
    root =z ;
  }
  else {
    if(z->key < y->key){
      y->left=z;
    }
    else{
      y->right =z;
    }
  }
}


void inorder(node *a){
  if(a== NIL) return;
  inorder(a->left);
  printf(" %d",a->key);
  inorder(a->right);
}
void preorder(node *a){
  if(a == NIL) return;
  printf(" %d",a->key);
  preorder(a->left);
  preorder(a->right);
}

int main(){
  int n,i,x;
  string com;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    cin >> com;
    if(com == "insert"){
    cin >> x;
      insert(x);
    }
    else if(com == "print"){
      inorder(root);
      cout<< endl;
      preorder(root);
      cout << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 26716
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	int res = (N + K - 3) / (K - 1);
	cout << res << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;
 
#define MOD 1000000007
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<vector<int> > A(N, vector<int>(N - 1));

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

    vector<p> q;
    vector<p> k;

    vector<vector<int> > v(N, vector<int>(N));

    vector<int> pos(N);

    for(int i = 0; i < N; i++) {
        int a = A[i][pos[i]];
        int b = i;
        if(b < a) swap(a, b);
        v[a][b]++;
        if(v[a][b] == 2) {
            q.push_back(make_pair(a, b));
        }
    }

    int ans = 0;

    while(!q.empty()) {
        ans++;
        for(int i = 0; i < q.size(); i++) {
            int a = q[i].first;
            int b = q[i].second;
            pos[a]++;
            pos[b]++;
            if(pos[a] < N - 1) {
                int c = a;
                int d = A[c][pos[c]];
                if(d < c) swap(c, d);
                v[c][d]++;
                if(v[c][d] == 2) {
                    k.push_back(make_pair(c, d));
                }
            }
            if(pos[b] < N - 1) {
                int c = b;
                int d = A[c][pos[c]];
                if(d < c) swap(c, d);
                v[c][d]++;
                if(v[c][d] == 2) {
                    k.push_back(make_pair(c, d));
                }
            }
        }

        q.clear();

        for(int i = 0; i < k.size(); i++) {
            q.push_back(k[i]);
        }

        k.clear();
    }

    for(int i = 0; i < N - 1; i++) {
        for(int j = i + 1; j < N; j++) {
            if(v[i][j] != 2) {
                cerr << i << " " << j << endl;
                cout << -1 << endl;
                return 0;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 11560
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
#include<unordered_map>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(int i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
/* Coding Space*/ 
ll c[10][10];
int main(){
  int h,w; cin >> h >> w;
  rep(i,10)rep(j,10) cin >> c[i][j];
  rep(k,10)rep(i,10)rep(j,10){
    c[i][j] = min(c[i][j],c[i][k] + c[k][j]);
  }
  ll ans = 0;
  rep(i,h)rep(j,w){
    int in; cin >> in;
    if(in != -1)
      ans += c[in][1];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
S = "000"+input()
S = S[::-1]
N = len(S)

dp = [[0] * 2 for _ in range(N + 5)]

ans = 0
up = 0
for i, s in enumerate(S):
    x = int(s) + up
    if x == 10:
        continue
    y = 10 - x
    if x < y:
        ans += x
        up = 0
    elif x > y:
        ans += y
        up = 1
    else:
        ans += x
        if int(S[i + 1]) >= 5:
            up = 1
        else:
            up = 0

print(ans)


Measured memory_bytes: 108516
#include <iostream>
using namespace std;
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using ll = long long;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
char c[405][405];
bool seen[400][400];
int h, w;
ll dfs(const int &i, const int &j, ll &ca, ll &cb) {
	if (seen[i][j]) return 0;
	seen[i][j] = 1;
	if (c[i][j] == '#')
		ca++;
	else
		cb++;
	rep(k, 4) {
		int nx = i + dx[k], ny = j + dy[k];
		if (nx < 0 or h <= nx or ny < 0 or w <= ny) continue;
		if (c[i][j] != c[nx][ny]) dfs(nx, ny, ca, cb);
	}
	return ca * cb;
}
int main() {
	scanf("%d%d", &h, &w);
	rep(i, h) scanf("%s", c[i]);
	ll ans = 0;
	rep(i, h) rep(j, w) {
		ll ca = 0, cb = 0;
		ans += dfs(i, j, ca, cb);
	}
	cout << ans << endl;
	return 0;
}


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

        int x = sc.nextInt();
        int n = sc.nextInt();
        
        HashMap<Integer, Integer> data = new HashMap<>();
        
        for(int i = 0; i<n;i++) {
          data.put(sc.nextInt(), 1);
        }
        
        int output = x;
        int diff = 0;
        
        while(true) {
          int val = x-diff;
          int val2 = x+diff;
          if(data.get(val) == null) {
            output = val;
            break;
          }
          
          if(data.get(val2) == null) {
            output = val2;
            break;
          }
          diff++;
        }
        
        System.out.println(output);
    }
}


Measured memory_bytes: 35964
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
#define F first 
#define S second
const ll N = 1011 ; 
char t[N][N] ;
int n, m, d[N][N], ans;
int X[4] = {1, 0, -1, 0} ;
int Y[4] = {0, 1, 0, -1} ;
vector<pair<int,int> > a ; 
bool VALID(int x, int y){ return !(x > n or x < 1 or y > m or y < 1) ;}
int main()
{
	ios::sync_with_stdio(false);cin.tie();cout.tie();
	for(int i = 0 ; i < N ; i ++) 
		for(int j = 0 ; j < N ; j ++) d[i][j] = 1e9 ;
	cin >> n >> m ;
	for(int i = 1 ; i <= n ; i ++)
		for(int j = 1 ; j <= m ; j ++){
			cin >> t[i][j] ;
			if(t[i][j] == '#'){
				a.push_back({i, j}) ;
				d[i][j] = 0 ; 
			}
		}
	for(int i = 0 ; i < a.size() ; i ++){
		int x = a[i].F, y = a[i].S ;
		for(int j = 0 ; j < 4 ; j ++){
			int xnow = x + X[j], ynow = y + Y[j] ;
			if(VALID(xnow, ynow) and d[xnow][ynow] > d[x][y] + 1){
				a.push_back({xnow, ynow}) ;
				d[xnow][ynow] = d[x][y] + 1 ;
				ans = max(ans, d[xnow][ynow]) ;
			}
		}
	}
	cout << ans ;
}

Measured memory_bytes: 15596
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>

#include <unordered_map>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <sstream>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll pow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = pow(N, P/2);
        return t*t;
    }
    return N * pow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    n=abs(n);
    m=abs(m);
    if(n*m==0)return max(n,m);
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
int main() {
    int n,k;cin>>n>>k;
    vector<bool>seen(n,1);
    rep(i,k){
        int d;cin>>d;
        rep(j,d){
            int a;cin>>a;
            a--;
            seen[a]=0;
        }
    }
    int cnt=0;
    rep(i,n){
        if(seen[i])cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef double db;
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define SZ(x) (int)(x.size())
#define sci(x) scanf("%d",&(x))
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
ll modpow(ll x,ll n,ll mod){ll res=1;for(;n;n>>=1,x=x*x%mod)if(n&1)res=res*x%mod;return res;}
const db eps=1e-8,PI=acos(-1.0);
const int N=2e3+10,M=1e6+10,INF=0x3f3f3f3f,mod=1e9+7;//998244353
int n,x,y,d[N],ans[N];
vi e[N];
queue<int>q;
void bfs(int s){
	memset(d,-1,sizeof d);
	d[s]=0;
	q.push(s);
	int x;
	while(!q.empty()){
		x=q.front();q.pop();
		for(int v:e[x]){
			if(d[v]!=-1)continue;
			d[v]=d[x]+1;
			ans[d[v]]++;
			q.push(v);
		}
	}
}
int main(){
	sci(n),sci(x),sci(y);
	rep(i,1,n-1){
		e[i].pb(i+1);
		e[i+1].pb(i);
	}
	e[x].pb(y),e[y].pb(x);
	rep(i,1,n){
		bfs(i);
	}
	rep(k,1,n-1){
		printf("%d\n",ans[k]/2);
	}
    return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    int ans1 = a + (a - 1);
    int ans2 = a + b;
    int ans3 = b + (b-1);

    int ans = max(ans1,max(ans2,ans3));

    cout << ans << endl;
}

Measured memory_bytes: 256
module Main where

import Control.Applicative
import Text.Printf
import Numeric

main :: IO()
main = do
  { _ <- getLine
  ; xs <- getInts
  ; let mx = maximum xs
  ; let mn = minimum xs
  ; let sm = sum xs
  ; putInts [mn, mx, sm]
  }

--
  
getInts :: IO[Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO()
putInts = putStrLn . unwords. map show

getDoubles :: IO[Double]
getDoubles = map read. words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble x = showFFloat Nothing x ""

getStrings :: IO [String]
getStrings = words <$> getLine

readInt' :: String -> Int
readInt' = read



Measured memory_bytes: 11444
#include<bits/stdc++.h>
using namespace std;
#define int long long int
signed main(){
	int n,k,a;
	cin>>n>>k;
	int A[n],ans[n];
	for(int i=0;i<n;i++)
	{
		cin>>a;
		A[i]=a;
	}
	if(n>k){
	ans[0]=0;
	for(int i=1;i<=k;i++)
	{
		ans[i]=min(abs(A[i]-A[0]),ans[i-1]+abs(A[i]-A[i-1]));
	}
	for(int i=k+1;i<n;i++)
	{
		ans[i]=ans[i-1]+abs(A[i]-A[i-1]);
		for(int j=2;j<=k;j++){
			ans[i]=min(ans[i],ans[i-j]+abs(A[i]-A[i-j]));
		}
	}}
	else{
		ans[0]=0;
	for(int i=1;i<=n;i++)
	{
		ans[i]=min(abs(A[i]-A[0]),ans[i-1]+abs(A[i]-A[i-1]));
	}
	}
	cout<<ans[n-1];
	return 0;
}

Measured memory_bytes: 1792
import sys
input = lambda : sys.stdin.readline().rstrip()

a, b, c, d = map(int, input().split(" "))

outs = []
xs = [a, b]
ys = [c, d]
for x in xs:
    for y in ys:
        out = x*y
        outs.append(out)

out = max(outs)
print(out)

Measured memory_bytes: 64400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

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

    int n,m;
    cin>>n>>m;
    int a[n];
    int l=1,hl=1;
    for(int i=0;i<n;i++){
        cin>>a[i];
        l=lcm(l,a[i]);
        hl=lcm(hl,a[i]/2);
    }
    for(int i=0;i<n;i++){
        if((hl-a[i]/2)%a[i]!=0){
            cout<<0<<endl;
            return 0;
        }
    }
    cout<<max(0,m/hl-m/l)<<endl;
}

Measured memory_bytes: 4012
// ------------------
// author: MatsuTaku
// date  : 27/02/2020
// ------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int N; cin>>N;
  vector<pair<int, int>> cities(N); for (auto& city : cities) {
    cin>>city.first>>city.second;
  }
  vector<int> I(N); iota(I.begin(), I.end(), 0);
  double sum = 0;
  ll fn = 0;
  do {
    for (int i = 1; i < N; i++) {
      auto a = I[i-1], b = I[i];
      auto dx = cities[a].first-cities[b].first;
      auto dy = cities[a].second-cities[b].second;
      sum += sqrt(dx*dx+dy*dy);
    }
    ++fn;
  } while (next_permutation(I.begin(), I.end()));
  cout << fixed << setprecision(7) << sum/fn << endl;

  return 0;
}


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

int main(){
	int M, T, P, R;

	cin >> M >> T >> P >> R;
	while(M != 0 || T != 0 || P != 0 || R != 0){
		int m, t, p, jx;
		int table[51][11][2];
		for(int i=0; i<51; i++){
			for(int j=1; j<11; j++){
				table[i][j][0] = 0;
				table[i][j][1] = -1;
			}
		}
		for(int i=0; i<R; i++){
			cin >> m >> t >> p >> jx;
			if(jx != 0){
				table[t][p][0] += 20;
			}else{
				table[t][p][0] += m;
			}
			table[t][p][1] = jx;
		}

		int ans[51];
		for(int i=1; i<=T; i++){
			ans[i] = 0;
		}
		for(int i=1; i<=T; i++){
			for(int j=1; j<=P; j++){
				if(table[i][j][1] == 0){
					ans[i] += (table[i][j][1]+1)*10000+(500-table[i][j][0]);
				}
			}
		}
	
		int max=0, maxp=0;	
		int tmp = 0;
		for(int j=1; j<=T; j++){
			for(int i=1; i<=T; i++){
				if(maxp <= ans[i]){
					maxp = ans[i];
					max = i;
				}
			}
			ans[max] = -1;
			if(j == 1){
				cout << max;
			}else{
				if(maxp == tmp){
					cout << '=' << max;
				}else{
					cout << ',' << max;
				}
			}
			tmp = maxp;
			maxp = -1;
		}
		cout << endl;
		cin >> M >> T >> P >> R;
	}
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;


//stack<char> stk;
set<ll> sll;
//map<string,ll> mp,mp1;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<char> deq;
//vector<ll> vll;
ll num[ten52];

int main(void)
{
    long long int m,n,i,k;
    cin>>m>>n;
    for(i=0;i<n;i++)
    {
        cin>>k;
        sll.insert(k);
    }
    for(i=0;i<=100;i++)
    {
        if(sll.find(m-i)==sll.end())
        {
            cout<<m-i;
            return 0;
        }
        else if(sll.find(m+i)==sll.end())
        {
            cout<<m+i;
            return 0;
        }
    }
    cout<<"No";
    return 0;
}





Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define MAX 100005
vector<int> v[MAX];
int dp[MAX],vis[MAX],indeg[MAX];
void dfs(int x)
{
	vis[x]=1;
	dp[x]=0;
	if(v[x].size()==0)
	return;
	int val=0;
	for(auto i:v[x])
	{
		if(vis[i]==0)
			dfs(i);
			if(val<dp[i])
			val=dp[i];
	}
	dp[x]=val+1;
}
signed main()
{
	int n,m,i;
	cin>>n>>m;
	for(i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		indeg[b]++;
		v[a].push_back(b);
	}
	int m1=0;
	for(i=1;i<=n;i++)
	if(indeg[i]==0)
	{
	dfs(i);
	if(dp[i]>m1)
	m1=dp[i];
}
	cout<<m1<<"\n";
}

Measured memory_bytes: 12800
s_ = input()
t = input()

for i, s_i in tuple(zip(range(len(s_)-len(t)+1), [s_[x:x+len(t)] for x in range(len(s_)-len(t)+1)]))[::-1]:
	if all((s_i_c == "?" or s_i_c == t[j]) for j, s_i_c in enumerate(s_i)):
		print(s_[:i].replace("?", "a") + t + s_[i+len(t):].replace("?", "a"))
		exit()
print("UNRESTORABLE")

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

int main() {
  string s; cin >> s;
  int count;
  if(s.at(2)==s.at(3)) {count++;}
  if(s.at(4)==s.at(5)) {count++;}
  if(count==2) {cout << "Yes" << endl;}
  else{ cout << "No" << endl;}
}



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<locale.h>
#include<set>
#include<stack>
#include<queue>
using namespace std;

int prime[1000000]={}; //i番目の素数
int spf[10000001];//1~1000000までSPFを求めておく
bool is_prime[1000001]; //is_primeがtrueならiは素数
void sieve(int n) //n以下の素数を列挙する
{
	int p=0;
	for(int i=0; i<=n;i++){ is_prime[i]=true; spf[i]=i;}
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=n;i++)
	{
		if(is_prime[i])
		{
			prime[p++]=i;
			for(int j=2*i;j<=n;j+=i){ is_prime[j]=false; spf[j]=i;}
		}
	}
}


int main()
{
 int x,ans=0;
 scanf("%d",&x);
 sieve(x);
//printf("aa");
 for(int i=1;i<x;i++)
 {
	int rep=x-i,med=1,tet=0,mae=1;//x-iの約数の個数がmed
	if(rep==1){ans++; break;}
	if(is_prime[rep]){med=2;}
	else{
	for(;;)
	{
		mae=spf[rep];//repを割り切る最小の素数を記録しておく
		rep/=mae;
		tet++;
		if(mae!=spf[rep]){med=med*(tet+1);tet=0;}
		if(rep==1){break;}
	}
	}
	ans+=med;
//	printf("%d %d\n",x-i,med);
 }
 printf("%d",ans);
}


Measured memory_bytes: 8892
import java.util.*;
import java.lang.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
            String S = sc.next();
        sc.close();

        int a = Integer.parseInt(S.substring(0, 2));
        String A = S.substring(0, 2);
        
        int b = Integer.parseInt(S.substring(2, 4));
        String B = S.substring(2, 4);
        
        int p = 0;
        int q = 0;
        if(A.equals("00")||a >= 13){
            p = 1;
        }
        if(B.equals("00")||b >= 13){
            q = 1;
        }

        if(p == 0 && q == 0){
            System.out.println("AMBIGUOUS");
        }
        else if(p == 1 && q == 0){
            System.out.println("YYMM");
        }
        else if(p == 0 && q == 1){
            System.out.println("MMYY");
        }
        else{
            System.out.println("NA");
        }
    }
}


Measured memory_bytes: 23124
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}
import scala.annotation.tailrec

object Main extends App {
  val n = in.readInt
  val a = in.readLine.split(" ").map(_.toInt)

  val tableL = Array.ofDim[Int](n)
  val tableR = Array.ofDim[Int](n)

  (0 until n-1)./:(a.head)((acc, i) => {
    tableL(i+1) = gcd(acc, a(i))
    tableL(i+1)
  })
  (n-1 to 1 by -1)./:(a.last)( (acc, i) => {
    tableR(i-1) = gcd(acc, a(i))
    tableR(i-1)
  })

  val init = tableR(0) max tableL(n-1)
  val ans = (1 until n-1)./:(init)((acc,i) => acc max gcd(tableL(i),tableR(i)))
  println(ans)

  def gcd(a:Int, b:Int):Int = {
    if(b== 0) a
    else gcd(b, a%b)
  }
}

Measured memory_bytes: 54444
N=input()
A=[]
for i in range(N):
	x=raw_input()
	if x in A:
		print "No"
		quit()
	if i==0:
		A.append(x)
		last=x[-1]
	else:
		if last!=x[0]:
			print "No"
			quit()
		else:
			A.append(x)
			last=x[-1]
else:
	print "Yes"			


Measured memory_bytes: 28012
n, c = map(int, raw_input().split())
time_table = [list(map(int, raw_input().split())) for _ in xrange(n)]
time_table.sort()

recoders = [[True for i in xrange(10**5+1)]]
for tt in time_table:
    for recoder in recoders:
        if recoder[0] == tt[2]:
            for i in xrange(tt[0], tt[1]+1):
                recoder[i] = False
            break
        else:
            if recoder[tt[0]]:
                for i in xrange(tt[0], tt[1]+1):
                    recoder[i] = False
                recoder[0] = tt[2]
                break
    else:
        recoders.append([True for i in xrange(10**5+1)])
        recoders[-1][0] = tt[2]
        for i in xrange(tt[0], tt[1]+1):
            recoders[-1][i] = False
print len(recoders)


Measured memory_bytes: 45364
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL)
//the function below is used to input integars(int) quickly;int a=readInt();
int readInt () {
	bool minus = false;
	int result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus)
		return -result;
	else
		return result;
}

ll bigpow(ll base,ll pw,ll M)
{
	if(pw==0) return 1;
	if(pw%2==0)
	{
		ll ret=bigpow(base,pw/2,M);
		return ((ret%M)*(ret%M))%M;
	}
	else return ((base%M)*(bigpow(base,pw-1,M)))%M;

}
ll maxi(ll a,ll b)
{
    if(a>b)return a;
    return b;
}
ll mini(ll a,ll b)
{
    if(a<b)return a;
    return b;
}
ll abse(ll a)
{
    if(a<0)return -a;
    return a;
}
ll ceili(ll a,ll div)
{
    return (a+div-1)/div;
}
int dp[100005][3]={0};
int ara[100005][3];
int N;
int f(int i,int row)
{
    if(row>=N)return 0;
    if(i>2)i-=3;
    if(dp[row][i])return dp[row][i];
    return dp[row][i]= maxi(ara[row][i]+f(i+1,row+1),ara[row][i]+f(i+2,row+1));

}
int main(void)
{
    io;
    int t;
    t=1;
    while(t--)
    {
        N=readInt();
        int i,j;
        for(i=0;i<N;i++)
        {
            for(j=0;j<3;j++)
                ara[i][j]=readInt();
        }
        ll ans=maxi(f(0,0),maxi(f(1,0),f(2,0)));
        cout<<ans;

    }
}



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

int digit(int n){
   int x=0;
  while(n>0){
    x++;
    n/=10;
  }
  return x;
}

int main() {
  int n;
  cin>>n;
  int ans=0;
 for(int i=1;i<=n;i++){
   if(digit(i)%2==1) ans++;
 }
  cout<<ans<<endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
    
int main() {
  int n,a,b;
  cin>>n>>a>>b;
  if ((b-a-1)%2)
    cout<<"Alice"<<endl;
  else
    cout<<"Borys"<<endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        long[] l = new long[5] {0,0,0,0,0};
        for(int i = 0; i < n; i ++) {
           string s = Console.ReadLine();
           if(s[0]=='M') l[0] ++;
           if(s[0]=='A') l[1] ++;
           if(s[0]=='R') l[2] ++;
           if(s[0]=='C') l[3] ++;
           if(s[0]=='H') l[4] ++;
       }
       Console.WriteLine(solve(l));
    }
    static long solve(long[] l) {
        long count = 0;
        for(int i = 0; i < l.Length-2; i ++) {
            for(int j = i+1; j <= l.Length-2; j ++) {
                count += l[i] * l[j] * (l.Where((x,y) => y > j).Sum());
            }
        }
        return count;
    }
}

Measured memory_bytes: 15316
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
///////////////////////////////////////////////
int main(){
	int N; SCD(N);
	static int A[102];
	ARSCD1(A,N);
	A[N+1] = 0;
	bool term = false;
	int ans = 0;

	while(!term){
		term = true;
		FORq(i,1,N){
			if (A[i] != 0) term = false;
		}
		if (term) continue;

		int left,right;
		FORq(l,1,N){
			if (A[l] != 0){
				left = l;
				break;
			}
		}

		FORq(r,left,N+1){
			if (A[r] == 0){
				right = r;
				break;
			}
		}
		
		FORq(k,left,right){
			A[k] = max(0,A[k] - 1);
		}
		ans++;

	}

	PRINTD(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1e9 + 7;
const int ms = 202;

long long comb[ms][ms];
long long fat[ms];

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	for(int i = 0; i < ms; i++) {
		comb[i][0] = 1;
		for(int j = 1; j <= i; j++) {
			comb[i][j] = (comb[i-1][j] + comb[i-1][j-1]) % MOD;
		}
	}
	fat[0] = 1;
	for(int i = 1; i < ms; i++) {
		fat[i] = (long long) fat[i-1] * i % MOD;
	}
	int n, x;
	std::cin >> n >> x;
	std::vector<long long> dp(x + 1, 0);
	std::vector<int> greater(x + 1, 0);
	std::vector<int> a(n);
	for(int i = 0; i < n; i++) {
		std::cin >> a[i];
		greater[std::min(x, a[i] - 1)]++;
	}
	for(int i = x-1; i >= 0; i--) {
		greater[i] += greater[i+1];
	}
	std::sort(a.begin(), a.end());
	dp[x] = fat[greater[x]] * comb[n][greater[x]] % MOD;
	long long ans = 0;
	for(int i = x; i > 0; i--) {
		if(dp[i] == 0) {
			continue;
		}
		if(i < a[0]) {
			ans = (ans + (long long) dp[i] * i) % MOD;
			continue;
		}
		// make transition
		for(auto v : a) {
			if(v > i) continue;
			int nxt = i % v;
			int f = greater[nxt] - greater[i];
			int used = greater[i];
			assert(1 <= f);
			assert(n-used-1 >= 0);
			assert(n-used-1 >= f-1);
			dp[nxt] = (dp[nxt] + (long long) comb[n-used-1][f-1] * dp[i] % MOD * fat[f-1] % MOD) % MOD;
		}
	}
	std::cout << ans << '\n';
}

Measured memory_bytes: 1792