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

#define debug(...)   printf( __VA_ARGS__ )
//#define debug(...)   /****nothing****/

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mem(arr,val)    memset(arr,val,sizeof(arr))
#define mp make_pair
#define pii pair<int,int>
#define F first
#define S second
#define sz(x) (int)(x).size()
#define nopos string::npos
#define fr(i,a,b) for(i=a;i<=b;i++)
#define frn(i,a,b) for(i=a;i>=b;i--)

int w,a,b;
int main()
{
    //freopen("d://i.txt","r",stdin);
    //freopen("d://o.txt","w",stdout);
    cin>>w>>a>>b;
    if( (b>=a&&b<=(a+w)) || (b+w>=a&&b+w<=a+w) )
        cout<<0<<'\n';
    else if(b>(a+w))
    cout<<b-a-w<<'\n';
    else
        cout<<a-b-w<<'\n';




    return 0;
}





Measured memory_bytes: 256
import java.util.InputMismatchException;
import java.util.Scanner;

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

                try
                    {
                        int inputA = scanner.nextInt();
                        int inputB = scanner.nextInt();
                        int inputC = scanner.nextInt();

                        if (inputA < inputB && inputB < inputC)
                            {
                                System.out.println("Yes");
                            }
                        else
                            {
                                System.out.println("No");
                            }
                    }
                catch (InputMismatchException e)
                    {
                        System.out.println("整数を入力してください");
                        e.printStackTrace();
                    }
            }
    }

Measured memory_bytes: 17160
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define ms(a,v) memset(a,v,sizeof a)
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor
 *
 * */

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    bitset<100010> bs; bs.set();
    bs[0] = bs[1] = 0;
    for (ll i=2; i<=100000; ++i) if (bs[i]){
		for (ll j = i*i; j<=100000; j+=i) bs[j]=0;
	}
	int ans[100001]; 
	ans[1] = 0; ans[0]=0;
	for (int i=2; i<=100000; ++i) 
		ans[i] = (bs[i] && bs[(i+1)/2]) ? ans[i-1] + 1: ans[i-1];	
	int q, l, r; cin>>q;
	while(q--){
		cin>>l>>r;
		cout<<ans[r] - ans[l-1]<<endl;
	}
    return 0;
}


Measured memory_bytes: 1024
input_S = input()

S = list(input_S)
N = len(S)
ans = 0

for num in range(N):
    if S[num] != S[N - num - 1]:
        ans = 1

for num in range(int((N - 1) / 2)):
    if S[num] != S[int((N - 1) / 2 - num - 1)]:
        ans = 1

if ans == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#define N 2000000
int n;
void heapIncreaseKey(int [],int,int);
int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}

void maxHeapify(int A[], int i){
  int lar;
  int le,ri;
  int tmp;
  le = left(i);
  ri = right(i);
  
  if(n>=le && A[le]>A[i])lar=le;
  else lar=i;
  
  if(n>=ri && A[ri]>A[lar]) lar=ri;
    
    if(lar != i){
      tmp=A[i];
      A[i]=A[lar];
      A[lar]=tmp;
      maxHeapify(A,lar);
    }
    
}

void buildMaxHeap(int A[]){
  int i;
  for(i=n/2;i>=1;i--){
    maxHeapify(A, i);
  }
}

void maxHeapInsert(int A[],int key){
  n=n+1;
  A[n]=-2147483647;
  heapIncreaseKey(A,n,key);
  
}

void heapIncreaseKey(int A[],int i,int key){
  int tmp;
  if(key < A[i])exit(1);
  A[i]=key;
  while(i>1 && A[parent(i)]<A[i]){
    tmp=A[i];
    A[i]=A[parent(i)];
    A[parent(i)]=tmp;
    i=parent(i);
  }
}

int heapExtractMax(int A[]){
  int max;
  if(n<1)exit(5);
  max=A[1];
  A[1]=A[n];
  n=n-1;
  maxHeapify(A,1);
  return max;
}

int main(void){
  int heap[N];
  int k;
  char c[20];
  while(1){
    scanf("%s",c);
    if( c[0] == 'i'){
      scanf("%d",&k);
      maxHeapInsert(heap, k);
    }else if( c[0] == 'e' && c[1] == 'x'){
      printf("%d\n",heapExtractMax(heap));
    }else break;       
  }
  return 0;
}

Measured memory_bytes: 6496
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto o = sread();
    auto e = sread();
    auto s = (o.length) + (e.length);
    foreach (i; 0 .. s)
    {
        if (i % 2 == 0)
        {
            write(o[i / 2]);
        }
        else
        {
            write(e[i / 2]);
        }
    }
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-9;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int x;
  cin>>x;
  int l=lcm(360, x);
  cout<<l/x<<'\n';
  return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

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

		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if(B % A == 0){
			System.out.println(A + B);
		}else{
			System.out.println(B - A);
		}
    }
}


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

int main(){
	int a,b,c;
	int ans_a=-1;
	int ans_b=-1;
	int ans_c=-1;
	int n,y;
	cin >> n >> y;
	for(a=0;a<=n;a++){
		for(b=0;a+b<=n;b++){
			c=n-a-b;
			if(a+b+c==n && a*10000+b*5000+c*1000==y){
				ans_a=a;
				ans_b=b;
				ans_c=c;
			}
		}
	}
	cout << ans_a << " " << ans_b << " " << ans_c << endl;
	return 0;
}


Measured memory_bytes: 256
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
    #include <bits/stdc++.h>
    using namespace std;
    #define endl '\n'
    #define MOD 1000000007
    #define ll long long
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define INF 1e18
    #define N 100100
    #define PI 3.141592653589793238
    typedef pair<ll,ll> pll;
    ll power(ll a,ll b)
    {
        if(b==1)return a;
        if(b==0)return 1;
        ll temp=power(a,b/2);
        ll ans=temp*temp;
        if(b&1)
            ans*=a;
        return ans;
    }
    ll power(ll a,ll b,ll p)
    {
        a=a%p;
        if(b==1)return a;
        if(b==0)return 1;

        ll temp=power(a,b/2,p);
        ll ans=(temp*temp)%p;
        if(b&1)
            ans=(a*ans)%p;
        return ans%p;
    }
    ll inv(ll a,ll m)
    {
        return power(a,m-2,m);
    }
    //code begins
    void solve(){
        ll k;cin>>k;
        ll sum=0;
        for(ll i=1;i<=k;i++){
            sum=(sum*10+7)%k;
            if(sum==0)
            {
                cout<<i<<endl;
                return;
            }
        }
        cout<<-1<<endl;
    }
    signed main()
    {
    //    freopen("input.txt","r",stdin);
    //    freopen("output.txt","w",stdout);

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

    //    ll t;cin>>t;while(t--)
        solve();
        return 0;
    }


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
int x, y;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> x >> y;
	if (y%2 != 0){
		cout << "No" << endl;
		return 0;
	}
	if (y < 2*x){
		cout << "No" << endl;
		return 0;
	}
	if ((y - 2*x)/2 > x){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 3636
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var a, b string
	fmt.Scan(&a, &b)

	num, _ := strconv.Atoi(a + b)
	if isSquare(num) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func isSquare(num int) bool {
	for i := 1; i*i <= num; i++ {
		if i*i == num {
			return true
		}
	}
	return false
}


Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
int p[110];
int c[110];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d%d",p+i,c+i);
	}
	int ret=mod;
	for(int i=0;i<(1<<a);i++){
		int tmp=0;
		int cur=0;
		for(int j=0;j<a;j++){
			if(i&(1<<j)){
				tmp+=p[j];
				cur+=100*(j+1)*p[j]+c[j];
			}
		}
		for(int j=a-1;j>=0;j--){
			if(!(i&(1<<j))){
				for(int k=0;k<p[j]&&cur<b;k++){
					tmp++;
					cur+=100*(j+1);
				}
			}
		}
		if(cur>=b){
			ret=min(ret,tmp);
		}
	}
	printf("%d\n",ret);
}


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

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

    set<int> a;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        a.insert(tmp);
    }
    if (a.size() == N) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 9600
import math
a , b ,C = map(int,input().split())
S = 0.5 *  a * b * math.sin(math.radians( C )) # 面積
L = a + b + math.sqrt(  a**2 + b**2 - 2 * a * b * math.cos ( math.radians ( C ) ) )
h = b * math.sin(math.radians( C ) )
print("{0:.8f}".format( S ) )
print("{0:.8f}".format( L ) )
print("{0:.8f}".format( h ) )


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

int main() {
	int n;
	string s;
	cin >> n >> s;
	int m = 0, x = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'I')
			x++;
		else
			x--;
		m = max(m, x);
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
main()
{
	int n;
	cin>>n;
	int cou=0;
	int flag=0;
	while(n--){
		int a, b;
		cin>>a>>b;
		if(a==b)
		cou++;
		else
		cou=0;
		if(cou==3)
		flag=1;
	}
	if(flag==1)
	cout<<"Yes"<<endl;
	else 
	cout<<"No"<<endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
using namespace std;

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)

int n, a, b;
int ans = 0;

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

  FOR(i, 1, n+1) {
    int j = i;
    int sum = 0;
    while (j) {
      sum += j%10;
      j /= 10;
    }
    if (a <= sum && sum <= b) { ans += i; }
  }

  cout << ans << endl;
  return 0;
}


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

int main(){
  vector<vector<int>> A(3,vector<int>(3) );
  vector<vector<bool>> hole(3,vector<bool>(3) );  
  Rep(i,3){
    Rep(j,3){
      cin >> A.at(i).at(j);}
  }
  int N;
  cin>>N;
  vector<int> B(N);
  Rep(i,N){
    cin >> B.at(i);
  }
  Rep(i,3){
    Rep(j,3){
      Rep(k,N){
        if ( B.at(k) == A.at(i).at(j) ){
          hole.at(i).at(j) = true;
        }
      }
    }
  }
  
  Rep(i,3){
    if ( hole.at(i).at(0) && hole.at(i).at(1) && hole.at(i).at(2) ){
      cout << "Yes";
      return 0;
    }
  }
    
  Rep(j,3){
    if ( hole.at(0).at(j) && hole.at(1).at(j) && hole.at(2).at(j) ){
      cout << "Yes";
      return 0;
    }
  }
  
  
  if ( hole.at(0).at(0) && hole.at(2).at(2) && hole.at(1).at(1)){
      cout << "Yes";
      return 0;
    }
    
   if ( hole.at(0).at(2) && hole.at(1).at(1) && hole.at(2).at(0)){
      cout << "Yes";
      return 0;
    }
    
  
    
  cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
#define HONEST 1
#define UNKIND 0
#define UNDEF -999

typedef pair<int,int> P;

int N;
vector<int> A;
vector<vector<P>> syougen;

vector<int> copy_state(vector<int>& state) {
  vector<int> ret(N,UNDEF);
  rep(i,N) {
    ret.at(i) = state.at(i);
  }
  return ret;
}

int solve(vector<int>& state, int start) {
  int x, y;
  for(int i = start; i < N; i++) {
//    cout << "#" << (i+1) << endl;
    switch(state.at(i)) {
      case HONEST:
        rep(j,A.at(i)) {
          P pair = syougen.at(i).at(j);
          x = pair.first;
          y = pair.second;
//          cout << (i+1) << ":" << x << "->" << y << endl;
          switch(state.at(x-1)) {
            case HONEST:
              if ( y != HONEST ) {
                return -1;
              }
              break;
            case UNKIND:
              if ( y != UNKIND ) {
                return -1;
              }
              break;
            case UNDEF:
              state.at(x-1) = y;
//              cout << "#" << x << ":" << y << endl;
              break;
          }
        }
        break;
      case UNKIND:
        break;
      case UNDEF:
        vector<int> state1 = copy_state(state);
        state1.at(i) = HONEST;
        int cand1 = solve(state1, i);
        
        vector<int> state2 = copy_state(state);
        state2.at(i) = UNKIND;
        int cand2 = solve(state2, i);
        
        return max(cand1, cand2);
    }
  }
  int honest = 0;
  rep(i,N) {
    if ( state.at(i) == HONEST ) {
      honest++;
    }
  }
  return honest;
}

int main() {
  //input
  cin >> N;
  A.resize(N);
  syougen.resize(N, vector<P>(N));
  int x, y;
  rep(i,N) {
    cin >> A.at(i);
    rep(j,A.at(i)) {
      cin >> x >> y;
      syougen.at(i).at(j) = make_pair(x, y);
    }
  }
  //calc
  vector<int> state1(N, UNDEF);
  state1.at(0) = HONEST;
  int cand1 = solve(state1, 0);
  
  vector<int> state2(N, UNDEF);
  state2.at(0) = UNKIND;
  int cand2 = solve(state2, 0);
  
  int cand = max(cand1, cand2);
  int answer = cand > 0 ? cand : 0;
  //output
  cout << answer << endl;
}

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

int main()
{
  int n,ans,standard;
  cin>>n;
  ans=1;
  vector<int> h(n);
  for(int i=0;i<n;i++)
  {
    cin>>h.at(i);
  }
  standard=h.at(0);
  for(int i=1;i<n;i++)
  {
    if(standard<=h.at(i))
    {
      standard=h.at(i);
      ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
	long long int N, a[100];

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

	sort(a, a+N);

	long long int res = 1 << 21;
	for(int f = a[0]; f <= a[N-1]; f++){
		
		long long m = 0;
		for(int i = 0; i < N; i++){
			m += (a[i] - f) * (a[i] - f);
		}

		if(m < res) res = m;
	}

	

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
//Robs Code
#include<bits/stdc++.h>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define all(x) x.begin(),x.end()
#define ed cout<<"\n";
#define pb push_back
#define pii pair<ll,ll>
#define _1 first
#define _2 second
#define maxi 100000007
/**********************************************************/
using namespace std;
ll i,j,k,n,m,q,t,a,b,c,cnt,sum,tot;
ll part[100001],sz[100001],cur,connect;
void init(ll n){
    for(i=1;i<=n;i++){
        part[i]=i;
        sz[i]=1;
    }
    connect=n;
}
ll findParent(ll k)
{
		while(k!=part[k])
		{
			part[k]=part[part[k]];
			k=part[k];
		}
		 return k;
}
// ll findParent(ll k){
//     return part[k]==k?k:part[k]=findParent(k);
// }
void unite(ll x,ll y){
    x=findParent(x),y=findParent(y);
    if(x==y) return ;
    cur -= (sz[x]*sz[y]);
    sz[x]+=sz[y];
    sz[y]=0;
    part[y]=x;
}
int main() 
{
    speed;
    cin>>n>>m;
    init(n);
    vector<pii> v(m);
    fri(0,m-1) cin>>v[i]._1>>v[i]._2;
    vector<ll> ans;
    cur=n*(n-1)/2;
    for(i=m-1;i>=0;i--){
        ans.pb(cur);
         unite(v[i]._1,v[i]._2);
    }
    for(i=ans.size()-1;i>=0;i--)
        cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 5492
h,w = map(int,input().split())

a= []

for i in range(h):
    arrc = input()
    a.append(arrc)
ans = 0
for gg in range(1,h+1):
    for bb in range(1,w+1):
        if a[gg-1][bb-1] == ".":
            ys=gg
            xs=bb
            n=[(ys-1,xs-1)]
            route={n[0]:0}
            p=[[1,0],[0,1],[-1,0],[0,-1]]
            count=1
            while count != 401:
                n2=[]
                for i in n:
                    for j in p:
                       
                        np=(i[0]+j[0],i[1]+j[1])
                        if 0<=np[0]<=h-1 and 0<=np[1]<=w-1:
                            if a[np[0]][np[1]]=='.' and route.get(np,-1)==-1:
                                n2.append(np)
                                route[np]=count
                n=n2
                count+=1
            
            ll= max(list(route.values()))
            if ll > ans:
                ans = ll

print(ans)

Measured memory_bytes: 47084
#include<stdio.h>

int main(){
    int N;
    scanf("%d",&N);
    int c[10][10];
    for(int i=0;i<10;i++)
        for(int j=0;j<10;j++)
              c[i][j]=0;
    
    for(int i=1;i<=N;i++){
        int x=i;
        while(x>=10) x/=10;
        c[x][i%10]++;
    }

    int ans =0;
    for(int i=0;i<=9;i++)
        for(int j=0;j<=9;j++)
             ans+=c[i][j]*c[j][i];
    printf("%d\n",ans);

}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

int main() {
    int N;
    scanf("%d", &N);
    vector<int> V;
    for (int i = 0; i < N; i++) {
        int tmp;
        scanf("%d", &tmp);
        V.push_back(tmp);
    }
    sort(V.begin(), V.end());
    LL ans = V[N - 1];
    deque<int> cand;
    cand.push_back(V[N - 2]);
    int cnt = 2;
    for (int i = N - 3; i >= 0; i--) {
        ans += cand.front();
        cnt--;
        if (cnt == 0) {
            cand.pop_front();
            cnt = 2;
        }
        cand.push_back(V[i]);
    }
    printf("%lld\n", ans);
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
by Benq;
*/


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

using namespace std;

int main() {
  string s;
  cin >> s;
  if (s.at(0) == '7' || s.at(1) == '7' || s.at(2) == '7') cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3592
from bisect import bisect_right as br
n = int(input())
a = [int(input()) for _ in range(n)][::-1]
INF = float("INF")
lst = [INF]*n
ans = 0
for i in range(n):
    l = br(lst,a[i])
    lst[l] = a[i]
    ans = max(l+1,ans)
print(ans)

Measured memory_bytes: 7840
#!/usr/bin/env python3

def gcd(a, b): 
    dividend = max(a, b)
    divider = min(a, b)

    if divider == 0:
        return dividend
    while dividend % divider != 0:
        r = dividend % divider
        dividend = divider
        divider = r 

    return divider

k = int(input())
ans = 0 
for a in range(1,k+1):
    for b in range(1,k+1):
        tmp = gcd(a, b)
        for c in range(1,k+1):
            ans += gcd(tmp, c)
print(ans)


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

string S, T;

int main(void) {
  cin >> S >> T;
  int n = S.size();
  if (n + 1 == T.size() && S == T.substr(0,n)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3612
def mi(): return map(int,input().split())
def lmi(): return list(map(int,input().split()))
def ii(): return int(input())
def isp(): return input().split()
from collections import deque
n,m=mi()
adjacent_list=[[] for i in range(n+1)]
for i in range(m):
  a,b=mi()
  adjacent_list[a].append(b)
  adjacent_list[b].append(a)
#print(adjacent_list)

dp=[0]*(n+1)

que=deque()
que.append(1)
while que:
  p=que.popleft()
  for i in adjacent_list[p]:
    if dp[i]==0:
      dp[i]=p
      que.append(i)
      
print('Yes')
for i in range(2,n+1):
  print(dp[i])

Measured memory_bytes: 34080
# coding=utf-8

###
### for python program
###

import sys
import math

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

#abc list
#abc = [chr(ord('a') + i) for i in range(26)]

### output sample
# print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
# print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
# print(" {}".format(i), end="")

# def printA(A):
#     for i, n in enumerate(A):
#         print(n, end='')
#         if i != N-1:
#             print(' ', end='')
#     print()

# リスト内包表記 ifあり
# [x-k if x != 0 else x for x in C]

# ソート
# N = N.sort()

# 10000個の素数リスト
# P = mymath.pnum_eratosthenes(105000)

def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

def dist(A, B):
    d = 0
    for i in range(len(A)):
        d += (A[i]-B[i])**2            
    d = d**(1/2)
    return d

def get_input():
    N = []
    while True:
        try:
            #N.append(input())
            #N.append(int(input()))
            N.append(float(input()))
        except EOFError:
            break
    return N

N = get_input()

for ans in N:
    pre = ans
    for i in range(2,11):
        if i % 2 == 0:
            pre = (pre*2)
            ans += pre
        else:
            pre = (pre/3)
            ans += pre
    print(ans)
    



Measured memory_bytes: 5656
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
   int a,c= 0,s= 0,d = 0,o = 0;
   string b;
   cin >> a;
   for(int i = 0;i < a;i++){
       cin >> b;
       
       if(b == "AC") c += 1;
       if(b == "WA") s += 1;
       if(b == "TLE") d += 1;
       if(b == "RE") o += 1;
   }
   
   
   cout << "AC x "<<c<< endl;
   cout << "WA x "<<s<< endl;
   cout << "TLE x "<<d<< endl;
   cout << "RE x "<<o<< endl;
}


Measured memory_bytes: 3632
def binarySearch(list_a, key):
    left = 0
    right = len(list_a)
    while left < right:
        mid = (left + right) // 2
        if list_a[mid] == key:
            return mid
            break
        elif key < list_a[mid]:
            right = mid
        else:
            left = mid+1
    else:
        return mid

n,k = map(int, input().split())
list_x = list((map(int, input().split())))
ans = 10**9
key_point = binarySearch(list_x,0)
for i in range(key_point-k,key_point+1):
    if i < 0:
        continue
    try:
        dist = min(abs(list_x[i]),abs(list_x[i+k-1])) + (list_x[i+k-1] - list_x[i])
        if ans > dist:
            ans = dist
    except:
        pass
print(ans)


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

class Program
{
  	static void Main(string[] args)
    {
    	var n = int.Parse(Console.ReadLine());
        var t = Console.ReadLine().Split(' ');
        var m = int.Parse(Console.ReadLine());
        for (var i = 0; i < m; i++)
        {
        	var px = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var tmp = t.Select(int.Parse).ToArray();
            tmp[px[0]-1] = px[1];
            Console.WriteLine(tmp.Sum());
        }
    }
}

Measured memory_bytes: 11348
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>
 
#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second
 
const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;
 
const int NIL=-1;
 
struct Node{int parent,left,right;};
Node T[10004];
int n,D[10004],H[10004];
 
void setDepth(int u,int d) {
    if(u==NIL) return;
    D[u]=d;
    setDepth(T[u].left,d+1);
    setDepth(T[u].right,d+1);
}
 
int setHeight(int u) {
    int h1=0,h2=0;
    if(T[u].left!=NIL) h1=setHeight(T[u].left)+1;
    if(T[u].right!=NIL) h2=setHeight(T[u].right)+1;
 
    return H[u]=max(h1,h2);
}
 
int getSibling(int u) {
    if(T[u].parent==NIL) return NIL;
    if(T[T[u].parent].left!=u && T[T[u].parent].left!=NIL) return T[T[u].parent].left;
    if(T[T[u].parent].right!=u && T[T[u].parent].right!=NIL) return T[T[u].parent].right;
    return NIL;
}
 
void print(int u) {
    printf("node %d: ",u);
    printf("parent = %d, ",T[u].parent);
    printf("sibling = %d, ",getSibling(u));
    int deg=0;
    if(T[u].left!=NIL) deg++;
    if(T[u].right!=NIL) deg++;
    printf("degree = %d, ",deg);
    printf("depth = %d, ",D[u]);
    printf("height = %d, ",H[u]);
 
    if(T[u].parent == NIL) {
        printf("root\n");
    }
    else if(T[u].left==NIL&&T[u].right==NIL) {
        printf("leaf\n");
    }
    else {
        printf("internal node\n");
    }
 
}
 
int main() {
    int v,l,r;
    int root=0;
    cin>>n;
    rep(i,n) T[i].parent=NIL;
    rep(i,n) {
        cin>>v>>l>>r;
        T[v].left=l;
        T[v].right=r;
        if(l!=NIL) T[l].parent=v;
        if(r!=NIL) T[r].parent=v;
    }
    rep(i,n) if(T[i].parent==NIL) root=i;
    setDepth(root,0);
    setHeight(root);
    rep(i,n) print(i);
    return 0;
}

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

int findSumOfDigits(int n) {
  int total=0;
    while (n > 0) {
    total += n%10;
    n /= 10;
  }
  return total;
}


int main() {
  int N,sum;

  cin >> N;

  sum = findSumOfDigits(N);
  if (N % sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int S, h, m, s;

	scanf("%d", &S);

	h = S / 3600;
	S = S % 3600;

	m = S / 60;

	s = S % 60;

	printf("%d:%d:%d\n", h, m, s);

	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;
 
int32_t main(){
	IOS;
	int h,n;
	cin>>h>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		h-=x;
	}
	if(h<=0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
// AUTHOR - SANDEEP PRADHAN
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>
#include<limits.h>


#define eps 1e-8
#define PI 3.141592653589793
#define bsize 512

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<vector<int>>
#define pb push_back
#define bs 1000000007
const int INF = 1e9 + 5;

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL) ;
    cout.tie(NULL) ;
    
    int n, w;
    scanf("%d%d", &n, &w);
    vector<ll> dp(w + 1); 
    
    for(int i1 = 0; i1 < n; i1++) 
    {
        int weight, value;
        scanf("%d%d", &weight, &value);

        for(int i = w - weight; i >= 0; i--) 
        {
            dp[i + weight] = max(dp[i + weight], dp[i] + value);
        }
    }

    ll answer = 0;
    for(int i = 0; i <= w; ++i) 
        answer = max(answer, dp[i]);

    printf("%lld\n", answer);

    return 0;
}


Measured memory_bytes: 1024
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
# map(int, input().split())
# int(input())
# input().split()
# mojiretu = ','.join(str_list)
# sorted(input())

def primes(n):
    isp = [True for _ in range(n+1)]
    isp[0] = False
    isp[1] = False
    l = ceil(sqrt(n))
    n += 1
    for i in range(2, l):
        if not isp[i]: continue
        for j in range(i*2, n, i): isp[j] = False
    return isp

q = int(input())
maxv = 10**5
isp = primes(maxv)
cnt = [0 for _ in range(maxv + 1)]

for i in range(3, maxv+1):
    if i%2 and isp[i] and isp[(i+1)//2]:
        cnt[i] = 1
#print(cnt[:10])
acc = list(accumulate(cnt))
for _ in range(q):
    l, r = map(int, input().split())
    print(acc[r] - acc[l-1])

Measured memory_bytes: 10364
from heapq import *

N = int(input())
*A, = map(int, input().split())
creatures = [(a, 1) for a in A]
heapify(creatures)
ans = N
while len(creatures) > 1:
    a, m = heappop(creatures)
    b, n = heappop(creatures)
    if 2*a < b: ans -= m; m = 0;
    heappush(creatures, (a+b, m+n))
print(ans)

Measured memory_bytes: 16392
// Problem : B - Go to Jail
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// $%U%$
// Mere bas ka nahi hai
// still i'm trying
// apna time aayega
//
//        .--------------.  
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |  
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'                          		  
//
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll x,ll y,ll m){if(y==0)return 1;ll p=power(x,y/2,m)%m;p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
ll nCr(ll n,ll r,ll m){if(r>n)return 0;ll a=1,b=1,i;for(i=0;i<r;i++){a=(a*n)%m;--n;}while(r){b=(b*r)%m;--r;}return (a*power(b,m-2,m))%m;}
#define Test int t;cin>>t;while(t--)
#define endl '\n'
void solve()
{
	int n;
	cin >> n;
	
	vector<pair<int,int>> v(n);
	int cnt=0;
	bool ans=0;
	for(int i=0;i<n;++i)
	{
		cin >> v[i].first >> v[i].second;
		if(v[i].first==v[i].second)
		cnt++;
		else
		cnt=0;
		if(cnt>=3)
		ans=1;
	}
	if(ans)
	cout << "Yes" << endl;
	else
	cout << "No " << endl;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//Test
	solve();
	return 0;
}


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

const int DIM = 1e2 + 5;

int arr[DIM];

int main( void ) {
    
    int n;
    cin >> n;
    
    int ans = 0, cnt = 0;
    for( int i = 1; i <= n; i ++ ) {
        int x;
        cin >> x;
        
        if( x >= 3200 )
            cnt ++;
        else {
            if( arr[x / 400] == 0 )
                ans ++;
            arr[x / 400] = 1;
        }
    }
    
    if( cnt == n )
        cout << 1 << " ";
    else
        cout << ans << " ";
    
    cout << ans + cnt;
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;

using namespace std;
int main() {
	int nl; cin >> nl;

	int n = nl;
	int s = 0;
	for (int i = 0; i < 9; i++) {
		s += n % 10;
		n = n / 10;
	}

	if (nl % s == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pi 3.1415926535897932384626433832795
#define fin(a,n)  for(ll i=0;i<n;i++) cin>>a[i];
#define fout(a,n)  for(ll i=0;i<n;i++) cout<<a[i]<<" ";

using namespace std;

int main() 
{
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); cout.tie(NULL);
	int n,res;
	cin>>n;
	if(n <= 1000)
		res = 1000 - n;
	else
		res = (1000 - (n%1000))%1000;
	cout<<res<<'\n';
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	unsigned long long arrAns[50] = { 2 };
	register int i;
	for (i = 1; i <= 45; ++i){
		arrAns[i] = arrAns[i - 1] * 2 + 2;
	}
	cin >> i;
	cout << arrAns[i] << endl;
endapp:
	//system("pause > nul");
	return 0;
}

Measured memory_bytes: 256
s = input()
acgt = ['A','C','G', 'T']
counter = 0
ans = 0

for i, s_i in enumerate(s):
  if s_i in acgt:
    counter+=1
  else:
    ans = max(ans, counter)
    counter=0
    
  if i==len(s)-1:
    ans = max(ans, counter)
    counter=0
    
print(ans)

Measured memory_bytes: 9060
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int h=12,w=6,dx[]={1,0,-1,0},dy[]={0,1,0,-1},c,T;
char m[101][101];

void dfs(int y,int x,char ch){
	m[y][x]='?';c++;
	rep(i,4){
		int ny=y+dy[i],nx=x+dx[i];
		if(ny>=0&&ny<h&&nx>=0&&nx<w&&m[ny][nx]==ch)dfs(ny,nx,ch);
		if(ny>=0&&ny<h&&nx>=0&&nx<w&&m[ny][nx]=='O')m[ny][nx]='o';
	}
}

int main(){
	cin>>T;
	while(T--){
		int ans=0;
		rep(i,h)rep(j,w)cin>>m[i][j];
		while(1){
			int f=0;
			rep(i,h)rep(j,w)if(m[i][j]!='.'&&m[i][j]!='O'){
				c=0;
				char ch=m[i][j];
				dfs(i,j,m[i][j]);
				rep(k,h)rep(l,w){
					if(m[k][l]=='?'){
						if(c>3){m[k][l]='.';f=1;}
						else m[k][l]=ch;
					}
					if(m[k][l]=='o'){
						if(c>3)m[k][l]='.';
						else m[k][l]='O';
					}
				}
			}
			if(!f)break;
			for(int i=h-1;i>=0;i--)rep(j,w){
				if(m[i][j]!='.'){
					int ny=i;
					while(ny!=h-1&&m[ny+1][j]=='.')ny++;
					if(ny!=i){
						m[ny][j]=m[i][j];
						m[i][j]='.';
					}
				}
			}
			ans++;
		}
		cout<<ans<<endl;
	}
}

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

using namespace std;

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

    if (s.size() == 1) {
        cout << s << endl;
        return 0;
    }

    vector<string> vs;
    for (int i = 0; i < s.size(); ++i) {
        for (int j = 1; j <= k; ++j) {
            vs.push_back(s.substr(i, j));
        }
    }

    sort(vs.begin(), vs.end());
    vs.push_back("11");
    vector<string> vs2;
    for (int i = 0; i < vs.size()-1; ++i) {
        if (vs[i] != vs[i+1]) vs2.push_back(vs[i]);
    }
    cout << vs2[k-1] << endl;
}

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

using namespace std;

int main() {
  const int CAKE_PRICE = 4;
  const int DONUT_PRICE = 7;

  int N;
  cin >> N;

  string answer = "No";
  int cakesPrice = 0;
  while (cakesPrice <= N) {
    if (cakesPrice == N || (N - cakesPrice) % 7 == 0) {
      answer = "Yes";
      break;
    }

    cakesPrice += CAKE_PRICE;
  }

  cout << answer << endl;
}


Measured memory_bytes: 764
using System;

namespace PanaB
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ');
            long h = long.Parse(s[0]);
            long w = long.Parse(s[1]);

            if(h == 1 || w == 1)
            {
                Console.WriteLine(1);
                return;
            }
            long hh = (h + 1) / 2;
            
            if(h % 2 == 0)
            {
                Console.WriteLine(hh * w);
            }
            else
            {
                long q = ((hh * 2) - 1) * (w / 2);
                if (w % 2 == 0)
                {
                    Console.WriteLine(q);
                }
                else
                {
                    Console.WriteLine(q + hh);
                }
            }
        }
    }
}


Measured memory_bytes: 13140
#include <algorithm>
#include <string.h>
#include <cmath>
#include <stdio.h>

using namespace std;

int main(){
	int n;
	char c[10];
	int ans;
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		ans = 0;
		scanf("%s",c);
		sort(c,c+8);
		for(int j = 0; j < 8; j++){
			ans += (c[j] - c[7-j]) * pow((double)10,(int)j);
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int ans = 0;
  int minNum = 1e6;
  for (int i = 0; i < N; i++) {
    int p;
    cin >> p;
    
    if (p < minNum) {
      minNum = p;
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
// IN THE NAME OF ALLAH
#include <math.h>
#include <vector>
#include <set>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <stack>
#include<cstring>
#include <cstdlib>
#include <string>
#include <ctime>
#include <cstdio>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

#define int ll

#define F first
#define S second
#define mp make_pair
#define L(x) (2*(x))
#define R(x) ((2*(x))+1)
#define pii pair<int , int>

using namespace std;
typedef long long ll;

const int N = 2e6 + 5, Mod = 1e9 + 7, MAXN = 3e5 + 10, LG = 25 , M = 1e7 + 1, P = 727, Sq = 400;
const ll inf = 3e18 + 10;


map<int, int> has;

int Gcd(int x, int y){
      if(x > y)
            swap(x, y);
      if(!x)
            return y;
      return Gcd(x, y % x);
}
int Solve(int x, int y){
      return x * y / Gcd(x, y);
}
int32_t main(){
      ios_base::sync_with_stdio(0); cin.tie(0);
      int n, m; cin >> n >> m;
      string s, t; cin >> s >> t;
      int ret = Solve(n, m);
      for(int i = 1; i <= ret; i += ret/n)
            has[i] = (s[(i - 1)/(ret/n)] - 'a') + 1;
      for(int i = 1; i <= ret; i += ret/m)
            if(has[i] && has[i] != (t[(i - 1)/(ret/m)] - 'a') + 1)
               return cout << -1, 0;
      return cout << ret, 0;
}


Measured memory_bytes: 10880
S = input()
t = len(S)
words = ['dream', 'dreamer', 'erase', 'eraser']
while True:
  flg = True
  for i in range(t, -1, -1):
    if S[i:t] in words:
      t = i 
      flg = False
  if flg:
    print('NO')
    break
  if t == 0:
    print('YES')
    break

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

ll N, K, R, S, P;
string T;

array<vector<ll>, 3> memo = { vector<ll>(100000, -1), vector<ll>(100000, -1), vector<ll>(100000, -1) };
array<char, 256> c2i;

ll dfs(char hand, int index, int a)
{
    if (index * K + a >= N) {
        return 0;
    }

    auto hand_index = index * K + a;
    auto& memo_r = memo[c2i[hand]][hand_index];
    if (memo_r != -1) {
        return memo_r;
    }

    auto enemy_hand = T[hand_index];
    ll score = 0;
    if (hand == 'r') {
        if (enemy_hand == 's') {
            score += R;
        }
        score += max(dfs('s', index + 1, a), dfs('p', index + 1, a));
    }
    if (hand == 's') {
        if (enemy_hand == 'p') {
            score += S;
        }
        score += max(dfs('r', index + 1, a), dfs('p', index + 1, a));
    }
    if (hand == 'p') {
        if (enemy_hand == 'r') {
            score += P;
        }
        score += max(dfs('r', index + 1, a), dfs('s', index + 1, a));
    }

    memo_r = score;
    return score;
}

void main_()
{
    cin >> N >> K >> R >> S >> P;
    cin >> T;

    c2i['r'] = 0;
    c2i['s'] = 1;
    c2i['p'] = 2;

    ll ans = 0;
    for (ll i = 0; i < K; ++i) {
        ans += max({
            dfs('r', 0, i),
            dfs('s', 0, i),
            dfs('p', 0, i),
        });
    }
    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 7504
/*#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>*/
#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
#define mod 1e9 + 7;

int main(){
    ll a=0,b=0,c=0,d=0,ans=0,ret=M,n,m;
	string s;
	bool x = false;
	cin >> a >> b >> c;
	if(a+b == c){
		ans = c + b;
	}
	else if(a+b < c){
		ans = (a+b)*2-a+1;
	}
	else ans = b + c;
	cout << ans << endl;
    return 0;
}  


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

int main() {
    long long int a, b;
    cin >> a >> b;
    long long int x;
    cin >> x;
    long long int sup = b / x;
    long long int inf = a / x;
    if(a % x == 0) {
        inf--;
    }
    long long int ans = sup - inf;
    cout << ans << endl;
    return 0;
}

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

int main() {
  int i,N;
  cin >> N;
  vector<string> S(N);
  vector<int> P(N);
  for(i=0; i<N; i++)
    cin >> S.at(i) >> P.at(i);
  
  set<string> st;
  for(string x : S)
    st.insert(x);
  
  map<string,vector<pair<int,int>>> gb;
  
  for(auto x : st)
    gb[x] = vector<pair<int,int>>(0);
  
  for(i=0; i<N; i++)
    gb.at(S.at(i)).push_back(make_pair(P.at(i),i+1));
  
  for(auto x : st) {
    sort(gb.at(x).begin(), gb.at(x).end());
    reverse(gb.at(x).begin(), gb.at(x).end());
  }
  
  for(pair<string,vector<pair<int,int>>> p : gb)
    for(pair<int,int> q : p.second)
      cout << q.second << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define ios       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define forn(i,a,n) for (ll i = a; i < (ll)(n); i++)
#define fon(i,n) for (ll i = (ll)n-1; i >=0; i--)
#define vi          vector<ll>
#define vii vector<pair<ll,ll>>
#define all(a)      (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ciin(v) forn(i,0,v.size()) cin>>v[i]
#define coutt(v) forn(i,0,v.size()) cout<<v[i]<<" "
using namespace std; 
int main(){
    ios
    ll t;
    t=1;
    //cin>>t;
    while(t--){
       string s;
       cin>>s;
       if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

        
        

    }}

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

const int INF = 1e9;

int main() {
  int N, W;
  cin >> N >> W;
  vector<int> w(N), v(N);
  for (int i = 0; i < N; i++) {
    cin >> w[i] >> v[i];
  }
  int sv = accumulate(begin(v), end(v), 0);
  vector<vector<ll>> dp(N + 1, vector<ll>(sv + 1, INF));
  dp[0][0] = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= sv; j++) {
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
      if (j >= v[i]) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
    }
  }
  int ans = 0;
  for (int i = 0; i <= sv; i++) {
    if (dp[N][i] <= W) ans = max(ans, i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 80256
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}
map<ll,ll>dp;

ll findAns(ll h){
    if(h==1){
        return 1;
    }else if(dp.count(h)){
        return dp[h];
    }
    return dp[h]=(findAns(h/2) + findAns(h/2) + 1);
}

void Flash(){
    ll h;
    cin>>h;
    cout<<findAns(h)<<"\n";
}

int main(int argc, char const *argv[]){
    ThunderClap;
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}

Measured memory_bytes: 256