akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
#define EPS 1e-15
using namespace std;
double calc(vi L,vi R){
  map<ll,ll>cnt;
  ll n = L.size();
  for(int i=0;i<n;i++){
    cnt[(L[i]+R[i+1])%256]++;
  }
  double ret = 0;
  for(auto a:cnt){
    ret += (double)((double)a.S/n)*log((double)a.S/n);
  }
  return -ret;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  while(cin>>n,n){
    vi A(n);
    for(auto &a:A)cin>>a;
    vi R(n+1);
    double mi = llINF;
    ll as = 0,aa = 0,ac = 0;
    for(ll s = 0;s <= 15;s++){
      for(ll a = 0;a <= 15;a++){
	for(ll c = 0;c <= 15;c++){
	  R[0] = s;
	  for(int i=1;i<=n;i++){
	    R[i] = (a*R[i-1]+c)%256;
	  }
	  double entropy = calc(A,R);
	  if(mi - entropy <= EPS){
	    /* cout<<"!"<<endl;
	    cout<<as<<" "<<aa<<" "<<ac<<endl;
	    cout<<s<<" "<<a<<" "<<c<<endl;
	    */	    if(as > s){
	      as = s;aa = a;ac = c;
	    }else if(as == s){
	      if(aa > a){
		as = s;aa = a;ac = c;
	      }else if(aa == a){
		if(ac > c){
		  as = s;aa = a;ac = c;
		}
	      }
	    }
	  }else if(entropy < mi){
	    mi = entropy;
	    as = s;aa = a;ac = c;
	  }
	  // if(s == 0 && a == 4 && c == 3){
	  //    cout<<entropy<<" "<<s<<a<<c<<endl;
	  //  }
	  //  if(s == 0 && a == 11 && c == 5){
	  //    cout<<entropy<<" "<<s<<a<<c<<endl;
	  //  }
	}
      }
    }
    cout<<as<<" "<<aa<<" "<<ac<<endl;
  }
  return 0;
}



Measured memory_bytes: 3488
#include <iostream>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int a,b;
  char N;
  cin >>a;
  cin >> N;
  cin >> b;
  if(N=='+'){
	
  	cout << a+b<<endl;
  }else{
	cout << a-b<<endl;
  }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    vector<long long> A;
    vector<long long> X;
    vector<long long> Y;
    int N;
    cin >> N;
    A.resize(3*N);
    X.resize(N+1);
    Y.resize(N+1);
    for ( int i = 0; i < 3*N; i++ ) {
        cin >> A[i];
    }
    
    long long sum = 0;
    priority_queue< long long > pq_des;
    priority_queue< long long,vector<long long>, greater<long long> > pq_asc;
    
    for ( int i = 0; i < N; i++ ) {
        pq_asc.push( A[i] );
        sum += A[i];
    }
    X[0] = sum;
    
    for ( int i = N; i < 2*N; i++ ) {
        
        if ( pq_asc.top() < A[i] ) {
            sum -= pq_asc.top();
            sum += A[i];
            
            pq_asc.pop();
            pq_asc.push( A[i] );
        }
        
        X[i-N+1] = sum;
    }
    
    sum = 0;
    for ( int i = 3*N-1; i >= 2*N; i-- ) {
        pq_des.push( A[i] );
        sum += A[i];
    }
    Y[N] = sum;
    
    for ( int i = 2*N-1; i >= N; i-- ) {
        
        if ( pq_des.top() > A[i] ) {
            sum -= pq_des.top();
            sum += A[i];
            
            pq_des.pop();
            pq_des.push(A[i]);
        }
        
        Y[N+(i-2*N)] = sum;
    }
    
    long long ans = LLONG_MIN;
    for ( int i = 0; i <= N; i++ ) {
        ans = max( ans, X[i]-Y[i] );
    }
    
    
    cout << ans << endl;
    
    
    return 0;
}

Measured memory_bytes: 6516
#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;
    cin >> a;
    cout << a + a * a + a * a * a;
}


Measured memory_bytes: 3600
#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;i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#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=1001001001; const long long INFLL=1001001001001001001ll;
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.first >> p.second; 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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
    #ifdef int
        cerr<<"\x1b[7m"<<"'int' is defined as 'long long' !!!!"<<"\x1b[m"<<endl;
    #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

int dp[2][420][420];
// dp[k%2][x][y] := k番目まで見た時Aの合計がx,Bの合計がyになるための最小コスト
signed main() {
    REP(i,420) REP(j,420) dp[0][i][j]=dp[1][i][j]=INFLL;

    int n,ma,mb;
    cin>>n>>ma>>mb;
    vi a(n),b(n),c(n);
    REP(i,n) {
        cin>>a[i]>>b[i]>>c[i];
    }
    dp[0][a[0]][b[0]]=c[0];
    dp[0][0][0]=0;
    FOR(k,1,n) REP(i,401) REP(j,401)
        if(dp[(k-1)%2][i][j]!=INFLL) {
            chmin(dp[k%2][i+a[k]][j+b[k]],dp[(k-1)%2][i][j]+c[k]);
            chmin(dp[k%2][i][j],dp[(k-1)%2][i][j]);
        }

    int ans=INFLL;
    for(int k=1; k*ma<410 && k*mb<410; k++) chmin(ans,dp[(n-1)%2][k*ma][k*mb]);
    cout<<(ans==INFLL?-1:ans)<<endl;
    return 0;
}


Measured memory_bytes: 3072
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN=705,MAXM=MAXN*MAXN/2;

bool adj[MAXN][MAXN];

int N,M;
int col[MAXN];
bool vis[MAXN],flag=true;
int id;
int cnt[MAXN][2];
bool dp[MAXN][MAXN];

void dfs(int u,int c)
{
	if(vis[u]&&col[u]!=c)
	{flag=false;return;}
	if(vis[u])return;
	cnt[id][c]++;
	vis[u]=true;
	col[u]=c;
	for(int v=1;v<=N;v++)
		if(!adj[u][v]&&u!=v)
			dfs(v,c^1);
}

int main()
{
	int a,b;
	scanf("%d%d",&N,&M);
	for(int i=1;i<=M;i++)
	{
		scanf("%d%d",&a,&b);
		adj[a][b]=adj[b][a]=true;
	}
	for(int i=1;i<=N;i++)
	{
		if(!vis[i])
		{
			id++;
			dfs(i,0);
		}
	}
	
	if(flag==false)
	{
		puts("-1");
		return 0;
	}
	
	dp[0][0]=true;
	for(int i=1;i<=id;i++)
		for(int j=0;j<=N;j++)
		{
			if(j>=cnt[i][0])
				dp[i][j]|=dp[i-1][j-cnt[i][0]];
			if(j>=cnt[i][1])
				dp[i][j]|=dp[i-1][j-cnt[i][1]];
		}
		
	int ans=0x7FFFFFFF;
	for(int i=1;i<=N;i++)
		if(dp[id][i])
			ans=min(ans,i*(i-1)/2+(N-i)*(N-i-1)/2);
		
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
const int maxn=305;
int n,k,m,f[maxn][maxn],C[maxn][maxn],g[maxn][maxn];
inline int add(int x,int y){ x+=y; return x>=m?x-m:x;}
inline void ADD(int &x,int y){ x+=y; if(x>=m) x-=m;}

inline void solve(){
	const int ha=m;
	
	C[0][0]=1;
	for(int i=1;i<=n;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++) C[i][j]=add(C[i-1][j-1],C[i-1][j]);
	}
	
	fill(g[0],g[0]+k+1,1);
	for(int i=0;i<=k;i++) g[1][i]=k-i+1,f[1][i]=1;
	
	for(int i=2;i<=n;i++){
		// calc f[i][]
		
		for(int j=0;j<=k;j++)
		    for(int u=1;u<i;u++) ADD(f[i][j],C[i-2][u-1]*(ll)g[u][j+1]%ha*(ll)f[i-u][j]%ha);
		
		// prepare prefix sum
		
		for(int j=k;j>=0;j--) g[i][j]=add(f[i][j],g[i][j+1]);
	} 
}

int main(){
	scanf("%d%d%d",&n,&k,&m),n++;
	solve(),printf("%d\n",f[n][0]);
	return 0;
}

Measured memory_bytes: 1280
fn = lambda: map(int, input().split())
D, G = fn()
p, c = [0] * D, [0] * D
complete_scores = [0] * D
for i in range(D):
    p[i], c[i] = fn()
    complete_scores[i] = 100 * (i + 1) * p[i] + c[i]

def calc(x):
    value = 0
    count = 0
    i_unused = None
    for i, xi in enumerate(x):
        if xi == '1':
            value += complete_scores[i]
            count += p[i]
        else:
            i_unused = i
    if i_unused is not None:
        for _ in range(p[i_unused]):
            if value >= G:
                break
            else:
                value += (i_unused + 1) * 100
                count += 1
    if value < G:
        return float('inf')
    else:
        return count

fmt = '0{}b'.format(D)
x = format(0, fmt)
best_count = float('inf')
while len(x) <= D:
    best_count = min(calc(x), best_count)
    x = format(int(x, 2) + 1, fmt)

print(best_count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i;
    string s;
    cin >> s;
    int k=s.length();
    for(i=0;i<k;i++)
    {
       if(s[i]=='?')
        {


            cout << 'D';
            s[i]='D';
        }
        else{
            cout << s[i];
        }



    }
    cout << endl;
}


Measured memory_bytes: 3752
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = 1;
    REP(i, 1, N) {
        ans = (ans * i) % mod;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++)cin >> p[i];

    sort(p.begin(), p.end());
    for (int i = 0; i < n; i++) {
        if (p[i] >= n - i) {
            cout << n - i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3108
#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 FORALL(i, m) for( auto i = m.begin(); i != m.end() ; ++i )
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define TM_T template <class T>
using namespace std;
typedef long long ll;
TM_T T inp(){T it;cin >> it;return it;}

ll N;
vector<ll> li;
vector<vector<ll>> dp;

int input(){
  cin >> N;
  REP(i,N) li.push_back( inp<ll>() );
}

int main()
{
  input();
  
  REP(i,N){
    dp.push_back( vector<ll>() );
    REP(j,N) dp[i].push_back( -1000000000000000l );
  }
  REP(i,N) dp[i][N-1-i] = li[i];
  REPR(i,N-2){
    REP(j,i+1){
      ll ma = -1000000000000000l;
      ma = max(ma, li[j] - dp[j+1][i-j]);
      ma = max(ma, li[N-1-(i-j)]- dp[j][i-j+1]);
      dp[j][i-j] = ma;
    }
  }
  cout << dp[0][0] << endl;
}

Measured memory_bytes: 82688
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

nn = inputs[0][0]

# body
if $debugFlag
  p nn
end

if nn == 3 or nn == 5 or nn == 7
  puts "YES"
else
  puts "NO"
end


Measured memory_bytes: 1788
#include<iostream>
using namespace std;
long long a[200010],b[200010],n,sum;
int main()
{
    int i;
    cin>>n;
    for(i=1;i<=n;i++) 
    {
        cin>>a[i];
        b[a[i]]++;
    }
    for(i=1;i<=n;i++) sum+=(b[i]-1)*b[i]/2;
    for(i=1;i<=n;i++) cout<<sum-(b[a[i]]-1)<<endl;
    //cin>>i;
}
    


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

int main() {
    fastio;
    int h, w;
    cin >> h >> w;
    for (int i = 0; i <= w+1; ++i) cout << "#";
    cout << "\n";
    for (int i = 0; i < h; ++i) {
        string t; cin >> t;
        cout << "#" << t << "#\n";
    }
    for (int i = 0; i <= w+1; ++i) cout << "#";
    return 0;
}

Measured memory_bytes: 256
N=int(input())
L=input().split( )
#リストがmutableなので以下ではコピーできていない
#B=L
#S=L
B=L[:]
S=L[:]
for i in range(N):
    j=N-1
    while j>i:
        if B[j][1]<B[j-1][1]:
            temp =B[j]
            B[j]=B[j-1]
            B[j-1]=temp

        j-=1

for i in range(N):
    minj= i
    j=i
    while j<N:
        if S[j][1]<S[minj][1]:
            minj=j
            j+=1
            #print(S[minj])
        else:j+=1

#j+=1してねぇｗ
#if終了後に交換なので以下のインデントはifと同列
#じゃなくてifより上でwhileと同列
#jでなくてi
#この辺散々間違えたが、間違えた時の挙動が追いきれない
    temp =S[i]
    S[i]=S[minj]
    S[minj]=temp
    #print(S,i,minj)

for i in range(N):
    if i!=N-1:
        print(f"{B[i]}",end=" ")
    else:
        print(f"{B[i]}")
print("Stable")

for i in range(N):
    if i!=N-1:
        print(f"{S[i]}",end=" ")
    else:
        print(f"{S[i]}")
flag=1
for i in range(N):
    if B[i]!=S[i]:
        flag=0
if flag==1:
    print("Stable")
if flag==0:
    print("Not stable")



Measured memory_bytes: 5624
#include<bits/stdc++.h>
using namespace std;
vector<int>v;
int n,a[202020];
bool vis[202020];
long long k;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int p=1;
	while(!vis[p])
	{
		vis[p]=true;
		v.push_back(p);
		p=a[p];
	}
	int pp=0;
	while(v[pp]!=p)
	{
		pp++;
	}
	if(k<pp)
	{
		cout<<v[k]<<endl;
		return 0;
	}
	k-=pp;
	for(int i=0;i<pp;i++)
	{
		v.erase(v.begin());
	}
	cout<<v[k%v.size()]<<endl;
	return 0;
}

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

using namespace std;

using int64 = long long;

int main()
{
  string S;
  cin >> S;
  for(int i = 0; i < 4; i++) {
    if(S[i] == 'A' && S[i + 1] == 'C') {
      cout << "Yes" << endl;
      return (0);
    }
  }
  cout << "No" << endl;
}

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

int main(){
	int N,D,X;	cin>>N>>D>>X;
	int A[N];
	int sum=0;
	for(int i=0;i<N;i++){
		int c;	cin>>c;	
		sum += int((D-1)/c) + 1;
	}
	cout<<sum + X;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

 class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        boolean good=true;
        for(int i=1;i<4;i++){
            if(s.charAt(i)==s.charAt(i-1)){
                good=false;
            }
        }
        if(!good)
            System.out.println("Bad");
        else
            System.out.println("Good");
    }
}


Measured memory_bytes: 21716
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=2e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }
  

int sum[N];
  
 void solve() {
	  int n,k;
	  
	  cin>>n>>k;
	  
	  rep(i,1,N) 
	    sum[i]=sum[i-1]+i;
	  int ans=0;
	  
	  rep(i,k,n+2) {
		    int mn=sum[i-1];
		    int mx=sum[n]-sum[n-i];
		    //~ cout<<i<<" "<<mx<<" "<<mn<<endl;
		    ans+=mx-mn+1;
		    
		    ans%=mod;
		  }    
		  cout<<ans<<endl;  	  
						   
 }

    
int32_t main() {
	cool;
	int t=1;

	//cin>>t;
	while(t--)
	solve();


return 0;	   
}


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

int main(){
    //入力
    char a,b;
    cin >> a >> b ;

    //出力
    if((a=='H'&&b=='H')||(a=='D'&&b=='D')){
        cout << 'H' << endl;
    }else{
        cout << 'D' << endl;
    }
    
}

Measured memory_bytes: 256
// ---------- begin ModInt ----------
const MOD: u32 = 1_000_000_007;

#[derive(Clone, Copy)]
struct ModInt(u32);

impl std::ops::Add for ModInt {
    type Output = ModInt;
    fn add(self, rhs: ModInt) -> Self::Output {
        let mut d = self.0 + rhs.0;
        if d >= MOD {
            d -= MOD;
        }
        ModInt(d)
    }
}

impl std::ops::AddAssign for ModInt {
    fn add_assign(&mut self, rhs: ModInt) {
        *self = *self + rhs;
    }
}

impl std::ops::Sub for ModInt {
    type Output = ModInt;
    fn sub(self, rhs: ModInt) -> Self::Output {
        let mut d = self.0 + MOD - rhs.0;
        if d >= MOD {
            d -= MOD;
        }
        ModInt(d)
    }
}

impl std::ops::SubAssign for ModInt {
    fn sub_assign(&mut self, rhs: ModInt) {
        *self = *self - rhs;
    }
}

impl std::ops::Mul for ModInt {
    type Output = ModInt;
    fn mul(self, rhs: ModInt) -> Self::Output {
        ModInt((self.0 as u64 * rhs.0 as u64 % MOD as u64) as u32)
    }
}

impl std::ops::MulAssign for ModInt {
    fn mul_assign(&mut self, rhs: ModInt) {
        *self = *self * rhs;
    }
}

impl std::ops::Neg for ModInt {
    type Output = ModInt;
    fn neg(self) -> Self::Output {
        ModInt(if self.0 == 0 {0} else {MOD - self.0})
    }
}

impl std::fmt::Display for ModInt {
    fn fmt<'a>(&self, f: &mut std::fmt::Formatter<'a>) -> std::fmt::Result {
        write!(f, "{}", self.0)
    }
}

#[allow(dead_code)]
impl ModInt {
    pub fn new(n: u32) -> ModInt {
        ModInt(n % MOD)
    }
    pub fn zero() -> ModInt {
        ModInt(0)
    }
    pub fn one() -> ModInt {
        ModInt(1)
    }
    pub fn pow(self, mut n: u32) -> ModInt {
        let mut t = ModInt::one();
        let mut s = self;
        while n > 0 {
            if n & 1 == 1 {
                t *= s;
            }
            s *= s;
            n >>= 1;
        }
        t
    }
    pub fn inv(self) -> ModInt {
        self.pow(MOD - 2)
    }
}
// ---------- end ModInt ----------

use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let k: usize = it.next().unwrap().parse().unwrap();
    if k > 1 + n.next_power_of_two().trailing_zeros() as usize {
        println!("0");
        return;
    }
    let mut dp = vec![ModInt::one(); n + 1];
    dp[0] = ModInt::zero();
    for _ in 1..k {
        for i in 1..(n + 1) {
            let mut local = ModInt::zero();
            let mut j = 2 * i;
            while j <= n {
                local += dp[j];
                j += i;
            }
            dp[i] = local;
        }
    }
    let ans = dp.into_iter().fold(ModInt::zero(), |s, a| s + a);
    println!("{}", ans);
}

fn main() {
    run();
}



Measured memory_bytes: 5028
// ABC167 - B
function main(input) {
  var inputs = input.split('\n');
  var line1 = inputs[0].split(' ');
  var n = parseInt(line1[0], 10);
  var m = parseInt(line1[1], 10);
  var x = parseInt(line1[2], 10);

  var c = [];
  var a = [];
  for (var i = 0; i < n; i++) {
    var lineN = inputs[i + 1].split(' ');
    c.push(parseInt(lineN[0], 10));
    a[i] = [];
    for (var j = 1; j < m + 1; j++) {
      a[i].push(parseInt(lineN[j], 10));
    }
  }

  var iniAs = [];
  for (var i = 0; i < m; i++) {
    iniAs.push(0);
  }

  var maxCost = c.reduce((a, b) => a + b) + 1;
  var minCost = maxCost * 1;

  var bits = bitComb(n);
  bits.forEach((bit) => {
    var tempCost = 0;
    var tempAs = iniAs.concat();
    bit.forEach((bitItem) => {
      tempCost += c[bitItem];
      tempAs = sumItems(tempAs.concat(), a[bitItem]);
    });
    if (tempAs.every((foo) => foo >= x)) minCost = Math.min(minCost, tempCost);
  });

  console.log(minCost != maxCost ? minCost : -1);
}

function bitComb(n) {
  var ret = [];
  for (let bit = 0; bit < (1 << n); bit++) {
    let row = [];
    for (let i = 0; i < n; i++) {
      if (bit & (1 << i)) {
        row.push(i);
      }
    }
    ret.push(row);
  }
  return ret;
}

function sumItems(arr1, arr2) {
  var ret = [];
  for (var i = 0; i < arr1.length; i++) {
    ret.push(arr1[i] + arr2[i]);
  }
  return ret;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 36712
#pragma GCC optimize("O3")
//#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#define re return
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define fi first
#define se second
#define ss second.second
#define sf second.first
#define ff first.first
#define fs first.second
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define PI 3.14159265358979323846
#define E 2.71828182845904523536
#define er erase
#define in insert
#define fo(i,n) for((i)=0;(i)<(n);(i)++)
#define ro(i,n) for((i)=n-1;(i)>=0;(i)--)
#define fr(i,j,n) for((i)=(j);(i)<(n);(i)++)
#define rf(i,j,n) for((i)=((n)-1);(i)>=(j);(i)--)
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
    const int N=(int)1e5+100;
    const int M=(int)2e6+100;
    const int inf=(int)1e9+100;
#define filename ""

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //freopen(filename".in","r",stdin);
    //freopen(filename".out","w",stdout);
    //freopen("ans.txt","w",stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    srand(time(0));
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n,k,s,i;
    cin>>n>>k>>s;
    fo(i,n)
    {
        if (k)
        {
            cout<<s<<' ';
            k--;
        }
        else
        {
            if (s==(int)1e9)
            {
                cout<<s-1<<' ';
            }
            else
            {
                cout<<s+1<<' ';
            }
        }
    }
}


Measured memory_bytes: 1280
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

struct Node {
  Node() {}
  string city;
  int score;
  int idx;
  bool operator <(const Node& rhs) const {
    if (city != rhs.city) return city < rhs.city;
    return score > rhs.score;
  }
};

int main() {
  int n;
  cin >> n;
  vector<Node> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i].city >> a[i].score;
    a[i].idx = i + 1;
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n; ++i) {
    cout << a[i].idx << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

int main(){
  int N;
  scanf("%d", &N);
  //std::vector<std::string > vec(N);
  std::map<std::string, int > mp;
  std::string S;
  for (int i=0; i<N; i++){
    std::cin >> S;
    mp[S]++;
  }
  std::vector<int > count(5, 0);
  // 0:M, 1:A, 2:R, 3:C, 4:H
  char moji[5] = {'M', 'A', 'R', 'C', 'H'};
  for (auto &entry : mp){
    //printf("%c\n", entry.first[0]);
    for (int j=0; j<5; j++){
      if (entry.first[0]==moji[j]){
        count[j] += entry.second;
      }
    }
  }
  /*for (int i=0; i<5; i++){
    printf("count[%d]=%d\n",i,count[i]);
    }*/

  long long ans = 0;
  for (int i=0; i<5; i++){
    for (int j=i+1; j<5; j++){
      for (int k=j+1; k<5; k++){
        ans += (long long)count[i]*count[j]*count[k];
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}


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

int main(){
	int a, b, c, d, e;
	std::cin >> a >> b >> c >> d >> e;
	int pasta = std::min(a, std::min(b, c));
	int juice = std::min(d, e);
	std::cout << pasta + juice - 50 << std::endl;
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define isLeap(x) ((x % 400 == 0) || (x % 100 ? x % 4 == 0 : false))
#define FAST ios_base::sync_with_stdio(0), cin.tie(0)
#define LCM(a, b) (a / __gcd(a, b)) * b;
#define PI acos(-1.0)
#define inf 0x3f3f3f3f
#define fr(m,n,c) for(int i = m; i < n; i+=c)
const int N = 1e5+3;
int ara[N+2];
pair<int, int> pp[N];
vector<int> vv[4*N];
set<int> st;
map<ll, ll> mp;
int ara1[N + 3], ara2[N + 3], ara3[N + 3];
int dp[N+3][3];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> ara1[i] >> ara2[i] >> ara3[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			if (i == 0) {
				if (j == 0) dp[i][j] = ara1[i];
				else if (j == 1) dp[i][j] = ara2[i];
				else dp[i][j] = ara3[i];
			}
			else {
				for (int k = 0; k < 3; k++) {
					if (j == k) continue;
					else if (j == 0) dp[i][j] = max(dp[i][j], dp[i - 1][k] + ara1[i]);
					else if (j == 1) dp[i][j] = max(dp[i][j], dp[i - 1][k] + ara2[i]);
					else dp[i][j] = max(dp[i][j], dp[i - 1][k] + ara3[i]);
				}
			}
		}
	}
	int maxi = 0;
	for (int i = 0; i < 3; i++) {
		maxi = max(dp[n - 1][i], maxi);
	}
	cout << maxi << "\n";
}

Measured memory_bytes: 15296
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());
    int v[] = new int[n];
    double g[] = new double[n];
    double s = 0.0;
    double ans = 0.0;
    
    for(int i=0; i<n; i++) {
      v[i] = Integer.parseInt(sc.next());
    }
    
    Arrays.sort(v);
    
    g[0] = 0.0 + (double) v[0];
    for(int i=0; i<n-1; i++){
      g[i+1] = (g[i] + v[i+1]) * 0.50;
    }
    
    
    System.out.println(g[n-1]);
    
  }
}


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

int main()
{
    long double r;
    cin>>r;
    long double pi = 3.141592653589793238;
    cout<<setprecision(6)<<((long double)(((long double)2.000000000)*pi*r))<<endl;
    return 0;
}

Measured memory_bytes: 3784
def main():
    N = int(input())
    dic = {}
    for i in range(10**5+10):
        dic[i]=0
    
    s=0
    l = [int(x) for x in input().split()]
    for a in l:
        dic[a]+=1
        s+=a
    ans=[]
    Q = int(input())
    for i in range(Q):
        b,c = map(int,input().split())
        b_num = dic[b]
        dic[b]=0
        dic[c]+=b_num
        s = s + (c-b)*b_num
        ans.append(s)
    for i in ans:
        print(i)
    
main()

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

using namespace std;

using int64 = long long;
const int INF = 1 << 30;

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

  int64 latte = 0, malta = 0;
  deque< int > choose(N);
  for(int i = 0; i < N; i++) {
    if(i & 1) malta += max(0LL, A[i]);
    else latte += max(0LL, A[i]);
  }

  if(latte == 0 && malta == 0) {
    latte = -INF, malta = -INF;
    for(int i = 0; i < N; i++) {
      if(i & 1) malta = max(malta, A[i]);
      else latte = max(latte, A[i]);
    }
    if(latte < malta) {
      cout << malta << endl;
      for(int i = 1; i < N; i += 2) {
        if(malta == A[i]) {
          choose[i] = true;
          break;
        }
      }
    } else {
      cout << latte << endl;
      for(int i = 0; i < N; i += 2) {
        if(latte == A[i]) {
          choose[i] = true;
          break;
        }
      }
    }
  } else if(latte < malta) {
    cout << malta << endl;
    for(int i = 1; i < N; i += 2) {
      if(A[i] > 0) choose[i] = true;
    }
  } else {
    cout << latte << endl;
    for(int i = 0; i < N; i += 2) {
      if(A[i] > 0) choose[i] = true;
    }
  }

  vector< int > operation;
  bool update = true;
  while(update) {
    update = false;
    for(int i = 2; i < choose.size(); i++) {
      if(!choose[i - 2] && !choose[i - 1] && !choose[i]) {
        operation.push_back(i);
        choose.erase(choose.begin() + i - 2);
        choose.erase(choose.begin() + i - 2);
        update = true;
        break;
      }
    }
  }

  while(choose.size() > 1) {
    if(!choose.front()) {
      operation.push_back(1);
      choose.pop_front();
    } else if(!choose.back()) {
      operation.push_back(choose.size());
      choose.pop_back();
    } else {
      operation.push_back(2);
      choose.pop_front();
      choose.pop_front();
    }
  }
  cout << operation.size() << endl;
  for(auto &s : operation) cout << s << endl;
}


Measured memory_bytes: 256
def weight
  master = Array.new(10) { |i| 2**i }
  while gets
    wei = $_.to_i
    spindles = master.select { |i| i <= wei }
    result = []
    while true
      break if wei <= 0
      minus = spindles.max
      if minus > wei
				spindles.delete(minus)
        next
      end
      wei = wei - minus
      result << spindles.delete(minus)
    end
    puts result.sort.join(' ')
  end
end

weight

Measured memory_bytes: 8656
import java.util.*;

/**
 * A
 */
public class Main {

    Node root;

    public void run() {

        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        
        for(int i=0; i<m; i++) {
            String str = sc.next();
            if(str.startsWith("i")) {
                insert(sc.nextInt());
            } else {
                inorder(root);
                System.out.println();
                preorder(root);
                System.out.println();
            }
        }

        sc.close();

    }

    public void insert(int v) {

        Node x = root; // root
        Node y = null; // parent of x
        Node z = new Node(v); // it will be inserted

        while(x != null) {
            y = x;
            if(z.id < x.id) {
                x = x.left;
            } else {
                x = x.right;
            }
        }
        if(y == null) {
            root = z;
        } else if(z.id < y.id) {
            y.left = z;
        } else {
            y.right = z;
        }

    }

    public void inorder(Node tree) {
        
        if(tree == null) {
            return;
        }

        inorder(tree.left);
        System.out.print(" "+tree.id);
        inorder(tree.right);

    }

    public void preorder(Node tree) {

        if(tree == null) {
            return;
        }

        System.out.print(" "+tree.id);
        preorder(tree.left);
        preorder(tree.right);

    }

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

}

class Node {

    int id;
    Node left;
    Node right;

    Node(int id) {
        this.id = id;
    }

}


Measured memory_bytes: 214044
from itertools import combinations_with_replacement
from functools import lru_cache
import math


@lru_cache(maxsize=None)
def _gcd(a, b):
    return math.gcd(a, b)


k = int(input())
C = combinations_with_replacement(range(1, k + 1), 3)

r = 0
for a, b, c in C:
    l = len({a, b, c})
    t = 1
    if l is 3:
        t = 6
    if l is 2:
        t = 3
    r += _gcd(_gcd(a, b), c) * t

print(r)


Measured memory_bytes: 11484
#include<bits/stdc++.h>
using namespace std;
const int MAX = 1e5+50;
int Next[MAX],num[MAX]={0};
int main(){
	string s;
	cin>>s;
	int n = s.length();
	int leftR=0;
	for(int i=0;i<n;i++){
		if(s[i]=='R'&&i+1<n&&s[i+1]=='R'){
			leftR++;
		}
		else if(s[i]=='L'){
			Next[i]=leftR;
			if(s[i-1]=='R'){
				for(int j=i-1;s[j]!='L'&&j>=0;j--){
					Next[j]=i;
				}
			}
			if(s[i+1]=='R'){
				leftR=i+1;
			}
		}
	}
//	for(int i=0;i<n;i++){
//		cout<<Next[i]<<" ";
//	}
//	cout<<endl;
	for(int i=0;i<n;i++){
		if(abs(i-Next[i])&1){
			if(s[Next[i]]=='R'){
				num[Next[i]+1]++;
			}
			else{
				num[Next[i]-1]++;
			}
		}
		else{
			num[Next[i]]++;
		}
	}
	for(int i=0;i<n;i++){
		cout<<num[i];
		if(i<n-1){
			printf(" ");
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1408
n = int(input())
a = list(map(int,input().split()))

ass = 0
k = a[0]
w = 0 #zouka gennshou
for i in range(n):
    if w == -1:
        if a[i] > a[i-1]:
            ass += 1
            w = 0
        
    elif w == 1:
        if a[i] < a[i-1]:
            ass += 1
            w = 0
    if w == 0:
        if i != n-1:
            if a[i] > a[i+1]:
                w = -1
            elif a[i] < a[i+1]:
                w = 1
print(ass+1)

Measured memory_bytes: 14224
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1.01e9;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

const int mod = (int) 1e9 + 7;

void add(int & x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int sum(int x, int y) {
  add(x, y);
  return x;
}

int mult(int x, int y) {
  return (ll) x * y % mod;
}

int power(int x, ll p) {
  int res = 1;
  while (p) {
    if (p & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
    p >>= 1;
  }
  return res;
}

int inv(int x) {
  return power(x, mod - 2);
}

void precalc() {
}

int n, m;

bool read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return false;
  }
  return true;
}

void solve() {
  int res = 0;
  vector<int> c(2 * m + 1);
  c[0] = 1;
  for (int i = 1; i <= 2 * m; i++) {
    c[i] = mult(c[i - 1], 2 * m - i + 1);
    c[i] = mult(c[i], inv(i));
  }
  for (int diff = n - 1; diff <= n; diff++) {
    int cur = 0;
    int step = 2 * (diff + 1);
    vector<int> v(step);
    for (int i = 0; i <= 2 * m; i++) {
      add(v[i % step], c[i]);
    }
    int val = 0;
    for (int i = m; i <= m + diff; i++) {
      add(val, v[i % step]);
    }
    for (int i = m + step / 2; i <= m + step / 2 + diff; i++) {
      add(val, mod - v[i % step]);
    }
    for (int it = 0; it <= diff; it++) {
      add(cur, val);
      add(val, v[((m - it - 1) % step + step) % step]);
      add(val, mod - v[(m + diff - it) % step]);
      add(val, mod - v[((m - it - 1 + step / 2) % step + step) % step]);
      add(val, v[(m + diff - it + step / 2) % step]);
    }
    if ((diff - n) & 1) {
      add(res, mod - cur);
    } else {
      add(res, cur);
    }
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time: %.3f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define nl "\n"
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;
#define mt make_tuple
#define vec vector

#define int long long

const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;

typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}


void solve() {

	string s; cin >> s;
	if(s.back()=='s') s += "es"; 
	else s += 's' ;

	cout << s ;

}

int32_t main() {

#ifdef LOCAL
    freopen("error.txt", "w", stderr);
#endif

    fast;

	// int t; cin >> t; while(t--)
		solve() ;

	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}


Measured memory_bytes: 3660
def calc(day, i, m, d, S, c):
    m += S[day][i]
    d[i] = day
    for i in range(26):
        m -= c[i] * (day - d[i])
    return m, d
def main():
    D = int(input())
    c = list(map(int, input().split()))
    S = []
    d = {i:-1 for i in range(26)}
    for _ in range(D):
        s = list(map(int, input().split()))
        S.append(s)
    m = 0
    for i in range(D):
        t = int(input())
        t -= 1
        m, d = calc(i, t, m, d, S, c)
        print(m)
main()


Measured memory_bytes: 9312
n,x,y=map(int,input().split())
k=[0]*(n-1)
for i in range(n): 
    for j in range(i+1,n):
        l=min(abs(j-i),abs(j-y+1)+abs(x-i-1)+1)
        k[l-1]+=1
for i in k:
    print(i)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
#define inf (1e9 + 7)
#define eps 0.000001
#define pi acos(-1)
typedef long long LL;
using namespace std;
const LL mod = (1e9 + 7);

LL n, stx, sty, edx, edy, nn = 0, mix, mxx, miy, mxy, tx, ty, num[200005];
double ans;

struct node
{
    LL x, y;
}nd[200005];

bool cmp(const node & a, const node & b)
{
    return a.x < b.x;
}

bool cmp2(const node & a, const node & b)
{
    return a.y < b.y;
}

void solve(int a)
{
    num[0] = 0;
    if(a == 1)
    {
        for(LL i = 1;i <= nn;i++)
        {
            if(!num[0]||num[num[0]] < nd[i].y)
                num[++num[0]] = nd[i].y;
            else
            {
                LL l = 1, r = num[0], res = -1;
                while(l <= r)
                {
                    LL mid = (l + r) / 2;
                    if(num[mid] >= nd[i].y)
                        r = mid - 1, res = mid;
                    else
                        l = mid + 1;
                }
                if(res == -1)
                    continue;
                num[res] = nd[i].y;
            }
        }
    }
    else
    {
        for(LL i = 1;i <= nn;i++)
        {
            if(!num[0]||num[num[0]] > nd[i].y)
                num[++num[0]] = nd[i].y;
            else
            {
                LL l = 1, r = num[0], res = -1;
                while(l <= r)
                {
                    LL mid = (l + r) / 2;
                    if(num[mid] <= nd[i].y)
                        r = mid - 1, res = mid;
                    else
                        l = mid + 1;
                }
                if(res == -1)
                    continue;
                num[res] = nd[i].y;
            }
        }
    }
    ans = ((double)(mxx - mix) + (double)(mxy - miy)) * 100.0;
    if(stx != edx&&sty != edy)
    {
        if(num[0] == mxx - mix + 1||num[0] == mxy - miy + 1)
            num[0]--, ans += (10.0 * pi - 20.0);
        double res = (20.0 - 5.0 * pi) * (double)num[0];
        ans = ans - res;
    }
    else
    {
        double res = (10.0 * pi - 20.0) * (double)num[0];
        ans = ans + res;
    }
}

int main()
{
    cin>>stx>>sty>>edx>>edy;
    cin>>n;
    mix = min(stx, edx);
    mxx = max(stx, edx);
    miy = min(sty, edy);
    mxy = max(sty, edy);
    for(LL i = 1;i <= n;i++)
    {
        cin>>tx>>ty;
        if(tx >= mix&&tx <= mxx&&ty >= miy&&ty <= mxy)
            nd[++nn].x = tx, nd[nn].y = ty;
    }
    sort(nd + 1, nd + 1 + nn, cmp);
    if(stx <= edx)
    {
        if(sty <= edy)
            solve(1);
        else
            solve(2);
    }
    else
    {
        if(sty >= edy)
            solve(1);
        else
            solve(2);
    }
    printf("%.12f\n", ans);
    return 0;
}

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

int main(void) {

	string s;
	cin >> s;

	vector <long long> v(26, 0);

	for (int i=0; i<s.size(); i++) {
		long long loc = s.at(i) - 'a';
		v.at(loc)++;
	}

	for (int i=0; i<26; i++) {
		if (!v.at(i)) {
			char c = 'a' + i;
			cout << c << endl;
			break;
		}
		if (i==25) cout << "None" << endl;
	}

}


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

int main() {
	int sum = 0;
	size_t N;
	cin >> N;
	vector<int> A(N + 2);
	for (size_t i = 1; i <= N; ++i) cin >> A[i];
	for (size_t i = 0; i <= N; ++i) sum += abs(A[i] - A[i + 1]);
	for (size_t i = 1; i <= N; ++i) {
		if (A[i - 1] > A[i] && A[i] < A[i + 1] || A[i - 1] < A[i] && A[i] > A[i + 1]) cout << sum - 2 * min(abs(A[i - 1] - A[i]), abs(A[i] - A[i + 1]));
		else cout << sum;
		cout << endl;
	}
}

Measured memory_bytes: 1664
#include <iostream>

int main()
{
    int N;
    std::cin >> N;

    auto cycles = N / 15;
    auto rest_begin = N - N % 15;

    constexpr long first_cycle = 1 + 2 + 4 + 7 + 8 + 11 + 13 + 14;
    constexpr long step = 15 * 8;

    auto result = (step * (cycles - 1) / 2 + first_cycle) * cycles;

    for (auto k = rest_begin; k <= N; k++) {
        if (k % 3 != 0 && k % 5 != 0) {
            result += k;
        }
    }

    std::cout << result << std::endl;

    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000,mod=1000000007;
ll power(ll a,ll b){
    ll res=1;
    a%=mod;
    while(b){
        if(b&1)
        res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
int main(){
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
     
        ll n,k;cin>>n>>k;
        ll sum;
        sum=power(k,n);
        ll ans[k+1];ans[1]=sum;
        for(ll i=2;i<=k;i++){
            ans[i]=power(k/i,n);
        }sum=0;
        for(ll i=k;i>0;i--){
            for(ll j=i*2;j<k+1;j+=i){
                ans[i]=(ans[i]-ans[j]+mod)%mod;
            }
            sum=(sum+(ans[i]*i)%mod)%mod;
        }
        cout<<sum;

}


Measured memory_bytes: 4436
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
int main()
{
	int n;
	cin>>n;
	for(int i=n;i>=1;i--){
		if(floor(sqrt(i))==sqrt(i)){
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

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

using namespace std;

const int dx1[]={1,0,1,2,1};
const int dy1[]={0,1,1,1,2};
const int dx2[]={0,1,2,0,1,2,0,1,2};
const int dy2[]={0,0,0,1,1,1,2,2,2};
const int dx3[]={2,1,2,3,0,1,2,3,4,1,2,3,2};
const int dy3[]={0,1,1,1,2,2,2,2,2,3,3,3,4};

int n1,n2,n3;
int cloth[10][10];

bool dfs1(int i,int j){
	if(n1==0) return true;

	if(i+2>=10) return false;
	if(j+2>=10) return dfs1(i+1,0);

	bool ok=true;
	rep(k,5) if(cloth[i+dy1[k]][j+dx1[k]]==0) ok=false;
	if(ok){
		rep(k,5) cloth[i+dy1[k]][j+dx1[k]]--;
		n1--;
		if(dfs1(i,j)){
			printf("%d %d 1\n",j+1,i+1);
			return true;
		}
		n1++;
		rep(k,5) cloth[i+dy1[k]][j+dx1[k]]++;
	}

	return dfs1(i,j+1);
}

bool dfs2(int i,int j){
	if(n2==0) return dfs1(0,0);

	if(i+2>=10) return false;
	if(j+2>=10) return dfs2(i+1,0);

	bool ok=true;
	rep(k,9) if(cloth[i+dy2[k]][j+dx2[k]]==0) ok=false;
	if(ok){
		rep(k,9) cloth[i+dy2[k]][j+dx2[k]]--;
		n2--;
		if(dfs2(i,j)){
			printf("%d %d 2\n",j+1,i+1);
			return true;
		}
		n2++;
		rep(k,9) cloth[i+dy2[k]][j+dx2[k]]++;
	}

	return dfs2(i,j+1);
}

bool dfs3(int i,int j){
	if(n3==0) return dfs2(0,0);

	if(i+4>=10) return false;
	if(j+4>=10) return dfs3(i+1,0);

	bool ok=true;
	rep(k,13) if(cloth[i+dy3[k]][j+dx3[k]]==0) ok=false;
	if(ok){
		rep(k,13) cloth[i+dy3[k]][j+dx3[k]]--;
		n3--;
		if(dfs3(i,j)){
			printf("%d %d 3\n",j+2,i+2);
			return true;
		}
		n3++;
		rep(k,13) cloth[i+dy3[k]][j+dx3[k]]++;
	}

	return dfs3(i,j+1);
}

int main(){
	int n; scanf("%d",&n);
	int sum=0;
	rep(i,10) rep(j,10) {
		scanf("%d",cloth[i]+j);
		sum+=cloth[i][j];
	}

	for(n1=0;n1<=n;n1++) for(n2=0;n1+n2<=n;n2++) {
		n3=n-n1-n2;
		if(5*n1+9*n2+13*n3==sum && dfs3(0,0)) return 0;
	}

	return 0;
}

Measured memory_bytes: 1028
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

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

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}"<<endl;
  return o;
}



int main() {
  string s,t;
  cin >> s >> t;
  int cnt=0,n=s.size();
  rep(i,n) if (s[i]!=t[i]) cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 3848
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;
int n;


int main()
{
    cin>>n;
    cout<<n*n*n<<endl;
    return 0;
}



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

int main()
{
    int w,h,x,y;
    cin >> w >> h >>x>>y;
    ll t = ll(w) * h;
    cout<<t/2;
    if(t%2!=0)
        cout<<".5";
    else
        cout<<".0";

    cout<<"00000"<<" ";

    if(2*x==w&&2*y==h)
        cout<<"1";
    else
        cout<<"0";
    return 0;
}


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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
   int x,y; cin >> x >> y;
   long long w = 1, h = 1;
   long long d[4] = {};
   int i = 0;
   while(1){
      if(-1*d[2] <= x && d[0] >= x && -1*d[3] <= y && d[1] >= y){
         
         cout << i%3 + 1 << "\n";
         break;
      }

      if(i%2 == 0){
         w += h;
         d[i%4] += h;
      }else{
         h += w;
         d[i%4] += w;
      }

      
      i++;
      // << w << " " << h << " " << d[0] << " " << d[1] << "\n";
   }
}


Measured memory_bytes: 3132