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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, k;
	cin >> n >> k;
	ll res = 1;
	ll l = 0, r = 0;
	rep (i, k) {
	  l += i;
	  r += n - i;
	}
	FOR (i, k, n + 1) {
	  res += r - l + 1;
	  l += i;
	  r += n - i;
	  res %= MOD;
	}
	cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 3608
#include<cstdio>
int main(){
	int n,i,t;
	scanf("%d",&n);
	if(n<3||n==(n&-n)){
		puts("No");
		return 0;
	}
	puts("Yes");
	printf("%d %d\n%d %d\n%d 1\n1 2\n2 3\n",1+n,2+n,2+n,3+n,3+n);
	for(i=4;i<n;i+=2)printf("1 %d\n%d %d\n1 %d\n%d %d\n",i,i,i+1,i+1+n,i+1+n,i+n);
	if(!(n&1)){
		t=n&-n;
		printf("%d %d\n%d %d\n",t,n,(n^t^1)+n,n<<1);
	}
	return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int h, w, di, de;

vector<vector<int> > mat, vis, dp;

int isValid(int i, int j) {
    if(i >= h || j >= w || i < 0 || j < 0 || mat[i][j] == 0) 
        return 0;
    return 1;    
}

int main() {
    cin>>h>>w;
    int si, se;
    cin>>si>>se;
    cin>>di>>de;
    mat = vector<vector<int> >(h, vector<int>(w, 0));
    dp = vector<vector<int> >(h, vector<int>(w, -1));
    vis = vector<vector<int> >(h, vector<int>(w, 0));

    for (int i = 0; i < h; i++)
    {   
        string s;
        cin>>s;
        for (int j = 0; j < w; j++)
        {
            if(s[j] == '.') {
                mat[i][j] = 1;
            } else {
                mat[i][j] = 0;
            }
        }
    }
    si--;
    se--;
    di--;
    de--;
    deque<pair<int, int> > q;
    map<pair<int, int>, int > mp;

    q.push_back({si, se});
    mp[{si, se}] = 0;
    while(!q.empty()) {
        pair<int, int> front = q.front();
        q.pop_front();
        int iAdd[4] = {-1, 0, 1, 0};
        int jAdd[4] = {0, 1, 0, -1};
        if(front == make_pair(di, de) ) {
            cout<<mp[{di, de}] <<endl;
            return 0;
        }
        for(int i=0; i<4; i++) {
            if(isValid(front.first + iAdd[i], front.second + jAdd[i])) {
                if(mp.find({front.first + iAdd[i], front.second + jAdd[i]}) == mp.end()) {
                    mp[{front.first + iAdd[i], front.second + jAdd[i]}] = mp[front];
                    q.push_front({front.first + iAdd[i], front.second + jAdd[i]});
                } else if (mp[{front.first + iAdd[i], front.second + jAdd[i]}] > mp[front]) {
                    mp[{front.first + iAdd[i], front.second + jAdd[i]}] = mp[front];
                    q.push_front({front.first + iAdd[i], front.second + jAdd[i]});
                }
            }
        }
        for(int i=front.first-2; i<= front.first + 2; i++) {
            for(int j = front.second-2; j <= front.second + 2; j++) {
                if(isValid(i, j) && mp.find({i, j}) == mp.end()) {
                    q.push_back({i, j});
                    mp[{i, j}] = mp[front] + 1;
                }
            }
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 41872
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<long long ,int >
#define F first
#define S second
#define mod 1000000007
///distance(s.begin(),s.lower_bound(101))
using namespace std;
///dp[i][j]=j lessons skipped in first i days.
///mn[i][j]=min hours needed to spend in ith day to skip skip exactly j lessons.



int main(){
    int x,y,a,b,c;cin >>x>>y>>a>>b>>c;
    vector<pii > arr;
    for(int i=0;i<a;i++){
        ll x;cin >>x;
        arr.push_back({x,1});
    }
    for(int i=0;i<b;i++){
        ll x;cin >>x;
        arr.push_back({x,2});
    }
    for(int i=0;i<c;i++){
        ll x;cin >>x;
        arr.push_back({x,3});
    }
    sort(arr.begin(),arr.end());
    int cred=0,cgreen=0,cl=0;int tc=0;
    int i=a+b+c-1;ll ans=0;
    while(i>=0){
        if(tc+cred+cgreen>=x+y){
            break;
        }
        if(arr[i].S==1){
            if(cred<x){
            cred+=1;ans+=arr[i].F;}

        }if(arr[i].S==2){
            if(cgreen<y)
           {

           cgreen+=1;ans+=arr[i].F;}
        }
        if(arr[i].S==3){

            tc+=1;ans+=arr[i].F;
        }
        i-=1;
    }
    cout <<ans<<endl;


}


Measured memory_bytes: 10476
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)n;i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1e9*2; const long long INFLL=1e18*2;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.second >> p.first; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------

signed main() {
    ll a,b,x;
    cin>>a>>b>>x;
    cout<<(b/x-a/x+(a%x==0))<<endl;
    return 0;
}


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

int main() {
    vector<int> v(3);
    int k;
    cin >> v[0] >> v[1] >> v[2];
    cin >> k;

    sort(v.begin(), v.end());

    for(int i=0; i<k; i++) {
        v[2] *= 2;
    }

    cout << v[0] + v[1] + v[2] << endl;
}


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

int main() {
    int64_t n, c;
    cin >> n >> c;
    vector<int64_t> x(n), v(n);
    for (int64_t i = 0; i < n; i++) cin >> x[i] >> v[i];

    vector<int64_t> cw1(n), cw2(n), aw1(n), aw2(n);
    partial_sum(begin(v), end(v), begin(cw1));
    partial_sum(rbegin(v), rend(v), rbegin(aw1));
    cw2 = cw1;
    aw2 = aw1;

    for (int64_t i = 0; i < n; i++) {
        cw1[i] -= x[i];
        cw2[i] -= x[i] * 2;
        aw1[n-i-1] -= (c - x[n-i-1]);
        aw2[n-i-1] -= (c - x[n-i-1]) * 2;
    }

    for (int64_t i = 0; i + 1 < n; i++) {
        cw1[i+1] = max(cw1[i], cw1[i+1]);
        cw2[i+1] = max(cw2[i], cw2[i+1]);
        aw1[n-i-2] = max(aw1[n-i-2], aw1[n-i-1]);
        aw2[n-i-2] = max(aw2[n-i-2], aw2[n-i-1]);
    }

    int64_t ans = max({cw1[n-1], aw1[0], 0l});
    for (int64_t i = 0; i + 1 < n; i++) {
        ans = max({ans, cw1[i], cw2[i] + aw1[i+1], aw1[i+1], aw2[i+1] + cw1[i]});
    }

    cout << ans << endl;
}


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

int main(){
  int N ; 
  cin >> N ; 
  vector<int> H(N) ; 
  int L = 0   ;
  int R = 0   ; 
  
  
  for(int i = 0 ; i < N ; i++){
    cin >> H.at(i) ;  

  }
  
  for(int i = 0 ; i < N-1 ; i++){
    if(H.at(i) >= H.at(i+1) ){
      L++ ; 

    }
    else{
      if(L >= R){
        R = L ; 
      }
      L = 0 ; 
    }
    
  }

  
  cout << max(R,L) << endl  ;
  
}

Measured memory_bytes: 3680
from itertools import product

S=input()
tf_li=list(product([True,False],repeat=len(S)-1))
ans=0
for x in tf_li:
  formula=S[0]
  for i in range(len(S)-1):
    if x[i]==False:
      formula+="+"
    formula+=S[i+1]
  ans+=eval(formula)
print(ans)


Measured memory_bytes: 73680
#include <stdio.h>
int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    int i;
    
    if(a <= b){
        for(i=0;i<b;i++){
            printf("%d",a);
        }
    }else{
        for(i=0;i<a;i++){
            printf("%d",b);
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long int a[105];
#define mod 1000000007

int main(){
      int n, k;
      cin>>n>>k;
      for(int i=0; i<n; i++)
            cin>>a[i+1];
      vector<int>prefix(k+1, 1);
      int dp[n+1][k+1];
      for(int i=0; i<=n; i++)
            for(int j=0; j<=k; j++)
                  dp[i][j]=0;
      dp[0][0]=1;

      for(int i=1; i<=n; i++){
            /*vector<int>pre(k+1);

            for(int p=0; p<=k; p++){
                  if(p-a[i]-1<0)
                        dp[i][p]=prefix[p];
                  else {
                        dp[i][p]=(prefix[p]-prefix[p-a[i]-1]+mod)%mod;
                  }
                  //cout<<i<<' '<<p<<' '<<dp[i][p]<<'\n';

                  if(p>0)pre[p]=(dp[i][p]+pre[p-1])%mod;
                  else pre[p]=1;
            }
            prefix=pre;*/
            /*int sums[k+1];
        sums[0]=dp[i-1][0];
        for(int j=1;j<=k;j++)
        {
            sums[j]=(sums[j-1]+dp[i-1][j])%mod;  ///Calculate the prefix sums for i-1
        }*/
        vector<int>pre(k+1);

        for(int j=0;j<=k;j++)
        {
            int tr=prefix[j];  ///Sum of dp[i-1][0...j]
            int unreachable=j-a[i]-1;  ///We need to subtract the sum of the first "unreachable" elements (dp[i-1][0...unreachable])
            if(unreachable>=0)
            {
                tr=(tr-prefix[unreachable]+mod)%mod;  ///Add mod to make sure that "tr-sums[unreachable]" is not negative.
            }
            dp[i][j]=tr;
            if(j>0)pre[j]=(pre[j-1]+dp[i][j])%mod;
            else pre[j]=1;
        }
        prefix=pre;
      }
      cout<<dp[n][k];
}

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

int main()
{
    ll n,m;
    cin>>n>>m;
    ll k[m],s[m][11],p[m],j,i,l;
    for(i=0;i<m;i++)
    {
        cin>>k[i];
        for(j=0;j<k[i];j++)
        {
            cin>>s[i][j];
        }
    }
    for(i=0;i<m;i++)
    {
        cin>>p[i];
    }
    ll count=0;
    for(i=0;i<(ll)pow(2,n);i++)
    {
        vector<ll>v;
        j=i;
        while(j>0)
        {
            v.push_back(j%2);
            j=j/2;
        }
        ll siz=0;
        if(i==0)
            siz=0;
        else
            siz=v.size();
        for(j=siz;j<n;j++)
        {
            v.push_back(0);
        }
        reverse(v.begin(),v.end());
        ll flag=0;
        for(j=0;j<m;j++)
        {
            ll c=0;
            for(l=0;l<k[j];l++)
            {
                c=c^v[s[j][l]-1];
            }
            if(c!=p[j])
            {
                flag=1;
                break;
            }
        }
        if(!flag)
            count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll inf = 1e18;

string s;
int K;
int main(){
    cin>>s>>K;
    REP(i, 0, s.size()-1){
        if(s[i]!='a'&& 'z'-s[i]<K){
            K -= 'z'-s[i]+1;
            s[i]='a';
        }
    }
    s.back() = (s.back()-'a'+K)%('z'-'a'+1) + 'a';
    p(s);
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 100050;
const int inf = 0x3f3f3f3f;
const ll mod = 1e9 + 7;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
ll n, k;
ll ans;
ll f[N];
inline ll mi(ll a, ll b)
{
    ll ret = 1;
    a %= mod;
    while (b)
    {
        if (b & 1)
            ret *= a, ret %= mod;
        a *= a, a %= mod;
        b >>= 1;
    }
    return ret;
}

void solve()
{
    scanf("%lld%lld", &n, &k);
    for (ll i = k; i; --i)
    {
        f[i] = mi(k / i, n);
        for (ll j = i * 2; j <= k; j += i)
            f[i] -= f[j];
        ans += ((i * f[i] + mod) % mod) % mod;
        ans = (ans + mod) % mod;
    }
    cout << ans << '\n';
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >>N;
  vector<int> a(N);
  int i,alice=0,bob=0;
  for(i=0;i<N;i++){
    cin >>a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  for(i=0;i<N;i++){
  if(i%2==0){
    alice+=a.at(i);
  }else{
    bob+=a.at(i);
  }
  }
  cout <<alice-bob <<endl;
  
}

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

int main(){
  int a,b;
  cin >> a >> b;
  int ans=0;
  for(int i=a;i<=b;i++){
    if(i/10000==i%10 && i%10000/1000==i%100/10)ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <queue>
using namespace std;

#define PI 3.14159265358979323846264338327950L

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

    
    
        long long n;
        cin >> n;
        int ans = 0;
        for (long long  i = 2; i * i <= n; i++)
        {
            long long z = i;
            while (n % z == 0)
            {
                n /= z;
                ans++;
                z *= i;
            }
            while (n % i == 0)
            {
                n /= i;
            }
        }
        if (n > 1)
            ans++;
        cout << ans << endl;
    }


Measured memory_bytes: 3648
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define F first
    #define S second
    #define pb push_back
    #define mkp make_pair
    #define int long long
    #define ld long double

    #define all(x) x.begin(),x.end() 
    #define rall(x) x.rbegin(),x.rend()
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int INF = 1e15;
    const int MAX = 2e6 + 7;
    const int MOD =  1000000007;
    const long double PI  =3.141592653589793238463;
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ D $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    int sum;
    int a[MAX];
    int pwr[MAX],val[MAX];
    
    void solve()
    {
        cin>>n;
        n++;
        // deb(n)
        fo(i,0,n)
        cin>>a[i];
        // deb(a[0])
        pwr[0]=1;
        fo(i,1,MAX)
        {
            if(pwr[i-1]<=(int)1e18/2)
                pwr[i]=pwr[i-1]*2;
            else
                pwr[i]=pwr[i-1];
            // deb(pwr[i])
        }

        if(n==1)
        {
            // deb(1)
            if(a[0]==1)
                cout<<1<<endl;
            else
                cout<<-1<<endl;
            return;
        }

        if(a[0]!=0)
        {
            cout<<-1<<endl;
            return;
        }
        sum=0;
        rfo(i,n-1,0)
        {
            // maxi=pwr[i];
            val[i]=min(pwr[i],sum+a[i]);
            sum=val[i];
            // deb(val[i])
        }
        sum=0;

        fo(i,0,n-1)
        {
            if((val[i]-a[i])<=0)
            {
                // deb(i)
                cout<<-1<<endl;
                return;
            }
            if((val[i]-a[i])*2<val[i+1])
            {
                val[i+1]=(val[i]-a[i])*2;
            }
            sum+=val[i];
        }
        if(val[n-1]-a[n-1]<0)
        {
            cout<<-1<<endl;
            return;
        }
        else
        sum+=val[n-1];

        cout<<sum<<endl;
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          THE GAME STARTS HERE                             //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        cout.tie(NULL);
        
        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

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

int main(){
    int N,M,C;
    cin >> N >> M >> C;
    int A[N][M],B[N],D[N]={0},cnt=0;
    for (int j=0;j<M;j++) cin >> B[j];
    for (int i=0;i<N;i++){
        for (int j=0;j<M;j++){
            cin >> A[i][j];
            D[i] += A[i][j]*B[j];
        }
        if(D[i]+C>0) cnt+=1;
    }
    cout << cnt << endl;
}





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

vector<int> G[100001];
int N,K;
queue<int>T;
typedef pair<int,int> edge;

map<edge,int> E;
edge es[100001];
bool used[100001];
int cl[100001];

int main(void){
    cin >>N;
    rep(i,N-1){
        int a,b;
        cin >> a>>b;
        G[a].push_back(b);
        G[b].push_back(a);
        es[i] = make_pair(a,b);
    }
    for(int i=1;i<=N;i++){
        K=max(K,(int)G[i].size());
        //for(int j=0;j<G[i].size();j++)cout << i <<" " <<  G[i][j] << endl;
    }
    //fill(cl,cl+N+1,1);
    T.push(1);
    used[1] = true;
    while(!T.empty()){
        int u = T.front();T.pop();
        int tc = 1;
        for(int i=0;i<G[u].size();i++){
            int v = G[u][i];
            if(!used[v]){
                if(tc == cl[u])tc++;
                cl[v] = E[make_pair(u,v)] = E[make_pair(v,u)] = tc++;
                T.push(v);
                used[v] = true;
            }
        } 
    }
    
    //for(int i=1;i<=N;i++)cout << cl[i] << endl;
    cout << K << endl;
    rep(i,N-1)cout << E[es[i]] << endl; 
}


Measured memory_bytes: 19840
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

int main() {
    string s, t; cin >> s >> t;
    int len = s.size();
    vector<vector<int>> pos(26);
    rep(i,len) pos[s[i]-'a'].push_back(i+1);
    rep(i,len) pos[s[i]-'a'].push_back(i+len+1);

    ll ans = 0;
    ll now = 0;
    rep(i,t.size()) {
        int a = t[i]-'a';
        if (pos[a].size() == 0) {
            cout << -1 << endl;
            return 0;
        }
        now = *upper_bound(pos[a].begin(), pos[a].end(), now);
        if (now >= len) {
            now -= len;
            ans += len;
        }
    }
    ans += now;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
//#define ll __int128
//#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define y1 y122
#define int long long

/*
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
/*
#pragma comment(linker, "/STACK: 20000000005")
*/


using namespace std;

const int N = 200005, MOD = 998244353;

int n, a[N];
map < int, int > M;
int ans;

main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        ans += M[a[i]];
        M[a[i]]++;
    }
    for (int i = 1; i <= n; i++)
        cout << ans + 1 - M[a[i]] << endl;
    return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

using namespace std;

signed main() {
	int N;
	cin >> N;

	int ans = 0;
	FOR(i, 1, 10) FOR(j, 1, 10) if (i*j == N) ans = 1;

	if (ans) Yes;
	else No;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define gc getchar
#define pc putchar
#define fi first
#define queue QQQ
#define se second
#define debug(x) cout << #x" = " << x << endl;
#define pp(x,y) cout << "pp: " << x << " " << y << endl;
#define rank __RANK
inline ll read(){
	register ll x=0,f=1;register char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
#define rd read
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
const int maxn = 1e5+233;
int dis[maxn],dep[maxn];
vector<int> e[maxn];
int n,k,ans;
void dfs(int u,int fa){
	dis[u] = dep[u];
	for(auto v : e[u]){
		dep[v] = dep[u] + 1;
		dfs(v,u);
		dis[u] = max(dis[u],dis[v]);
	}
	if(fa != 1 && u != 1 && dis[u] - dep[u] == k-1){
		++ans;
		dis[u] = 0;
	}
}
int main(){
	n = rd(),k = rd();
	Rep(i,1,n){
		int x = rd();
		if(i==1) ans += (x != 1); else
		e[x] . push_back(i);
	}
	dfs(1,0);
	writeln(ans);
	return 0;
}

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

int main(void){
    string s;
    cin >> s;
    int a=0;
    string ans;
    rep(i, s.size()){
        char ch[1];
        ch[0] = s.at(i);
        a += atoi(ch);
    }
    if(a%9 == 0) ans = "Yes";
    else ans = "No";
    cout << ans << endl;
    return 0;
}

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

int main(){
  int box[3];
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b==c){
    cout<<"Yes"<<endl;
    return 0;
  }
  if(a+c==b){
    cout<<"Yes"<<endl;
    return 0;
  }
  if(b+c==a){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
  
    
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N,K,Q =map(int,input().split())
lis = [0 for _ in range(N)]
for _ in range(Q):
    s = int(input())
    lis[s-1] += 1

ans = ["Yes" if i+K-Q>0 else "No" for i in lis]
print("\n".join(ans))

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

int main(int argc, char *argv[]) {
  int N;
  int A;
  int B;
  cin >> N;
  if(N == 1) {
    cout << "Hello World" << endl;
    return 0;
  }
  cin >> A;
  cin >> B;
  cout << A+B << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

vector<int> w; vector<ll> v;
vector<vector<ll>> dp;

int main() {
	int n, W; cin >> n >> W; w.resize(n); v.resize(n);
	for (int i = 0; i < n; i++) cin >> w[i] >> v[i];
	dp.resize(2, vector<ll>(W + 1, 0));
	for(int i = 1; i <= n; i++)
		for (int j = 1; j <= W; j++) {
			dp[i & 1][j] = max({ dp[i & 1][j], dp[(i ^ 1) & 1][j], dp[i & 1][j - 1] });
			if (j >= w[i - 1]) dp[i & 1][j] = max(dp[i & 1][j], dp[(i ^ 1) & 1][j - w[i - 1]] + v[i - 1]);
		}
	cout << dp[n & 1][W] << '\n';
	cin.ignore(2); return 0;
}

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

int main()
{
  int N, Y;
  cin >> N >> Y;
  int res10000 = -1, res5000 = -1, res1000 = -1;
  for (int a = 0; a <= N; a++)
  {
    for (int b = 0; b <= N - a; b++)
    {
      int c = N - a - b;
      int total = 10000 * a + 5000 * b + 1000 * c;
      if (total == Y)
      {
        res10000 = a;
        res5000 = b;
        res1000 = c;
      }
    }
  }
  
  cout << res10000 << " " << res5000 << " " << res1000 << endl;
}

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)
#define all(x) (x).begin(),(x).end()

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; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int N, K, Q;
    cin >> N >> K >> Q;

    vector<int> A(N, K - Q);

    rep(i, Q) {
        int point;
        cin >> point;
        A[point - 1]++; 
    }

    rep(i, N) {
        if (A[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn=1e5+100;
int n, arr[maxn];
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0);
    cin>>n;
    int mx=-INT_MAX, mn=INT_MAX;
    for(int i=0; i<n; i++)
    {
        int a;
        cin>>a;
        mn=min(mn, a);
        mx=max(mx, a);
    }
    cout<<mx-mn<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int A, B, C; cin >> A >> B >> C;
	int res = 0;
	if(A % 2 == 0 && A == B && B == C) {
		cout << "-1" << endl;
		return 0;
	}
	while (true)
	{
		if(A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
			cout << res << endl;
			return 0;
		}
		int a = (B + C) / 2;
		int b = (A + C) / 2;
		int c = (A + B) / 2;
		A = a, B = b, C = c;
		res++;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int N,M,C,A[20],B[20];
	int ans = 0;
	int count = 0;
	scanf("%d %d %d", &N,&M,&C);
	for (int i = 0; i < M; i++) scanf("%d", &B[i]);
	for (int i = 0; i < N; i++) {
		for (int j=0; j < M; j++) {
			scanf("%d", &A[j]);
			ans += A[j] * B[j];
		}
		if (ans+C > 0)count++;
		ans = 0;
	}
	printf("%d\n", count);

}

Measured memory_bytes: 256
// Problem Code: abc172_e

#include <iostream>
#include <numeric>
#include <vector>
#include <functional>

using namespace std;

int inverse(long long a, int m) {
	// fermat's little theorem
	int x = 1, n = m - 2;
	while (n) {
		if (n & 1)
			x = (x * a) % m;
		a = (a * a) % m;
		n >>= 1;
	}
	return x;
}

int neq(int N, int M) {
	int mod = 1e9 + 7;
	vector<long long> fact(M + 1), inv_fact(M + 1);

	// preprocess the factorials and inverse factorials
	fact[0] = 1;
	for (int i = 1; i <= M; i++)
		fact[i] = (i * fact[i - 1]) % mod;
	inv_fact[M] = inverse(fact[M], mod);
	for (int i = M - 1; i >= 0; i--)
		inv_fact[i] = ((i + 1) * inv_fact[i + 1]) % mod;
	
	// helper function to compute n choose r
	auto nCr = [&](int n, int r) {
		int den = (inv_fact[r] * inv_fact[n - r]) % mod;
		return (fact[n] * den) % mod;
	};

	int ways_b = 0, neg = 1;
	long long ways_a = (nCr(M, N) * fact[N]) % mod;

	for (int j = 0; j <= N; j++) {
		int ways = (nCr(N, j) * nCr(M - j, N - j)) % mod;
		ways = (ways * fact[N - j]) % mod;
		ways = (neg * ways + mod) % mod;
		ways_b = (ways_b + ways) % mod;
		neg *= -1;
	}

	return (ways_a * ways_b) % mod;
}

int main() {
	int N, M;
	cin >> N >> M;
	cout << neq(N, M);
	return 0;
}

Measured memory_bytes: 11076
x, y = map(int, input().split())
a = {1, 3, 5, 7, 8, 10, 12}
b = {4, 6, 9, 11}
c = {2}

print('Yes' if (x in a and y in a) or (x in b and y in b) or (x in c and y in c) else 'No')

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

char s[100010],a[5]="bpqd";
bool m[128][128];
int main(){
	scanf("%s",s);
	int n=strlen(s);
	if(n%2!=0){
		printf("No\n");
		return 0;
	}
	for(int i=0;i<4;i++)
		m[a[i]][a[3-i]]=true;
	for(int i=0;i<n/2;i++)
		if(!m[s[i]][s[n-i-1]]){
			printf("No\n");
			return 0;
		}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    cout << a * b;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
typedef long long int ll;
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];


int main(){
  ll n; cin >>n;
  vector<int> a(n);
  cinf(n,a);
  ll cnt1=0;
  ll cnt2=0;
  for(int i=0;i<n;i++){
    if(a[i]%2==1)cnt1++;
    else cnt2++;
  }
  ll ans=pow(3,n)-pow(1,cnt1)*pow(2,cnt2);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

  

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

int N, A, x[55];
ll dp[55][3000], tot;

int main () {
        cin >> N >> A;
        dp[0][0] = 1ll;
        fo(i, 0, N) {
                cin >> x[i];
                for (int n = N; n--; ) for (int s = 3000; s--; ) if (dp[n][s]) {
                        dp[n+1][s+x[i]] += dp[n][s];
                }
        }
        fo(i, 1, N+1) fo(s, 0, 3000) if (A*i == s) {
                tot += dp[i][s];
        }
        printf("%lld\n", tot);
        return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using piii = pair<int, pair<int, int>>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

ll prim(int s, const Graph<pii> &G) {
    int N = G.size();
    vector<bool> isused(N);
    priority_queue<pii, vector<pii>, greater<pii>> que;
    que.push({0, s});
    ll res = 0;
    while (!que.empty()) {
        int c = que.top().first;
        int v = que.top().second;
        que.pop();
        if (isused[v])
            continue;
        isused[v] = true;
        res += c;
        for (auto np : G[v]) {
            int nv = np.second;
            if (isused[nv])
                continue;
            que.push(np);
        }
    }
    return res;
}

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

    int N;
    cin >> N;
    vector<pii> x(N), y(N);
    for (int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        x[i] = {a, i};
        y[i] = {b, i};
    }

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    Graph<pii> G(N);
    for (int i = 0; i < N - 1; ++i) {
        {
            int a = x[i].second, b = x[i + 1].second;
            int c = x[i + 1].first - x[i].first;
            G[a].push_back({c, b});
            G[b].push_back({c, a});
        }
        {
            int a = y[i].second, b = y[i + 1].second;
            int c = y[i + 1].first - y[i].first;
            G[a].push_back({c, b});
            G[b].push_back({c, a});
        }
    }

    cout << prim(0, G) << endl;
    return 0;
}


Measured memory_bytes: 10616
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
ll p[500005],inv[500005],hell=pow(10,9)+7;
ll exp(ll x,ll y){
	ll res=1;
	x%=hell;
	while(y){
		if(y&1)
		res=(res*x)%hell;
		y>>=1;
		x=(x*x)%hell;
	}
	return res;
}
ll bin(ll n,ll r){
	ll res=(p[n]*inv[n-r])%hell;
	res=(res*inv[r])%hell;
	return res;
}
ll per(ll n,ll r){
	return (p[n]*inv[n-r])%hell;
}
void solve(){
	ll n,m;
	cin>>n>>m;
	ll res=0;
	for(ll i=0;i<=n;i++){
		ll val=(bin(n,i)*per(m,n))%hell;
		val=(val*per(m-i,n-i))%hell;
		if(i%2)
		res=(res-val)%hell;
		else
		res=(res+val)%hell;
	}
	if(res<0)
	res+=hell;
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    p[0]=inv[0]=1;
    for(ll i=1;i<500005;i++){
		p[i]=(i*p[i-1])%hell;
		inv[i]=exp(p[i],hell-2);
	}
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++)
    solve();		
}


Measured memory_bytes: 11460
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
using namespace std;
typedef long long ll;
const int INF = 1001001001;


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

int main() {
    int n;
    ll X;
    cin >> n >> X;
    vector<ll> x(n);

    rep(i, n) cin >> x[i];
    rep(i, n) x[i] = abs(X - x[i]);

    rep(i, n){
        if(i==0) continue;

        x[i] = gcd(x[i-1], x[i]);
    }

    cout << x[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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

const ll mod=1e9+7;

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    cout << 'A' << b[0] << 'C' << endl;
    return 0;
}



Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll x, k, d;
    cin >> x >> k >> d;
    if(abs(x) > abs(k * d)){
        cout << abs(x) - abs(k * d) << endl;
        return 0;
    }
    ll p = x / d;
    ll q = x % d;
    k -= abs(p);
    q = abs(q);
    if(k % 2 == 0)
        cout << q << endl;
    else cout << abs(q-d) << endl;
    return 0;
}

Measured memory_bytes: 3636
def main():
    a, b, c = map(int, input().split())
    k = int(input())
    
    while k != 0 and a >= b:
        b *= 2
        k -= 1
    while k != 0 and b >= a:
        c *= 2
        k -= 1
    if a < b < c:
        print('Yes')
    else:
        print('No')

    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9188
import sys
from collections import defaultdict
from collections import deque
input = sys.stdin.readline

new_cards = defaultdict(int)
n, m = map(int, input().split())
A = deque(sorted(list(map(int, input().split()))))

for i in range(m):
    b, c = map(int, input().split())
    new_cards[c] += b

for card, count in sorted(new_cards.items(), reverse=True):
    for i in range(count):
        if A[0] < card:
            A.append(card)
            A.popleft()
        else:
            print(sum(A))
            exit()

print(sum(A))



Measured memory_bytes: 27804
inf=float("inf")
def merge(a,left,mid,right):
    count=0
    n1=mid-left
    n2=right-mid
    L=[0]*(n1+1)
    R=[0]*(n2+1)
    for i in range(n1):
        L[i]=a[left+i]
    for i in range(n2):
        R[i]=a[mid+i]
    L[n1]=inf
    R[n2]=inf
    i=0
    j=0
    for k in range(left,right):
        count+=1
        if L[i]<=R[j]:
            a[k]=L[i]
            i+=1
        else:
            a[k]=R[j]
            j+=1
    return count

def mergeSort(a,left,right):
    if left+1<right:
        mid=(left+right)//2
        return mergeSort(a,left,mid)+mergeSort(a,mid,right)+merge(a,left,mid,right)
    return 0
n=int(input())
*a,=map(int,input().split())
ans=mergeSort(a,0,n)
print(*a)
print(ans)



Measured memory_bytes: 61668
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <bitset>
using namespace std;

char str[101];
int len;

void Print(int a, int b, int l, int r) {
  for (int i = l; i < r; ++i) {
    str[len++] = i % (a + b) < a ? 'A' : 'B';
  }
}

int main(void) {
  int q;
  scanf("%d", &q);
  while (q--) {
    int a, b, c, d;
    scanf("%d%d%d%d", &a, &b, &c, &d);
    len = 0;
    bool rev = false;

    if (a == b) {
      --c;
      Print(1, 1, c, d);
      for (int i = 0; i < len; ++i) {
        putchar(str[i]);
      }
      putchar('\n');
      continue;
    }

    if (b > a) {
      rev = true;
      swap(a, b);
      c = a + b - c + 1;
      d = a + b - d + 1;
      swap(c, d);
    }
    --c;

    int x = (a + b) / (b + 1);
    int ya = x == 1 ? b : ((long long)a * x - b) / ((long long)x * x - 1);
    int yb = (b - ya) / x;
    int za = a - (long long)ya * x - yb;
    int zb = b - (long long)yb * x - ya;

    int m1 = (long long)ya * (x + 1);
    int m2 = m1 + za;
    int m3 = m2 + zb;

    if (c < m1) {
      if (d <= m1) {
        Print(x, 1, c, d);
        goto end;
      }
      Print(x, 1, c, m1);
      c = m1;
    }
    if (c < m2) {
      if (d <= m2) {
        Print(1, 0, c - m1, d - m1);
        goto end;
      }
      Print(1, 0, c - m1, m2 - m1);
      c = m2;
    }
    if (c < m3) {
      if (d <= m3) {
        Print(0, 1, c - m2, d - m2);
        goto end;
      }
      Print(0, 1, c - m2, m3 - m2);
      c = m3;
    }
    Print(1, x, c - m3, d - m3);

  end:
    if (rev) {
      for (int i = len - 1; i >= 0; --i) {
        putchar('A' + 'B' - str[i]);
      }
    } else {
      for (int i = 0; i < len; ++i) {
        putchar(str[i]);
      }
    }
    putchar('\n');
  }
  return 0;
}


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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, t; cin >> n >> t;
    vector<pair<int,int>> st(n);
    for(auto &i : st) cin >> i.first >> i.second;
    sort(st.begin(), st.end());
    for(int i = 0; i < n; i++){
        if(st[i].second <= t){
            cout << st[i].first << "\n";
            return 0;
        }
    }
    cout << "TLE\n";
    return 0;        
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define mu(x) x.resize(unique(all(x))-x.begin());
#define srt(x) sort(all(x));
#define rev(x) reverse(all(x));
#define each(x,a) for(auto& x:a)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define PER(i,a,b) for(int i=a;i>=b;i--)
#define debug(x) cerr<<#x<<" "<<x<<"\n";
#define debug_v(x) { cerr<<#x<<"\n";  each(y,x) cerr<<y<<" "; cerr<<'\n';}
#define debug_vp(x) { cerr<<#x<<"\n";  each(y,x) cerr<<y.ff<<" "<<y.ss<<'\n'; cerr<<'\n';}
#ifndef BTW
	#define cerr if(false)cerr
#endif
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

int main(){
	fastio;
	ll a, b, c;
	cin>>a>>b>>c;
	if(c - a - b < 0) {
		cout<<"No";
		return 0;
	}
	if(4 * a * b < (c - a - b) * (c - a-b)){
		cout<<"Yes";
	} else {
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){

  int Climb_up[150],Climb_down[150];
  int n,t;
  int Box[150];
  int UM,DM;

  cin >> t;
  for( int i = 0 ; i < t ; i++ ){

    UM = 0;
    DM = 0;

    cin >> n;
    for( int j = 0 ; j < n ; j++ ){

      cin >> Box[j];

      if( j > 0 ){
	if( Box[j-1] < Box[j] ){
	  
	  Climb_up[j] = Box[j] - Box[j-1];
	  Climb_down[j] = 0;
	  
	}

	else if( Box[j-1] > Box[j] ){
	 
	  Climb_down[j] = Box[j-1] - Box[j];
	  Climb_up[j] = 0;

	}

	else if( Box[j-1] == Box[j] ){
	 
	  Climb_up[j] = 0;
	  Climb_down[j] = 0;
	  
	}

      }

    }


    for( int j = 0 ; j < n ; j++ ){
      
      if( j > 0 ){

      if( UM < Climb_up[j] ) UM = Climb_up[j];
      if( DM < Climb_down[j] ) DM = Climb_down[j];

      }

    }

    cout << UM << " " << DM << endl;

  }

  return 0;

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const int MAX = 1005;

int lcs[MAX][MAX];

int main() {
  int q, nx, ny;
  string x, y;
  cin >> q;

  rep(i, q) {
    cin >> x >> y;
    nx = x.size();
    ny = y.size();

    rep(i, nx+1) {
      rep(j, ny+1) {
        lcs[i][j] = 0;
      }
    }

    FOR(i, 1, nx+1) {
      FOR(j, 1, ny+1) {
        if (x[i-1] == y[j-1]) {
          lcs[i][j] = lcs[i-1][j-1] + 1;
        }
        else {
          lcs[i][j] = max(lcs[i-1][j], lcs[i][j-1]);
        }
      }
    }

    cout << lcs[nx][ny] << endl;
  }

  
  return 0;
}


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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int red_cnt = 0;
    int blue_cnt = 0;
    REP(i, s.size()) {
        if(s[i] == '0') red_cnt++;
        else blue_cnt++;
    }
    cout << min(red_cnt, blue_cnt) * 2 << ln;
    return 0;
}


Measured memory_bytes: 512
import java.util.AbstractMap;
import java.util.ArrayDeque;
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        char[][] map = new char[H][];
        for(int i = 0 ; i < H ; i++)
            map[i] = sc.next().toCharArray();
        long[][] dp = new long[H+1][W+1];
        dp[1][1] = 1;
        ArrayDeque<P> deq = new ArrayDeque<P>();
        deq.add(new P(1,1));
        while (!deq.isEmpty())
        {
            P current = deq.remove();
            if(current.x >H || current.y >W )
                continue;
            if(map[current.x-1][current.y-1] == '#')
                continue;
            deq.add(new P(current.x ,current.y+1));
            deq.add(new P(current.x + 1 ,current.y));
            dp[current.x][current.y] =  dp[current.x-1][current.y] + dp[current.x][current.y-1]+dp[current.x][current.y];
            dp[current.x][current.y] = dp[current.x][current.y]% (1000000000+7);
            map[current.x-1][current.y-1] = '#';
        }
        System.out.println(dp[H][W]% (1000000000+7));

    }
    static class P extends AbstractMap.SimpleImmutableEntry<Integer,Integer>{
        int x , y;
        public P(int a , int b)
        {
            super(a,b);
            x =a ;
            y =  b;
        }
    }
}


Measured memory_bytes: 74852
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define all(v) v.begin(),v.end()
#define fi first
#define se second
const int inf = 1e9;
int mod = 1e9+7;

int dp[2000][2000], C[2000][2000];
void init(){
	C[0][0] = 1;
	rrep(i,1000)rrep(j,1000){
		C[i][0] = 1;
		C[i][j] = (C[i-1][j-1]+C[i-1][j])%mod;
	}
}

int fac[2000], inv[2000];
int Pow(int x, int k){
	int res = 1;
	while(k > 0){
		if(k&1)res = (x*res)%mod;
		x = (x*x)%mod;
		k >>= 1;
	}
	return res;
}
void Factrial(int n){
	fac[0] = inv[0] = 1;
	rrep(i,n){
		fac[i] = (fac[i-1]*i)%mod;
		inv[i] = Pow(fac[i], mod-2);
	}
}
int perm(int n, int k){
	int res = (fac[n]*inv[n-k])%mod;
	return res;
}

signed main(){
	int n, a, b, c, d;
	scanf("%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d);
	init();
	Factrial(1002);
	
	dp[a-1][0] = 1;
	repi(i,a,b+1)rep(j,n+1){
		dp[i][j] = dp[i-1][j];
		int s = 1;
		repi(k,c,d+1){
			if(j-i*k < 0)break;
			/*s = (s*C[n-(j-i*k)][i])%mod;
			int tmp = (s*inv[k])%mod;
			dp[i][j] += (dp[i-1][j-i*k]*tmp)%mod;*/
			int tmp1 = (dp[i-1][j-i*k]*perm(n-j+i*k,i*k))%mod;
			int tmp2 = (Pow(inv[i], k)*inv[k])%mod;
			dp[i][j] += (tmp1*tmp2)%mod;
			dp[i][j] %= mod;
		}
	}
	/*dp[a-1][0]=fac[n];
	repi(i,a,b+1){
		rep(j,n+1){
			dp[i][j]=dp[i-1][j];
			if(i*c<=j){
				int m=min(d-c+1,1+(j-i*c)/i);
				rep(k,m){
					int res=dp[i-1][j-i*(c+k)]*Pow(inv[i],c+k)%mod;
					dp[i][j]+=res*inv[c+k]%mod;
				}
				dp[i][j]%=mod;
			}
		}
	}*/
	printf("%lld\n",dp[b][n]);
	return 0;
}


Measured memory_bytes: 32512
n,d = gets.split.map(&:to_i)

ans = 0
dots = n.times.map{gets.split.map(&:to_f)}
(0..n-2).each do |i|
  y = dots[i]
  (i+1..n-1).each do |j|
    z = dots[j]
    dist = (d.times.map{|k| (y[k]-z[k])**2}.inject(:+))**(1/2.0)
    ans += 1 if dist == (dist * 10).to_i / 10.0
  end
end

puts ans

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

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


    long long sum = 0;
    vector<long long> point;
    for (long long i = 1; i <= n; ++i){
        sum += i;
        point.push_back(i);
        if (sum > n){
            long long remove_i = sum - n;
            point.erase(point.begin() + remove_i - 1 );
            break;
        }else if (sum == n){
            break;
        }
    }

    for (const auto& v : point) {
        cout << v << endl;
    }

}

Measured memory_bytes: 3708