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

using ll=long long;
using namespace std;

#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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

const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, x;
    while(true){
        cin >> n >> x;
        if(n == 0 && x == 0)break;
        vector<int> hoge(n);
        for (int i = 0; i < n; i++){
            hoge[i] = i + 1;
        }
        int ans = 0;

        for (int i = 0; i < n - 2; i++){
            for (int a = i + 1; a < n - 1; a++){
                for (int b = a + 1; b < n; b++){
                    if(hoge[i] + hoge[a] + hoge[b] == x)ans++;
                }
            }
        }
        say(ans)
    }
}


Measured memory_bytes: 3132
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;


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

	int sum = 0;

	if (n % 10 == 0) {
		cout << 10 << endl;
	}
	else {
		while (n > 0) {
			sum += (n % 10);
			n /= 10;
		}
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
roota = int(a ** 0.5)

def pcheck(n):
    rootn = int(n ** 0.5)
    for i in range(2, rootn + 2):
        if n % i == 0:
            return False
    return True

pa = []
for i in range(2, roota + 2):
    if a % i == 0:
        pa.append(i)
        while a % i == 0:
            a //= i
if (pcheck(a) == True) & (a != 1):
    pa.append(a)
cd = []
for i in range(len(pa)):
    if b % pa[i] == 0:
        cd.append(pa[i])
print(len(cd) + 1)

Measured memory_bytes: 63828
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int main()
{
  int n;
  int a[100001];
  int sum;

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

  for(int i = 1; i <= n+1; i++){
    sum += abs(a[i] - a[i-1]);
  }

  for(int i = 1; i <= n; i++){
    cout << sum - (abs(a[i] - a[i-1]) + abs(a[i+1] - a[i])) + abs(a[i+1] - a[i-1]) << endl;
  }

  return 0;
}


Measured memory_bytes: 1664
#A-small multiple
n=int(input())
lista=[0 for i in range(n)]
listb=[0 for j in range(n)]
for i in range(n):
    a,b=map(int,input().split())
    lista[i]=a
    listb[i]=b

counter=0
add=0
            
lista=lista[::-1]
listb=listb[::-1]

for i in range(n):
    lista[i]+=add
    mod=lista[i]%listb[i]
    if mod==0:
        need=0
    else:
        need=listb[i]-mod
    add+=need
    counter+=need
print(counter)


Measured memory_bytes: 14856
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long int
#define pi pair <ll,ll>
#define vi vector <ll>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define SQ(a) (a)*(a)
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>       //greater_equal<ll> or less<ll>
// find_by_key()   order_of_key()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}*/

ll power(ll n){

    ll c=1;
    ll i=5;
    while(i--){
        c=c*n;
    }
    return c;
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    /*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll i,j,k,n,m,t,l=0,x,prev=0,max1=0,flag=0,cnt=0,y,min1,q;
    cin>>x;
    for(i=-1000;i<=1000;i++){
        for(j=-1000;j<=1000;j++){
            if((power(i)-power(j))==x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A,B;
    scanf("%d %d",&A,&B);
    if(A==B)
    printf("Draw");
    else if((A==1)||((A>B)&&(B!=1)))
        printf("Alice");
    else
        printf("Bob");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;
typedef long long int ll;
const int MOD = 1000000007;
void sayYes() { cout << "Yes" << endl; };
void sayNo() { cout << "No" << endl; };
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define rep(i, n) for (ll i = 0; i < n; i++)

void Main()
{
    // int n;
    // cin >> n;
    // vector<int> a(n);
    // rep(i, n)
    // {
    //     cin >> a[i];
    // }
    int n;
    cin >> n;
    cout << n * 2 * M_PI;
    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 3860
#include<bits/stdc++.h>	
#define intt long long 
using namespace std;	
const int maxx = 4010;
const int M = 1e9+7;
intt dp[maxx][maxx];
intt A[400020],B[400020];
intt times[3000002];
int n,m;
int read(){int k;cin>>k;return k;}
intt qsm(int x){
	intt ans=1,s=x;
	int k=M-2;
	while(k){if(k&1)ans=ans*s%M;k>>=1;s=s*s%M;}	
	return ans;
}	
intt C(int i,int j){
	return times[i]*qsm(times[j])%M*qsm(times[i-j])%M;
}	
intt Ans=0;
int main(){	
	times[0]=1;
	for(int i=1;i<=100000;i++)times[i]=times[i-1]*i%M;
	n=read();	
	for(int i=1;i<=n;i++){	
		A[i]=read();B[i]=read();
		dp[-A[i]+2000][-B[i]+2000]++;
	}	
	for(int i=0;i<=4000;i++)
		for(int j=0;j<=4000;j++){
			if(i)
				dp[i][j]+=dp[i-1][j];
			if(j)
				dp[i][j]+=dp[i][j-1];
			dp[i][j]%=M;
		}
	intt Ans=0;	
	for(int i=1;i<=n;i++){
		Ans+=dp[A[i]+2000][B[i]+2000];
		Ans-=C(2*A[i]+2*B[i],2*B[i]);
		Ans=(Ans%M+M)%M;
	}	
	Ans=Ans*qsm(2)%M;
	cout<<Ans<<endl;
	return 0;
}	

Measured memory_bytes: 133504
#include <bits/stdc++.h>
#define v vector
#define r resize
using namespace std;
typedef long long ll;
v<bool> s;
v<ll> b; 
v<v<int>> g;
v<ll> ans;
void dfs(ll, int);
int main(){
    int n, q;
    cin >> n >> q;
    g.r(n);
    b.r(n);
    s.r(n);
    ans.r(n);
    for(int i = 0; i < n - 1; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }
    for(int i = 0; i < q; i++){
        ll x, y;
        scanf("%lld %lld", &x, &y);
        b[x - 1] += y;
    }
    dfs(0, 0);
    for(int i = 0; i < n; i++){
        printf("%lld ", ans[i]);
    }
}
void dfs(ll parent_pnt, int current){
    if(s[current]) return;
    s[current] = true;
    ans[current] = parent_pnt + b[current];
    for(int child : g[current]){
        dfs(ans[current], child);
    }
    return;
}


Measured memory_bytes: 22784
#include<stdio.h>
main(){
	long max,min,sum;
	long a;
	int i;
	int n;
	max = -1000000;
	min = 1000000;
	sum = 0;

	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%ld",&a);
		if(a > max)
		max = a;
		if(a < min)
		min = a;
		sum = sum + a;
	}
	printf("%ld %ld %ld\n",min,max,sum);

	return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
    string s;
    cin >> s;
    int l = s.length();
    if(s[0]!='A'){
        cout << "WA\n";
        return 0;
    }
    int i, cnt = 0;
    for(i=1; i<l; i++){
        if(isupper(s[i])){
            if(i==1 || i==l-1 || s[i]!='C'){
                cout << "WA\n";
                return 0;
            }
            cnt++;
        }
    }
    if(cnt==1) cout << "AC\n";
    else cout << "WA\n";
    return 0;
}

Measured memory_bytes: 3616
/**
 * 線形探索
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_A&lang=ja
 */

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector <int>S(n);
  for (int i = 0; i < n; i++) {
    cin >> S.at(i);
  }

  int q;
  cin >> q;
  vector <int>T(q);
  for (int i = 0; i < q; i++) {
    cin >> T.at(i);
  }

  // 線形探索
  int cnt = 0;
  // Tに含まれる整数で、Sに含まれているものの個数をカウントする
  for (int i = 0; i < q; i++) {
    for (int j = 0; j < n; j++) {
      if (T.at(i) == S.at(j)) {
        cnt++;
        break;
      }
    }
  }
  
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 3140
#include <iostream>
using namespace std;
int main()
{
    int count=0;
    string S;
    string T;
    cin >> S;
    cin >> T;
    for(int i=0,j=0; i<S.length()&&j<T.length(); i++,j++)
        {
            if(S[i]!=T[j])
            count++;
        }
        cout << count << endl;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;
typedef unordered_map<int,int> uoii;
typedef unordered_map<string,int> uosi;

const int MOD = 1e9+7;

const int INF = 1e10;




int32_t main()
{
   
    IOS
    int n,k;
    cin>>n>>k;
    vi h;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        h.pb(x);
    }
    sort(all(h));
    int ans=0;
    for(int i=0;i<n-k;i++){
        ans+=h[i];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;

int main(){
    string S;
    cin>>S;
    ll ans=0;
    rep(i,0,4){
        if(S[i]=='+')ans++;
        if(S[i]=='-')ans--;
    }
    cout<<ans;
    
    return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll n=stoi(s);

    ll sum=0;
    REP(i,s.size()){
        sum+=(s[i]-'0');
    }
    if(n%sum==0)YES;
    else NO;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

int main()
{
    int N;
    cin >> N;
    vector<double> probs(N, 0);
    rep(i, 0, N) cin >> probs[i];

    vector<double> dp(N+1, 0);
    dp[0] = 1;
    rep(i, 0, N)
    {
        vector<double> dp_next(N+1, 0);
        
        rrep(j, N, 0)
        {
            dp_next[j+1] += dp[j] * probs[i]; 
            dp_next[j] += dp[j] * (1 - probs[i]);
        }

        swap(dp, dp_next);
    }

    double ans = 0;
    rrep(i, N+1, N/2 + 1)
        ans += dp[i];

    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

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

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

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

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

ll min(ll a, ll b){
	if(a>=b){
		return b;
	}
	else{
		return a;
	}
}

void solve(){

	ll n,m,k;
	cin>>n>>m>>k;
	
	vector<ll> a(n,0);
	vector<ll> b(m,0);

	ll al=0,bl=0;
	ll as=0,bs=0;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		as+=a[i];
		if(as<=k){
			al=i+1;
		}
	}
	for(ll i=0;i<m;i++){
		cin>>b[i];
		bs+=b[i];
		if(bs<=k){
			bl=i+1;
		}
	}
	
	vector<ll> s(n+m,0);
	for(ll i=0;i<n+m;i++){
		if(i<n){
			s[i]=a[n-i-1];
		}
		else{
			s[i]=b[i-n];
		}
	}

	ll res = 0;
    ll right = n;
    ll sum=0;
	for(ll i=n-al;i<n;i++){
		sum+=s[i];
	}
    for (ll left = n-al; left < n+m; ++left) {
        while (right < n+bl && sum + s[right] <= k) {
            sum += s[right];
            ++right;
        }
       	if(res<right-left){
			res=right-left;
		}

        if (left == right){ 
			++right;
		}
        else{
			sum -= s[left]; // left を除く
		} 
    }

    cout << res << endl;
	
}


int main(){
	
	solve();
	
    return 0;
}



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

int main() {
    int n;
    cin >> n;
    vector<vector<double>> p(n, vector<double>(2));
    REP(i, n) cin >> p[i][0] >> p[i][1];
    sort(p.begin(),p.end());
    double sum_dist = 0.0;
    int j = 0;
    do {
        j++;
        double dist = 0.0;
        REP(i, n - 1) {
            dist += sqrt(pow((p[i+1][0]- p[i][0]),2) + pow((p[i+1][1]- p[i][1]),2));
        }
        sum_dist += dist;
    } while(next_permutation(p.begin(), p.end()));
    double ans = sum_dist;
    REP(i, n) ans /= (i + 1);
    printf("%.9f\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
int main(){
    int n;
    cin >> n;
    vector<vector<vector<vector<ll>>>> dp(n+1,vector<vector<vector<ll>>>(4,vector<vector<ll>>(4,vector<ll>(4,0))));
    dp[0][0][0][0] = 1;
    /*for(int i = 0;i < 4;i++){
        for(int j = 0;j < 4;j++){
            for(int k = 0;k < 4;k++){
                dp[0][i][j][k] = 0;
            }
        }
    }*/
    for(int i = 0;i < n;i++){
        for(int j = 0;j < 4;j++){
            for(int k = 0;k < 4;k++){
                for(int l = 0;l < 4;l++){
                    for(int m = 0;m < 4;m++){
                        if(k == 2 && l == 1 && m == 3)continue;
                        if(k == 1 && l == 3 && m == 2)continue;
                        if(k == 1 && l == 2 && m == 3)continue;
                        if(j == 1 && l == 2 && m == 3)continue;
                        if(j == 1 && k == 2 && m == 3)continue;
                        dp[i+1][k][l][m] += dp[i][j][k][l];
                        dp[i+1][k][l][m] %= MOD;
                    }  
                }
            }
        }
    }
    ll ans = 0;
    for(int i = 0;i < 4;i++){
        for(int j = 0;j < 4;j++){
            for(int k = 0;k < 4;k++){
                ans += dp[n][i][j][k];
                ans %= MOD;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int H,W,M[102][102]={0};
	bool A[102][102]={0};
	char s;
	cin>>H>>W;
	for(int i=0;i<=H+1;i++)for(int j=0;j<=W+1;j++){
		if(i==0||i==H+1||j==0||j==W+1)M[i][j]=H*W;
		else{
			cin>>s;
			A[i][j]= (s!='#');
			if(i==1&&j==1)M[i][j]=!A[i][j];
			else M[i][j]=min(M[i-1][j]+(A[i-1][j]&&!A[i][j]),M[i][j-1]+(A[i][j-1]&&!A[i][j]));
		}
	}
	cout<<M[H][W];
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		int C = A - 1;
		int D = B - 1;

		int sum = +0;
		if (A < B) {
			sum += B;
			if (A < D) {
				sum += D;
			} else {
				sum += A;
			}
		} else {
			sum += A;
			if (B < C) {
				sum += C;
			} else {
				sum += B;
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 21844
import sys
n = int(input())

#条件満たす数カウント
cn = 0
#約数カウント
cy = 0

if n < 105:
    print(0)
    sys.exit()
    
for i in range(105, n+1):
    if i % 2 == 0:
        continue

    for j in range(1, i+1):
        if i % j == 0:
            cy += 1
    if cy == 8:
        cn += 1
    cy = 0
print(cn)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	s := getNextString(scanner)
	m := make(map[rune]int)
	for i := 0; i < 4; i++ {
		_, ok := m[rune(s[i])]
		if ok == false {
			m[rune(s[i])] = 0
		}
		m[rune(s[i])]++
	}

	for _, count := range m {
		if count != 2 {
			fmt.Fprintln(writer, "No")
			writer.Flush()
			return
		}
	}
	fmt.Fprintln(writer, "Yes")
	writer.Flush()
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)

int main(){
    int x;
    cin >> x;
    int ans;
    ans = 1000 * floor(x / 500);
    ans += floor((x % 500) / 5) * 5;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<iostream>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <cstring>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <sstream>
#include <map>
#include <unordered_map>
#include <vector> 
#include <bitset>
#include <cctype>
#include <set>
#include <stack>
#include <queue>
#include <fstream>
#include <numeric>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int MAXN = 100005;
const int MAXM = 50005;
const int MOD = 1e9+7;

#define MP make_pair
#define INF 0x3f3f3f3f
#define closeSync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mst(X,Y) memset(X,Y,sizeof(X)) 
#define rep(i, a, n) for (int i=(a); i<=(n); i++)
#define per(i, a, n) for (int i=(a); i>=(n); i--)
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) { cerr << " " << to_string(H);    debug_out(T...);}
template <typename T> inline T max(T a, T b, T c) { return max(max(a, b),c); }

int vis[MAXN];
int p[MAXN];
ll c[MAXN];
ll sumv[MAXN],preMax[MAXN],val[MAXN];
int n;
ll k;
inline ll go(int st)
{
	int cnt = 0;
	vis[st] = 1;sumv[0] = 0;
	preMax[0] = -1e18;
	while (!vis[p[st]])
	{
		st = p[st];
		++cnt;
		sumv[cnt] = sumv[cnt-1] + c[st];
		val[cnt] = c[st]; 
		preMax[cnt] = max(preMax[cnt-1],sumv[cnt]);
		vis[st] = 1;
	}
	st = p[st];
	++cnt;
	sumv[cnt] = sumv[cnt-1] + c[st];
	val[cnt] = st;
	preMax[cnt] = max(preMax[cnt-1],sumv[cnt]);
	int rd = cnt; //循环节的长度
	ll rdval = sumv[cnt];	//循环节的值
	ll ans = 0;
	rep (i,1,rd)
	{
		sumv[rd+i] = sumv[rd+i-1] + val[i]; 
		preMax[rd+i] = max(preMax[rd+i-1],sumv[rd+i]);
	}
	if (k > rd)
	{
		if (rdval > 0)
		{
			ll rm = k%rd + rd;
			ans += rdval * ((k - rd)/rd);
			ans += preMax[rm];
		}
		else 
			ans = preMax[cnt];
	}
	else 
		ans = preMax[k];
	return ans;
}
int main()
{closeSync;
#ifdef DEBUG
	// freopen("C:/Users/86159/Desktop/a2.in.txt", "r", stdin);
	// freopen("C:/Users/86159/Desktop/output.txt", "w", stdout);
#endif  
	cin>>n>>k;
	rep (i,1,n)
		cin>>p[i];
	rep (i,1,n)
		cin>>c[i];
	ll mx = -1e18;
	rep (i,1,n)
	{	
		rep (i,1,n)
			val[i] = sumv[i] = preMax[i] = vis[i] = 0;
		ll temp = go(i);
		// debug(temp);
		mx = max(mx,temp);
	}
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 3948
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <functional>

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)

using namespace std;
using ll = long long;

int main() {

	int N;
	cin >> N;
	vector<vector<vector<int>>> F(N, vector<vector<int>>(5, vector<int>(2)));
	REP(i, N) REP(j, 5)REP(k, 2) cin >> F[i][j][k];
	vector<vector<ll>> P(N, vector<ll>(11));
	REP(i, N) REP(j, 11) cin >> P[i][j];
	ll sum = 0, summax = -1000000000;

	vector<vector<int>> J(5, vector<int>(2, 0));
	REP(i00, 2) {
		J[0][0] = (i00 == 0) ? 0 : 1;
		REP(i01, 2) {
			J[0][1] = (i01 == 0) ? 0 : 1;
			REP(i10, 2) {
				J[1][0] = (i10 == 0) ? 0 : 1;
				REP(i11, 2) {
					J[1][1] = (i11 == 0) ? 0 : 1;
					REP(i20, 2) {
						J[2][0] = (i20 == 0) ? 0 : 1;
						REP(i21, 2) {
							J[2][1] = (i21 == 0) ? 0 : 1;
							REP(i30, 2) {
								J[3][0] = (i30 == 0) ? 0 : 1;
								REP(i31, 2) {
									J[3][1] = (i31 == 0) ? 0 : 1;
									REP(i40, 2) {
										J[4][0] = (i40 == 0) ? 0 : 1;
										REP(i41, 2) {
											J[4][1] = (i41 == 0) ? 0 : 1;
											if ((J[0][0] == 0) && (J[0][1] == 0) && (J[1][0] == 0) && (J[1][1] == 0) && (J[2][0] == 0) && (J[2][1] == 0) && (J[3][0] == 0) && (J[3][1] == 0) && (J[4][0] == 0) && (J[4][1] == 0)) continue;

											sum = 0;
											REP(i, N) {
												int c = 0;
												REP(j, 5) {
													REP(k, 2) {
														if ((J[j][k] == 1) && (F[i][j][k] == 1)) c++;
													}
												}
												sum += P[i][c];
											}
											summax = max(summax, sum);
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
	cout << summax << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e10;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double



////////////////////////////////////////////////////////////////////

template<typename T>
struct edge {
  int to, from;T cost;
  edge(int to, T cost) : from(-1), to(to), cost(cost) {}
  edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};
template<typename T>
using edges = vector<edge<T>>;
template<typename T>
using graph = vector<edges<T>>;
template<typename T>
using matrix = vector<vector<T>>;

template<typename T>
bool compByCost(const edge<T>& left, const edge<T>& right){
  return left.cost < right.cost; 
}

template<typename T>
vector<T> dijkstra(int s, graph<T> &g){
  vector<T> dist(g.size()+10, INF);dist[s] = 0;
  priority_queue<P, vector<P>, greater<P>> que;que.push(P(0,s));
  while(!que.empty()){
    P p = que.top();que.pop();
    int v = p.second;
    if(dist[v] < p.first)continue;
    rep(i, g[v].size()){
      edge<T> e = g[v][i];
      if(dist[e.to] > dist[v] + e.cost){
        dist[e.to] = dist[v] + e.cost;
        que.push(P(dist[e.to], e.to));
      }
    }
  }
  return dist;
}

#define dijkstra dijkstra<int>

ll modpow(ll a,  ll n, const ll &MOD = MOD){
  ll ret = n == 0 ? 1 : modpow(a, n/2, MOD);
  (ret *= ret) %= MOD;
  if(n%2)((ret *= a) %= MOD);
  return ret;
}
////////////////////////////////////////////////////////////////////i

int h,w,k,dp[110][15];
signed main(){
  cin>>h>>w>>k;
  if(w == 1){
    cout << 1 << endl;return 0;
  }
  dp[1][1] = 1;
  repd(i,2,h+2){
    repd(j,1,w+1){
      int x = 0, y = 0, z = 0;
      rep(bit, 1LL<<(w-1)){
        bool b[15];rep(i,15)b[i] = false;
        rep(kk,w-1){
          if(bit&1<<kk)b[kk+1] = true;
        }
        bool bb = false;
        repd(kk,1,w){
          if(kk>0 && b[kk] && b[kk-1]){
            bb = true;break;
          }
        }
        if(bb)continue;
        if(b[j-1]){
          x++;
        }
        if(!b[j-1] && !b[j])y++;
        if(b[j])z++;
      }
      dp[i][j] = (dp[i-1][j] * y)%MOD;
      dp[i][j] = (dp[i][j] + dp[i-1][j-1] * x % MOD) % MOD;
      dp[i][j] = (dp[i][j] + dp[i-1][j+1] * z % MOD) % MOD;
    }
  }

  cout << dp[h+1][k] << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


set<int> SET;

int main(){

	int num_query;
	scanf("%d",&num_query);

	int command,x;

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d %d",&command,&x);

		if(command == 0){

			SET.insert(x);
			printf("%lld\n",SET.size());

		}else{

			printf("%lld\n",SET.count(x));
		}
	}

	return 0;
}



Measured memory_bytes: 12572
#include <bits/stdc++.h>
using namespace std;
bool comp(pair<string,int> a,pair<string,int> b)
{
    if(a.first != b.first)
    {
        return a.first < b.first; 
    }
    else
    {
        return a.second > b.second;
    }
    
}
int main()
{
    int n;
    cin >> n;
    pair<string,int> p;
    vector<pair<string,int> > v,v2;
    for(int i = 0;i < n;i++)
    {
        string a;
        int b;
        cin >> a >> b;
        v.push_back(make_pair(a,b));
    }
    v2 = v;
    sort(v2.begin(),v2.end(),comp);
    for(int i = 0;i < n;i++)
    {
        for(int j = 0;j < n;j++)
        {
            if(v2.at(i) == v.at(j))
            cout << j + 1 << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for (int i=0;i<n;++i) a[i] = sc.nextInt();

        count = 1;
        int last = 1;
        for (int i=0;i<n;++i)
        {
            if (count == a[i])
            {
                last = a[i];
                ++count;
            }else
            {
                a[i] = -1;
            }
        }

        List<Integer> b = new ArrayList<>();
        //if (count - 1 != a[a.length-1]) System.out.println(-1);
        if (count - 1 != last) System.out.println(-1);
        else
        {
            for (int i=0;i<n;++i)  if (a[i] != -1) b.add(a[i]);
            System.out.println(a.length - b.size());
        }

        sc.close();
    }

    public class Pair<F,S>
    {
        private final F first;
        private final S second;

        Pair(F first,S second)
        {
            this.first = first;
            this.second = second;
        }

        public void print() { System.out.println("("+this.first+","+this.second+")"); }

        //get
        public F first() {return this.first;}
        public S second() {return this.second;}

        @Override
        public boolean equals(Object object)
        {
            if (object instanceof Pair)
            {
                Pair pair = (Pair)object;
                return this.first==pair.first && this.second==pair.second;
            }else
            {
                return false;
            }
        }

        @Override
        public int hashCode()
        {
            return Objects.hash(first,second);
        }
    }
}

Measured memory_bytes: 91312
import sys
input = sys.stdin.readline
def print_ans(r):
    """Test Case
    >>> print_ans(4)
    48
    >>> print_ans(15)
    675
    >>> print_ans(80)
    19200
    """
    print(3 * (r ** 2))

if __name__ == '__main__':
    r = int(input().rstrip())
    print_ans(r)


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

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

int main() {
    long long x,y;
    cin >> x >> y;
    long long sum =0;
    long long c=0;
    long long i=1;
    while(c<=y){
        sum++;
        c = x * pow(2,i);
        i++;
    }

    cout << sum;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,n,x,ans;
  cin>>a>>b>>n;
  if(n<b){
    ans=floor(a*n/b)-a*floor(n/b);
  }else{
    x=n-n%b-1;
    ans=floor(a*x/b)-a*floor(x/b);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
import scala.io.StdIn.readInt

object Main {
  def fib(a:Int, b:Int, n:Int):Int = {
    if (n ==  0)
      a
    else
      fib(a+b, a, n-1)
  }

  def main(args: Array[String]) = {
    val n = readInt()
    println(fib(1, 0, n))
  }
}

Measured memory_bytes: 43636
# AOJ 2608: Minus One
# Python3 2018.6.30 bal4u

import heapq
MAX = 0x7fffffff

def dijkstra(dist, start):
	Q = []
	dist[start] = 0
	heapq.heappush(Q, (0, start))
	while Q:
		t, s = heapq.heappop(Q)
		if dist[s] < t: continue
		for e in to[s]:
			nt = t + 1
			if dist[e] > nt:
				dist[e] = nt
				heapq.heappush(Q, (nt, e))

N, M, s, t = map(int, input().split())
s, t = s-1, t-1
to = [[] for i in range(N)]
for i in range(M):
	x, y = map(int, input().split())
	x, y = x-1, y-1
	to[x].append(y)
	to[y].append(x)
smin = [MAX]*N
dijkstra(smin, s)
tmin = [MAX]*N
dijkstra(tmin, t)
scnt = [0]*N
tcnt = [0]*N
for i in range(N):
	if smin[i] < N: scnt[smin[i]] += 1
	if tmin[i] < N: tcnt[tmin[i]] += 1
ans = 0
s = smin[t]-1
for i in range(s): ans += scnt[i]*tcnt[s-1-i]
print(ans)


Measured memory_bytes: 36616
n,m = map(int, raw_input().split())
f = [0 for i in xrange(m+1)]
for i in xrange(n):
	a = map(int, raw_input().split())
	for j in xrange(1,len(a)):
		f[a[j]] += 1
ans = 0
for i in xrange(1,m+1):
	if f[i] == n:
		ans += 1
print ans

Measured memory_bytes: 28780
def main():
    import itertools
    import sys
    buf = sys.stdin.buffer


    n, t = map(int, buf.readline().split())
    m = map(int, buf.read().split())
    shops = []
    shopsA0 = [0]

    for a, b in zip(m, m):
        if a == 0:
            shopsA0.append(b + 1)
        else:
            shops.append([a, b])

    shopsA0.sort()
    shops.sort(reverse=True, key=lambda x: x[0]/(x[1]+1))


    DP = [t+10] * 30
    DP[0] = 0

    for a, b in shops:
        for num in range(28, -1, -1):
            candidate = (DP[num]+1) * (a+1) + b
            if candidate < DP[num+1]:
                DP[num+1] = candidate

    cumA0 = list(itertools.accumulate(shopsA0))

    ans = [0]
    count_A0 = len(cumA0) - 1
    for count, spend_time in enumerate(DP):
        residue = t - spend_time
        if residue < 0:
            break
        while count_A0 > 0 and cumA0[count_A0] > residue:
            count_A0 -= 1
        ans.append(count_A0 + count)
    print(max(ans))


if __name__ == '__main__':
    main()

Measured memory_bytes: 58592
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    for(int i=9; i>=1; i--)
    {
        if(n%i==0)
        {
            int a=n/i;
            if(a<=9)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
                break;
        }
    }
}


Measured memory_bytes: 256
s=list(input())
#print(s)
ans = -1
counter = 0
for i in range(len(s)):
  if s[i] == "A" or s[i] == "T" or s[i] == "G" or s[i] == "C":
    #print("ATGC")
    counter += 1
  else:
    counter = 0
  ans = max(ans,counter)
  
print(ans)
    

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
const double PI  = acos(-1.0);

//-------------------------------------------


int main(){

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

    int A,B;
    cin >> A >> B;
    int cnt=0;
    for ( int i = A; i < B+1; i++){
        string s = toString(i);
        if(s[0] == s[4] && s[1] == s[3]) cnt++;
    }
    cout << cnt;


    return 0;

}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		long ans = 0l;
		ArrayList<Integer> list = new ArrayList<>();
		list.add(s);
		for(int i = 2; i < Integer.MAX_VALUE; i++) {
			int x = 0;
			if(s%2 == 0) {
				x = s/2;
			}else {
				x = (3*s)+1;
			}
			if(list.contains(x)) {
				ans = i;
				break;
			}else {
				list.add(x);
				s = x;
			}
		}
		System.out.println(ans);
	}
}


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

using namespace std;

typedef long long ll;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }
    if (n == 2) {
        if (s[0] == s[1]) {
            cout << 1 << endl;
        }else {
            cout << 2 << endl;
        }
        return 0;
    }
    int dp[n + 1][2]{};
    dp[0][0] = 1;
    dp[0][1] = 0;
    if (s[0] == s[1]) {
        dp[1][0] = 1;
        dp[1][1] = 1;
    }else {
        dp[1][0] = 2;
        dp[1][1] = 1;
    }

    for (int i = 2; i < n; ++i) {
        if (s[i] != s[i - 1]) {
            dp[i][0] = dp[i - 1][0] + 1;
            dp[i][1] = dp[i - 2][0] + 1;
        }else {
            dp[i][0] = dp[i - 1][1]  + 1;
            dp[i][1] = dp[i - 2][0] + 1;
        }
    }
    cout << max(dp[n - 1][0], dp[n - 1][1]) << endl;
    return 0;
}

Measured memory_bytes: 2180
#include<iostream>
using namespace std;
int main(){
	int a,b; cin >> a >> b;
	string s;
	cin >> s;
	bool ans=true;
	for(int i=0;i<s.length();i++){
		if(i!=a){
			if(s[i]=='-') ans=false;
		}else{
			if(s[i]!='-') ans=false;
		}
	}
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
		
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  int H,W;
  cin>>H>>W;
  VVI C(10,VI(10));
  rep(i,10) rep(j,10) cin>>C[i][j];
  VVI A(H,VI(W));
  rep(i,H) rep(j,W) cin>>A[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) if(A[i][j]!=-1) ans+=C[A[i][j]][1];
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int>v(3);
  for(int i=0;i<3;i++)
  {
	cin>>v[i];
  }
  sort(v.begin(),v.end());
  cout<<v[0]+v[1];
}

Measured memory_bytes: 3628
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	int N, M;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		N = sc.nextInt();
		M = sc.nextInt();

		List<List<Integer>> AB = new ArrayList<>();

		for (int i = 0; i <= 100000; i++) {
			AB.add(new ArrayList<>());
		}

		for (int i = 0; i < N; i++) {
			AB.get(sc.nextInt()).add(sc.nextInt());
		}

		sc.close();

		PriorityQueue<Integer> q = new PriorityQueue<>((a, b) -> Integer.compare(b, a));

		long ans = 0;

		for (int i = 1; i <= M; i++) {
			for (Integer x : AB.get(i)) {
				q.add(x);
			}
			if (!q.isEmpty()) {
				ans += q.poll();
			}
		}

		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 99304
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>

#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second

using namespace std;
using ll = long long;
using namespace __gnu_pbds;

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 2e5 + 10 , inf = 2e9 + 7;
const ll INF = 1e18 ,   mod = 1e9+7;

void solve() {
    string s;
    cin >> s;
    int cur = 0 , cnt = 0 , ans = 0;
    while(s[cur] == 'R') {
        cur ++;
        cnt ++;
    }
    ans = max(ans , cnt);
    cur = 1;
    cnt = 0;
    while(s[cur] == 'R') {
        cur ++;
        cnt ++;
    }
    ans = max(ans , cnt);
    cur = 2;
    cnt = 0;
    while(s[cur] == 'R') {
        cur ++;
        cnt ++;
    }
    ans = max(ans , cnt);
    cout << ans;
}

/*
1 1 5 5
1 2 13
*/
main() {
    ios;
    int tt = 1;
   // cin >> tt;
    while(tt --) {
        solve();
    }
    return 0;
}


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

#define FOR(x,n) for(int x=0;x<n;x++)
#define mp make_pair
typedef long long ll;
typedef pair<int,int> iPair;

void next(string& s) {
  bool nine = true;
  for(auto c : s) {
    if(c != '9') nine = false;
  }
  if(nine) {
    s = "1" + string(s.length(), '0');
    return;
  }

  for(int i = s.length() - 1; i >= 0; i--) {
    if(i == 0 || (s[i - 1] - s[i] > -1 && s[i] != '9')) {
      s[i]++;
      for(int j = i + 1; j < s.length(); j++) {
	s[j] = (s[j - 1] == '0') ? '0' : s[j - 1] - 1;
      }
      return;
    }
  }
}

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

  int k;
  cin >> k;

  string s = "0";
  while(k--) {
    next(s);
  }

  cout << s << '\n';
}

// UPDATE N WHEN UR DONE AAAAAAAAAAAAAAAAAAAAAAAAAAA (if it applies lol)


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;



int main(){
	
	int n;
	cin>>n;
	for(int iii=0;iii<n;iii++){
	int map[17][17]={};
	string str;
	for(int i=0;i<8;i++)
	{cin>>str;
	for(int j=0;j<8;j++)
		map[i+3][j+3]=str[j]-'0';
	}


	



	int x,y;
	cin>>x;cin>>y;
	x+=2;y+=2;
	map[y][x]=0;
	map[y][x+1]+=2;map[y][x+2]+=2;map[y][x+3]+=2;
	map[y][x-1]+=2;map[y][x-2]+=2;map[y][x-3]+=2;
	map[y-1][x]+=2;map[y-2][x]+=2;map[y-3][x]+=2;
	map[y+1][x]+=2;map[y+2][x]+=2;map[y+3][x]+=2;
	bool f=false;
	while(f==false){f=true;
	for(int i=0;i<8;i++)
	for(int j=0;j<8;j++){
		if(map[i+3][j+3]%2==1&&map[i+3][j+3]!=1){f=false;
			x=j+3;y=i+3;
			map[y][x]=0;
	map[y][x+1]+=2;map[y][x+2]+=2;map[y][x+3]+=2;
	map[y][x-1]+=2;map[y][x-2]+=2;map[y][x-3]+=2;
	map[y-1][x]+=2;map[y-2][x]+=2;map[y-3][x]+=2;
	map[y+1][x]+=2;map[y+2][x]+=2;map[y+3][x]+=2;

		}
	
	}

}
	/*
	for(int i=0;i<8;i++)
	{
	for(int j=0;j<8;j++)
		cout<<map[i+3][j+3];
	cout<<endl;
	}
	*/

	for(int i=0;i<8;i++)
	for(int j=0;j<8;j++)
		map[i+3][j+3]=map[i+3][j+3]%2;


	cout<<"Data "<<iii+1<<":"<<endl;
	for(int i=0;i<8;i++)
	{
	for(int j=0;j<8;j++)
		cout<<map[i+3][j+3];
	cout<<endl;
	}


	}
	return 0;
}

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

// 各桁の和を計算する関数
int findSumOfDigits(ll n) {
  ll sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
ll n;
cin >> n;
string ans ="No";

if(n % findSumOfDigits(n) == 0){
    ans ="Yes";
}

cout << ans << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep for(int i = 0;i<n;i++)
const int MOD = 1000000007;
 
int main(){
    int n;cin >> n;
    long long int ans = n;
    ans *= n-1;
    ans /= 2;
    printf("%lld\n",ans);
}

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

int main() {
    int N; cin >> N;
    // map<int, int> L;
    // for (int i = 0; i < N; ++i) {
    //     int x; cin >> x;
    //     L[x]++;
    // }
    vector<int> L(N);
    for (int i = 0; i < N; ++i) cin >> L[i];
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            for (int k = j+1; k < N; ++k) {
                if (L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j] && L[i] != L[j] && L[j] != L[k] && L[k] != L[i]) ans++;
            }
        }
    }
    cout << ans << endl;
}

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

using int64 = long long;

const int MAX_N = int(2e5) + 10;

int n;
bool is[MAX_N];
char s[MAX_N];

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for (int i = 1; i <= n; ++i) {
		if (s[i] == 'C' && s[i - 1] != 'B') {
			is[i] = true;
		}
		if (s[i] == 'B' && s[i + 1] != 'C') {
			is[i] = true;
		}
	}

	int64 ans = 0LL;
	for (int l = 1, r; l <= n; l = r + 1) {
		while (is[l]) ++l;
		if (l > n) break;
		r = l;
		while (r < n && !is[r + 1]) ++r;
		int cnt = 0;
		int64 del = 0LL;
		for (int i = l; i <= r; ++i) {
			if (s[i] == 'A') ++cnt;
			else if (s[i] == 'B' && s[i + 1] == 'C') {
				++i;
				del += cnt;
			}
		}
		ans += del;
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 4004
#include<bits/stdc++.h>
#define N 200010
using namespace std;
vector<int> v[N];
int f[N],vst[N],ans[N],n,q;
void dfs(int idx,int sum){
    vst[idx]=1;
    ans[idx]=sum;
    for(int i=0;i<v[idx].size();i++){
        if(!vst[v[idx][i]]){
            dfs(v[idx][i],sum+f[v[idx][i]]);
        }
    }
}
int main(){
    cin>>n>>q;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(int i=0;i<q;i++){
        int pi,xi;
        cin>>pi>>xi;
        f[pi]+=xi;
    }
    dfs(1,f[1]);
    for(int i=1;i<=n;i++){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 24832
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {

    int W, H, N; cin >> W >> H >> N;
    bool f[W][H];
    rep(i,W) {
        rep(j,H) f[i][j] = false;
    }

    rep(i,N) {
        int x, y, a; cin >> x >> y >> a;
        if (a == 1) {
            for (int w = 0; w < x; ++w) {
                for (int h = 0; h < H; ++h) f[w][h] = true;
            }
        }
        else if (a == 2) {
            for (int w = x; w < W; ++w) {
                for (int h = 0; h < H; ++h) f[w][h] = true;
            }
        }
        else if (a == 3) {
            for (int w = 0; w < W; ++w) {
                for (int h = 0; h < y; ++h) f[w][h] = true;
            }
        }
        else {
            for (int w = 0; w < W; ++w) {
                for (int h = y; h < H; ++h) f[w][h] = true;
            }
        }
    }

    int ans = 0;
    for (int w = 0; w < W; ++w) {
        for (int h = 0; h < H; ++h) {
            if (!f[w][h]) ++ans;
        } 
    }
    out(ans);

    return 0;
}









Measured memory_bytes: 256