akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        //Compute c1 = new Compute();//calc

        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //StringBuilder answer=new StringBuilder();

        //input
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String ans[]={"Yes","No"};

        String ss[]=new String[s.length()];
        for (int i=0;i<s.length();++i) ss[i]=s.substring(i,i+1);
        int p1=0;
        int p2=0;

        for (int i=0;i<s.length();++i)
        {
            //System.out.println(i+1);
            //System.out.println(ss[i]);
            if ((i+1)%2==1)
            {
                if (ss[i].equals("L"))
                {
                    p1=1;
                    //System.out.println("hit1" + (i+1));
                }
            }else
            {
                if (ss[i].equals("R"))
                {
                    p2=1;
                    //System.out.println("hit2" + (i+1));
                }
            }
            //System.out.println("------------------");
        }

        if (p1!=1 && p2!=1) System.out.println(ans[0]);
        else System.out.println(ans[1]);
    }
}

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



int main() {
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL); 
  int n ;
	cin>>n;
	vector<long long>mon(n);
	for(int i  = 0 ; i< n ; i++ ){
		long long y; cin>>y;
		mon[i]=y;
	}

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

	while(mon.size()>1){
			for(int i = 1 ; i< mon.size() ; i++){
				mon[i]=mon[i]%mon[0];
				if(mon[i]==0){
					mon.erase(mon.begin()+i);
					i--;
				}
		}
		sort(mon.begin(),mon.end());
		
	}

	cout<<mon[0];
}

Measured memory_bytes: 1024
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

A, B, C = map(int, input().split())
r = set()

i = 1
ans = "NO"
while True:
    t = (A*i) % B
    if t in r:
        break
    else:
        if t == C:
            ans = "YES"
            break
        else:
            i += 1
            r.add(t)
print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define MaxN 200000+100
typedef long long LL;
int loca[MaxN];
int main()
{
    int N;
    scanf("%d",&N);
    for(int i=0;i<N;i++)
    {
        int num;
        scanf("%d",&num);
        loca[num]=i;
    }
    int max=1;
    int ans=1;
    for(int i=N-1;i>=1;i--)
    {
        if(loca[i]<loca[i+1])
            ans++,max=max>ans?max:ans;
        else
            ans=1;
    }
    printf("%d\n",N-max);
    return 0;
}


Measured memory_bytes: 1024
//ysh_gpta
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;


#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define IN(i,l,r) (l<i&&i<r)   //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)


#define repf(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define repfe(i,L,R) for (int i = L; i <= R; i++)
#define repb(i,L,R) for (int i = L; i > R; i--)
#define repbe(i,L,R) for (int i = L; i >= R; i--)


typedef long long ll;
#define cerr if(false)cerr
#define vb vector<bool>
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define mkp make_pair
#define pb push_back
#define INF 1000000000000000
#define MOD 1000000007
#define ff first
#define ss second


#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


ll gcd( ll a, ll b ){if(b==0) return a; else return gcd( b, a%b );}
ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}


vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

ll n;
ll dp[22][1<<22];
ll v[22][22];

ll solve(ll i,ll mask){
    if(!i)
    return ((mask==((1<<n)-1)) ? 1LL : 0LL);
    if(dp[i][mask]!=-1)
    return dp[i][mask];
    dp[i][mask] = 0LL;
    repf(j,0,n){
        if(v[i-1][j] && (!(mask & (1<<j))))
        dp[i][mask] = (dp[i][mask] + solve(i-1,mask|(1<<j)))%MOD;
    }
    return dp[i][mask];
}

int main(){
    FastIO
    cin>>n;
    repf(i,0,n)
    repf(j,0,n)
    cin>>v[i][j];
    memset(dp,-1,sizeof(dp));
    cout<<solve(n,0);
    return 0;
}

Measured memory_bytes: 721280
//s.empty() //emptyなら1を出力 入っていれば0を出力
/*//ABC018-B 部分的にreverseをかける解法
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  rep(i,n) cin>>a.at(i)>>b.at(i);
  rep(i,n)a.at(i)--;
  rep(i,n)b.at(i)--;
  string t;
  rep(i,n){
    t = s;
    for(int k=0;k<=b.at(i)-a.at(i);k++){
      t.at(a.at(i)+k) = s.at(b.at(i)-k);
    }
    s = t;
  }
  cout << s << endl;
}
*///ABC018-B
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string a;
  cin >> a;
  int zcount=0;
  int icount=0;
  rep(i,a.size()){
    if(a.at(i)=='0')zcount++;
    else 		  icount++;
  }
  if(zcount>icount) cout<<2*icount<<endl;
  else if(zcount<icount) cout<<2*zcount<<endl;
  else cout<<2*zcount<<endl;
}


Measured memory_bytes: 3728
#include<iostream>
#include<vector>
#include<string>

const int INF = 1000000000;
int n;
int target[3];
std::vector<int> l;

// ref : https://img.atcoder.jp/abc119/editorial.pdf
// ref : https://drken1215.hatenablog.com/entry/2019/02/24/224100
/*
延長、縮小は合成の前後どっちでやろうが同じ
-> 合成魔法を一切これ以降使用しない場合に限り延長、縮小魔法を使用としても一般性は失われない
目的を達成するに当たって竹はA, B, Cの材料or一切使わないの4通り
-> N本あるので4^N通り
そこで合成するペアだけ全探索すればあとは目標の長さを得るためのコストを計算すればok
*/

int solve(int i = 0, int a = 0, int b = 0, int c = 0){
    if(i == n){
        // どれも目標の長さを作るのに使っていない場合はダメ
        if(!a || !b || !c) return INF;
        else return std::abs(a - target[0]) + std::abs(b - target[1]) + std::abs(c - target[2]);
    }

    int cost = INF;
    cost = std::min(cost, solve(i + 1, a, b, c)); // この竹を使わない
    // 以降使う, このとき最初の1本目は合成できていないので+10しないことに注意
    cost = std::min(cost, solve(i + 1, a + l[i], b, c) + (a ? 10 : 0));
    cost = std::min(cost, solve(i + 1, a, b + l[i], c) + (b ? 10 : 0));
    cost = std::min(cost, solve(i + 1, a, b, c + l[i]) + (c ? 10 : 0));
    return cost;
}

int main(){
    std::cin >> n;
    l.assign(n, 0);
    for(int i = 0; i < 3; i++) std::cin >> target[i];
    for(int i = 0; i < n; i++){
        std::cin >> l[i];
    }

    std::cout << solve() << std::endl;

    return 0;
}


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

int main(){
  int n; cin>>n;
  vector<int> num(n);
  for(int i=0;i<n;i++){
    cin>>num[i];
  }
  vector<int> col(1);
  int mx=num[n-1];
  col[0]=num[n-1];
  for(int i=n-2;i>=0;i--){
    if(mx>num[i]){
      auto itr=upper_bound(col.begin(),col.end(),num[i]);
      int j=int(itr-col.begin());
      if(col[j]==mx && j==col.size()-1) mx=num[i];
      col[j]=num[i];
    }else{
      col.push_back(num[i]);
      mx=num[i];
    }
  }  
  cout<<col.size()<<endl;
}     

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

namespace flow {

struct edge {
  int to, cap, cost, rev;
  edge(int t, int ca, int co, int r) : to(t), cap(ca), cost(co), rev(r) {}
};

struct primal_dual {

  vector<vector<edge>> G;
  vector<int> h;
  vector<int> dist;
  vector<int> prevv, preve;

  primal_dual(int V) : G(V), h(V), dist(V), prevv(V), preve(V) {}

  void add_edge(int from, int to, int cap, int cost) {
    G[from].emplace_back(to, cap, cost, G[to].size());
    G[to].emplace_back(from, 0, -cost, G[from].size()-1);
  }

  int min_cost_flow(int s, int t, int f) {
    int ret = 0;
    fill(h.begin(), h.end(), 0);
    while(f > 0) {
      typedef pair<int, int> P;
      priority_queue<P, vector<P>, greater<P>> pq;
      fill(dist.begin(), dist.end(), inf);
      dist[s] = 0;
      pq.emplace(0, s);
      while(!pq.empty()) {
        P p = pq.top(); pq.pop();
        int v = p.second;
        if(dist[v] < p.first) { continue; }
        for(int i=0; i<G[v].size(); i++) {
          auto& e = G[v][i];
          if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
            dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
            prevv[e.to] = v;
            preve[e.to] = i;
            pq.emplace(dist[e.to], e.to);
          }
        }
      }

      if(dist[t] == inf) { return -1; }
      for(int i=0; i<h.size(); i++) h[i] += dist[i];

      int d = f;
      for(int i=t; i!=s; i=prevv[i]) {
        d = min(d, G[prevv[i]][preve[i]].cap);
      }
      f -= d;
      ret += d * h[t];
      for(int i=t; i!=s; i=prevv[i]) {
        auto& e = G[prevv[i]][preve[i]];
        e.cap -= d;
        G[i][e.rev].cap += d;
      }
    }
    return ret;
  }

};

}

int main() {

  int N; cin >> N;

  vector<int> ps(N);
  rep(i, N) cin >> ps[i], ps[i]--;

  flow::primal_dual pd(2 * N + 2);

  int SRC = 2 * N, SINK = 2 * N + 1;

  rep(i, N) {
    pd.add_edge(SRC, i, 1, 0);
    pd.add_edge(N + i, SINK, 1, 0);
  }

  rep(i, N) rep(j, N) {
    if(ps[i] != j) {
      pd.add_edge(i, N + j, 1, (ps[i] + 1) * abs(i - j));
    }
  }

  cout << pd.min_cost_flow(SRC, SINK, N) << endl;

  return 0;
}

Measured memory_bytes: 3436
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

void isrepeated(int n, int &ans)
{
  vi a;
  int m = n;
  while (n > 0)
  {
    a.push_back(n % 10);
    n /= 10;
  }
  bool result = true;
  rep(i, a.size() - 1)
  {
    if (a.at(i) != a.at(i + 1))
    {
      result = false;
      break;
    }
  }
  if(result){
    ans = m;
  }
}

int main()
{
  int n;
  cin >> n;
  int ans = -1;
  int i = n;
  while (ans < 0)
  {
    isrepeated(i, ans);
    i++;
  }

  cout << ans << endl;

  return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

    int ac = 1900;
    int n, m;
    cin >> n >> m;

    cout << (ac * m + 100 * (n - m)) * pow(2, m) << '\n';
    return 0;
}

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


int main(){
  ll n;int k;
  cin >> n >> k;
  int i=0;
  while(1){
    if(pow(k,i)-1<n)i++;
    else {
      cout << i;
      return 0;
    }
  }
}



Measured memory_bytes: 256
#include<stdio.h>


int main() {
    int W, H, x, y, r;
    scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
    bool inR = false;
    int a, b;
    a = H - r;
    b = W - r;
    if (y > 0 && x>0) {
        if (y>=r && y <= a && x>=r && x <= b) {
            
            inR = true;

        }
    }
    if (inR == false) {
        printf("No\n");
    }
    else {
        printf("Yes\n");
    }

    return 0;
}


Measured memory_bytes: 2696
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=200005,mod=200003;
const double pi=3.141592653589793;
int n,m=524288,a[N],b[N],p[N*2],pos[N];
long long ans;
int rev[N*3];
struct complex{
	long double x,y;
	complex(){}
	complex(long double x,long double y):x(x),y(y){}
	friend complex operator + (const complex &a,const complex &b){
		return complex(a.x+b.x,a.y+b.y);
	}
	friend complex operator - (const complex &a,const complex &b){
		return complex(a.x-b.x,a.y-b.y);
	}
	friend complex operator * (const complex &a,const complex &b){
		return complex(a.x*b.x-a.y*b.y,a.x*b.y+a.y*b.x);
	}
}x[N*3];
void fft(complex *a,int md){
	for(int i=0;i<m;i++){
		if(i<rev[i]){
			swap(a[i],a[rev[i]]);
		}
	}
	for(int i=1;i<m;i<<=1){
		complex wn=complex(cos(pi/i),md*sin(pi/i));
		for(int j=0;j<m;j+=(i<<1)){
			complex w=complex(1,0);
			for(int k=j;k<j+i;k++,w=w*wn){
				complex x=a[k];
				complex y=w*a[k+i];
				a[k]=x+y;
				a[k+i]=x-y;
			}
		}
	}
	if(md==-1){
		for(int i=0;i<m;i++){
			a[i].x/=m;
		}
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		a[i]%=mod;
	}
	p[0]=1;
	for(int i=1;i<=mod*2;i++){
		p[i]=p[i-1]*2%mod;
	}
	for(int i=0;i<mod;i++){
		pos[p[i]]=i;
	}
	for(int i=1;i<=n;i++){
		if(!a[i]){
			continue;
		}
		b[i]=pos[a[i]];
		x[b[i]].x++;
	}
	for(int i=0;i<m;i++){
		rev[i]=(rev[i>>1]>>1)|(i&1)*(m>>1);
	}
	fft(x,1);
	for(int i=0;i<m;i++){
		x[i]=x[i]*x[i];
	}
	fft(x,-1);
	for(int i=0;i<mod*2;i++){
		ans+=p[i]*((long long)(x[i].x+0.5));
	}
	for(int i=1;i<=n;i++){
		if(!a[i]){
			continue;
		}
		ans-=p[2*b[i]];
	}
	ans/=2;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 24856
N = int(input())
A = []
B = []
for i in range(2,int(N**0.5)+1):
    if N%i==0:
        A.append(i)
        A.append(N//i)
    if (N-1)%i==0:
        B.append(i)
        B.append((N-1)//i)
A.append(N)
if N>2:
    B.append(N-1)
A = sorted(A)
for a in A:
    m = 1
    while True:
        if a**m==N:
            B.append(a)
            break
        elif a**m>N:
            break
        m += 1
for a in A:
    m=0
    while a**m<N:
        if N%a**m==0:
            if (N//(a**m)-1)%a==0:
                B.append(a)
        m += 1
B = sorted(list(set(B)))
print(len(B))

Measured memory_bytes: 41180
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 105;
const int P = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int dp[MAXN][MAXN];
int fac[MAXN], inv[MAXN];
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
int power(int x, int y) {
	if (y == 0) return 1;
	int tmp = power(x, y / 2);
	if (y % 2 == 0) return 1ll * tmp * tmp % P;
	else return 1ll * tmp * tmp % P * x % P;
}
int main() {
	int n; read(n);
	fac[0] = inv[0] = 1;
	for (int i = 1; i <= n; i++) {
		fac[i] = 1ll * fac[i - 1] * i % P;
		inv[i] = power(fac[i], P - 2);
	}
	dp[n - 1][n] = dp[n - 1][n + 1] = 1;
	for (int i = n - 1; i >= 1; i--)
	for (int j = 0; j <= 2 * n; j++) {
		int r = j - n;
		for (int p = 0; p <= i; p++)
		for (int q = 0; p + q <= i; q++)
			if (p + q != 0 && (r + p - q) % 2 == 0 && r + p + q >= 0 && r - p - q <= 0) {
				update(dp[i - p - q][n + (r + p - q) / 2], 1ll * dp[i][j] * inv[p] % P * inv[q] % P);
			}
	}
	writeln(1ll * fac[n] * dp[0][n] % P);
	return 0;
}

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

using namespace std;

const int NMAX = 200000 + 1;
int lft[NMAX] = {};
int rgt[NMAX] = {};

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

    while (m--) {
        int a, b;
        cin >> a >> b;
        if (a == 1) lft[b] = 1;
        if (b == n) rgt[a] = 1;
    }

    bool flag = false;
    for (int i = 2; i < n; ++i) {
        if (lft[i] == 1 and rgt[i] == 1) {
            flag = true;
            break;
        }
    }

    if (flag) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 1792
//=======================//
// coder: Andy - Tohrumi //
//=======================//

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define pb emplace_back
#define mp make_pair
#define rep(i, a, b) for(__typeof(b) i = a; i < b; ++i)
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; --i)

typedef vector<int> vi;

vector<vi> graph;
int dp[100005];
vi visited;

void dfs(int u) {
	if (visited[u]) return;
	visited[u] = 1;
	for (int v : graph[u]){
		if (dp[v] == -1) dfs(v);
		dp[u] = max(dp[u], dp[v] + 1);
	}
	dp[u] = max(dp[u], 0);
	return;
}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, m, a, b; cin >> n >> m;
	graph.assign(n, vi());
	visited.assign(n, 0);
	rep(i, 0, m) {
		cin >> a >> b;
		a--; b--;
		graph[a].pb(b);
	}
	rep(i, 0, n) dp[i] = -1;
	rep(i, 0, n) dfs(i);
	cout << *max_element(dp, dp + n);
}

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

int main(){
    ll n;
    cin>>n;
    ll a[5];
    ll mn=1e18;
    rep(i,5){
        cin>>a[i];
        mn=min(mn,a[i]);
    }
    ll ans=5;
    if(n%mn!=0)ans+=n/mn;
    else ans+=n/mn-1;
    cout<<ans<<endl;
    return 0;
}

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

namespace ABC128C
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = ReadInt();
            int N = NM[0];
            int M = NM[1];

            List<int>[] switches = new List<int>[M];
            for (int i = 0; i < M; i++)
            {
                switches[i] = new List<int>();
                var input = ReadInt();
                for (int j = 0; j < input[0]; j++)
                {
                    switches[i].Add(input[j + 1] - 1);
                }
            }
            int[] p = ReadInt();

            int ans = 0;

            //bit全探索
            int n = N;
            for (int bit = 0; bit < (1 << n); ++bit)
            {
                bool ok = true;
                List<int> S = new List<int>();
                for (int j = 0; j < M; j++)
                {
                    int c = 0;
                    foreach (var i in switches[j])
                    {
                        if ((bit & (1 << i)) != 0)
                        {
                            c++;
                        }
                    }
                    if (c % 2 != p[j])
                    {
                        ok = false;
                        break;
                    }
                }
                if (ok) ans++;
            }
            Console.WriteLine(ans);
            Console.ReadKey();
        }


        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


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

int main(){
  int N,sum=0;
  cin>>N;
  vector<int> pri={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
  vector<int> ko(15);
  for(int i=0;i<15;i++){
    ko.at(i)=0;
    for(int j=1;j<=6;j++){
      ko.at(i)+=N/pow(pri.at(i),j);
    }
  }
  if(ko.at(0)>=74){
    sum++;
  }
  if(ko.at(0)>=24){
    for(int i=1;i<15;i++){
      if(ko.at(i)>=2){
        sum++;
      }
    }
  }
  if(ko.at(1)>=24){
    for(int i=2;i<15;i++){
      if(ko.at(i)>=2){
        sum++;
      }
    }
    sum++;
  }
  if(ko.at(2)>=24){
    for(int i=3;i<15;i++){
      if(ko.at(i)>=2){
        sum++;
      }
    }
    sum++;
    sum++;
  }
  
  if(ko.at(0)>=14){
    for(int i=1;i<15;i++){
      if(ko.at(i)>=4){
        sum++;
      }
    }
  }
  if(ko.at(1)>=14){
    for(int i=2;i<15;i++){
      if(ko.at(i)>=4){
        sum++;
      }
    }
    sum++;
  }
  if(ko.at(2)>=14){
    for(int i=3;i<15;i++){
      if(ko.at(i)>=4){
        sum++;
      }
    }
    sum++;sum++;
  }
  if(ko.at(3)>=14){
    for(int i=4;i<15;i++){
      if(ko.at(i)>=4){
        sum++;
      }
    }
    sum++;sum++;sum++;
  }
  
  int s4=0,s2=0;
  for(int i=0;i<15;i++){
    if(ko.at(i)>=4){
      s4++;
    }
    if(ko.at(i)>=2){
      s2++;
    }
  }
  if(s4>=2){
    sum+=((s4*(s4-1))/2)*(s2-2);
  }
  cout<<sum<<endl;
  
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define IMP cout << "IMPOSSIBLE" << endl
#define Imp cout << "Impossible" << endl
#define imp cout << "impossible" << endl
#define M1 cout << "-1" << endl
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n = in();
    string s = in();

    vint ve(n, 0), vw(n, 0);
    rep(i, n)
    {
        ve[i + 1] += ve[i];
        vw[i + 1] += vw[i];
        ++(s[i] == 'E' ? ve[i + 1] : vw[i + 1]);
    }

    int ans = INF;
    rep(i, n)
    {
        ans = min(ans, vw[i] + ve[n] - ve[i + 1]);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 2964
N=int(input())
A=list(map(int,input().split()))
ans=0
while True:
    tmp=[]
    count=0
    for a in A:
        tmp.append(a//2)
        if a%2==0:
            count+=1
    if count==N:
        ans+=1
    else:
        break
    A=tmp
print(ans)
    

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

// BEGIN CUT HERE
pair< V<>, V< pair<int, int> > > lowlink(const VV<>& g, V<>& ord, V<>& low, int r = 0) {
  int n = g.size();
  ord.assign(n, -1); // pre-order
  low.assign(n, -1); // 後退辺を高々1回通って到達できる頂点のordのmin
  V<> articulation_points;
  V< pair<int, int> > bridges;
  int t = 0;
  auto dfs = [&](const auto& dfs, int v, int p) -> void {
    ord[v] = low[v] = t++;
    int d = 0;
    bool f = false;
    for (int w : g[v]) if (w != p) {
      if (ord[w] == -1) {
        dfs(dfs, w, v);
        low[v] = min(low[v], low[w]);
        f |= ord[v] <= low[w];
        if (ord[v] < low[w]) bridges.emplace_back(minmax(v, w));
        ++d;
      } else {
        low[v] = min(low[v], ord[w]);
      }
    }
    if (v == r and d >= 2 or v != r and f) {
      articulation_points.push_back(v);
    }
  };
  dfs(dfs, r, -1);
  sort(begin(articulation_points), end(articulation_points));
  sort(begin(bridges), end(bridges));
  return {articulation_points, bridges};
}
// END CUT HERE

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  VV<> g(n);
  while (m--) {
    int s, t; cin >> s >> t;
    g[s].push_back(t);
    g[t].push_back(s);
  }
  V<> ord, low;
  // for (int v : lowlink(g(, ord, low)).first) {
  //   cout << v << '\n';
  // }
  for (const auto& e : lowlink(g, ord, low).second) {
    cout << e.first << ' ' << e.second << '\n';
  }
}

// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3428946#1


Measured memory_bytes: 4580
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static int N = sc.nextInt();
    static int W = sc.nextInt();
    static long weight[] = new long[110];
    static long value[] = new long[110];
    static long dp[][] = new long[110][100100];

    public static void main(String[] args) {
        //標準入力取得
        for (int i = 0; i < N; i++){
            weight[i] = sc.nextLong();
            value[i] = sc.nextLong();
        }
        for (int i = 0; i < 110; i++){
            for (int j = 0; j < 100100; j++){
                dp[i][j] = 2147483647;
            }
        }

        dp[0][0] = 0;
        for (int i = 0; i < N; i++){
            for (int sum_v = 0; sum_v < 100100; sum_v++){
                if (sum_v - value[i] >= 0)
                    dp[i + 1][sum_v] = chmin(dp[i + 1][sum_v], dp[i][(int)(sum_v - value[i])] + weight[i]);
                dp[i + 1][sum_v] = chmin(dp[i + 1][sum_v], dp[i][sum_v]);
            }
        }
        long result = 0;
        for (int sum_v = 0; sum_v < 100100; sum_v++){
            if (dp[N][sum_v] <= W)
                result = sum_v;
        }
        System.out.println(result);
    }

    public static long chmin(long a, long b){
        if (a > b){
            return b;
        } else {
            return a;
        }
    }

}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll mod = 1000000007;

int main(void)
{
	int n;
	cin >> n;
	set<string> s;
	rep(i, n) {
		string a;
		cin >> a;
		s.insert(a);
	}
	cout << s.size() << endl;
	return 0;
}


Measured memory_bytes: 19256
#include <bits/stdc++.h>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
LL z = 1;
int read(){
	int x, f = 1;
	char ch;
	while(ch = getchar(), ch < '0' || ch > '9') if(ch == '-') f = -1;
	x = ch - '0';
	while(ch = getchar(), ch >= '0' && ch <= '9') x = x * 10 + ch - 48;
	return x * f;
}
int ksm(int a, int b, int p){
	int s = 1;
	while(b){
		if(b & 1) s = z * s * a % p;
		a = z * a * a % p;
		b >>= 1;
	}
	return s;
}
int ok(int x){
	int a = x % 10;
	while(x){
		if(x % 10 != a) return 0;
		x /= 10;
	}
	return 1;
}
int main(){
	int i, j, n, m;
	n = read();
	for(i = n; i <= 999; i++){
		if(ok(i)){
			printf("%d", i);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
/*
	0522:JOI and IOI
*/
#include	<iostream>
#include	<string>
#include	<cstdio>
#include	<cstring>

using namespace std;

int main(void) {
	char str[10001];
	
	while(1) {
		int cJOI = 0, cIOI = 0;
		
		if( scanf("%s", str) == EOF) { break; }
		
		for(int i = 0; i + 2 < (int)strlen(str); i++) {
			if( str[i+1] == 'O' && str[i+2] == 'I' ) {
				if( str[i] == 'J' ) {
					//cout << "JOI:count..." << endl;
					cJOI++;
				}
				if( str[i] == 'I' ) {
					//cout << "IOI:count..." << endl;
					cIOI++;
				}
			}
		}
		
		cout << cJOI << endl << cIOI << endl;
	}
}

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

int main()
{
        ll N, M;
        cin >> N >> M;
        vector<bool> A(N, false);
        vector<bool> B(N, false);
        for (int i = 0; i < M; ++i) {
                int a, b;
                cin >> a >> b;
                if (a == 1) {
                        A[b-1] = true;
                }
                else if (b == N) {
                        B[a-1] = true;
                }

        }
        for (int i = 0; i < N; ++i) {
                if (A[i] == true && B[i] == true) {
                        cout << "POSSIBLE" << endl;
                        exit(0);
                }
        }
        cout << "IMPOSSIBLE" << endl;


}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int c5=0, c7=0, b;
  for(int i=0; i<3; i++){
    scanf("%d", &b);
    if(b == 5) c5++;
    if(b == 7) c7++;
  }
  if(c5 == 2 && c7 == 1){printf("YES");}
  else{printf("NO");}
  return 0;
}

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

#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...);
}


typedef long long ll;

string K;

int D;
const ll mod = 1e9+7;

ll DP[2][100][10000];

ll sum(ll a, ll b){

    ll rta = a+b;
    return a+b>=mod ? rta-mod : rta;
}

int sub(int a, int b){
    a = a%D; b = b%D;
    int rta = a-b+D;
    return rta>=D ? rta-D : rta;
}

ll dp(int l, int m, int i){
    if(i==K.size()) return m==0;
    if(DP[l][m][i]!=-1) return DP[l][m][i];
    ll rta = 0;

    if(l){
        for(int j = 0; j<K[i]-'0'; ++j){
            rta=sum(rta, dp(0, sub(m, j), i+1));
        }
        rta=sum(rta, dp(1, sub(m, K[i]-'0'), i+1));
    }
    else{
        for(int j = 0; j<10; ++j){
            rta=sum(rta, dp(0, sub(m, j), i+1));
        }
    }

    return DP[l][m][i] = rta;
}

int main(){
    memset(DP, -1, sizeof(DP));
    cin>>K>>D;
    ll rta = dp(1,0, 0)-1;
    if(rta<0) rta+=mod;
    cout<<rta<<"\n";
}


Measured memory_bytes: 20184
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[][] = new int[N][2];
		for(int i = 0; i < N; i++) {
			A[i][0] = sc.nextInt();
			A[i][1] = sc.nextInt();
		}
		Arrays.sort(A, Comparator.comparingInt(o -> o[1]));
		
		long cnt = 0;
		for(int i = 0; i < N; i++) {
			cnt += A[i][0];
			if(cnt > A[i][1]) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 107028
n = int(input())
p = list(map(int,input().split(' ')))
count = 0
for i in range(1,n-1):
    if p[i-1] < p[i] < p[i+1] or p[i-1] > p[i] > p[i+1]:
        count = count + 1
print(count)

Measured memory_bytes: 3444
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		static long mod = 1000000007;

		static void Main(string[] args)
		{

			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int H = vs[0];
			int W = vs[1];
			string[] map = new string[H];
			for (int i = 0; i < H; i++) {
				map[i] = Console.ReadLine();
			}

			long[,] dp = new long[W, H];
			dp[0, 0] = 1;
			for (int x = 0; x < W; x++) {
				for (int y = 0; y < H; y++) {
					if (x == 0 && y == 0) {
						continue;
					}
					long c = 0;
					if (map[y][x] == '.') {
						if (x > 0) {
							c = (c + dp[x - 1, y]) % mod;
						}
						if (y > 0) {
							c = (c + dp[x, y - 1]) % mod;
						}
						dp[x, y] = c;
					}
				}
			}
			Console.WriteLine(dp[W - 1, H - 1]);
		}
	}
}

Measured memory_bytes: 29148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll dp[MAXn],h[MAXn];
ll pw(ll x){return x*x;}
ii getslope(ll x,ll y){  //y<x
  ll dy = dp[x]-dp[y]+pw(h[x])-pw(h[y]);
  ll dx = 2*(h[x]-h[y]);
  ii ret = mkp(dy,dx);
  return ret;
}
int main(){
  IOS();
  ll n,C;
  cin >> n >> C;
  REP (i,n) cin >> h[i];

  dp[0] = 0;
  deque<ll> dq;
  dq.eb(0);
  REP1 (i,n-1) {
    if (SZ(dq) == 1) {
      ll bst = dq.front();
      dp[i] = dp[bst] + pw(h[i]-h[bst])+C;
      dq.eb(i);
    }
    else {
      while (SZ(dq) > 1) {
        ll bst = dq.front();
        dq.pop_front();
        ii slope = getslope(bst,dq.front());
        if (slope.X >= h[i]*slope.Y) continue;
        else {
          dq.emplace_front(bst);
          break;
        }
      }
      ll bst = dq.front();
      dp[i] = dp[bst] + pw(h[i]-h[bst])+C;

      if (SZ(dq) == 1) dq.eb(i);
      else {
        while (SZ(dq) > 1) {
          ll lst = dq.back();
          dq.pob();
          ii slope1 = getslope(lst,i);
          ii slope2 = getslope(dq.back(),lst);
          if (slope1.X*slope2.Y <= slope1.Y*slope2.X) continue;
          else {
            dq.eb(lst);
            break;
          }
        }
        dq.eb(i);
      }
    }
  }
  cout << dp[n-1] << endl;
}


Measured memory_bytes: 4480
/*
 © 2020-06-27 07:00:49 Franco1010 All Rights Reserved
*/

#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  string s, t; cin >> s >> t;
  lli res = 0;
  fore(i, 0, sz(s)){
    if(s[i] != t[i]) res++;
  }
  cout << res << ENDL;
  return 0;
}


Measured memory_bytes: 3828
#include <iostream>
#include <cstring>
using namespace std;
int main() {
	char a[55], b[55];
	cin >> a >> b;
	int la = strlen(a), lb = strlen(b);
	int maxn = 55;
	for(int i = 0; i <= la - lb; i++) {
		bool flag = true;
			for(int j = 0; j < lb; j++)
				if(a[i + j] != '?' && a[i + j] != b[j]) {
					flag = false;
					break; 
				}
			if(flag == true)
				maxn = i;
		}
	if(maxn == 55)
		cout << "UNRESTORABLE" << endl;
	else {
		for(int i = 0; i < lb; i++)
			a[maxn + i] = b[i];
		for(int i = 0; i < la; i++)
			if(a[i] == '?')
				a[i] = 'a';
		cout << a << endl;
	}
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
using namespace std;

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

    vector<int> l(N);

    for (int i = 0; i < N; i++)
    {
        cin >> l[i];
    }

    int min = 100000;

    for (int i = 0; i < (int)pow(4, N); i++)
    {
        vector<int> type(N);
        bitset<16> bs(i);

        for (int j = 0; j < N; j++)
        {
            type[j] = 2 * bs[2 * j + 1] + bs[2 * j];
        }

        int cost = 0;
        bool all = true;

        for (int j = 0; j < 3; j++)
        {
            int use = 0;
            int sum = 0;
            for (int k = 0; k < N; k++)
            {
                if (type[k] == j)
                {
                    use++;
                    sum += l[k];
                }
            }

            cost += (use - 1) * 10 + abs(ABC[j] - sum);
            all = all && (use != 0);
        }

        if (cost < min && all)
        {
            min = cost;
        }
    }

    cout << min << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cmath>
#include <iostream>
using namespace std;

int main(void){
  int a,l,x;
  while(cin>>a>>l>>x){
    double s1=(a+2.0*l)/2.0;
    double S=sqrt(s1*(s1-a)*(s1-l)*(s1-l));
    double s2=(2.0*l+x)/2.0;
    S+=2.0*sqrt(s2*(s2-l)*(s2-(l+x)/2.0)*(s2-(l+x)/2.0));
    printf("%.10f\n",S);
  }
  return 0;
}

Measured memory_bytes: 1196
local N=tonumber(io.read())
local H={}
for s in io.read():gmatch("(%S+)%s*")do
  H[#H+1]=tonumber(s)
end
local max=0
local cnt=0

for i=1,N do
  if(max<=H[i])then
    cnt=cnt+1
    max=H[i]
  end
end
print(cnt)

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

int main() {
    int N;
    cin >> N;
    long long ans = 0;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for(int i = 1; i < N; i++){
        if(A[i - 1] > A[i]){
            ans += A[i - 1] - A[i];
            A[i] = A[i - 1];
        }
    }
    cout << ans << endl;
}

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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> p;
    while(N > 0)
    {
        ll res = N % 26;
        if (res == 0)
        {
            res = 26;
        }
        p.push_back(res);
        N /= 26;
        if (res == 26)
        {
            N -= 1;
        }
    }
    string ans;
    ll n = p.size();
    REP(i, n)
    {
        ans.push_back('a' + p[n - 1 - i] - 1);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <iostream>

int main(int argc, char const* argv[])
{
    int n, a;
    std::cin >> n >> a;

    if(n >= 500)
    {
        n %= 500;
    }

    if(n - a <= 0)
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {

        std::cout << "No" << std::endl;
    }

    return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    ll n;
    cin >> n;
    ll a, b;
    ll sum1 = 0;
    ll sum2 = 0;
    for(int i=0;i<n;i++)
    {
        cin >> a >> b;
        sum1 += b;
        sum2 += a * b;
    }
    ll ans;
    ans = sum1 - 1 + (sum2 - 1) / 9;
    cout << ans  << endl;
}

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

#define endl '\n'

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

    int n, p=2019;
    string s; cin >> s;
    n = s.size();
    long long ans = 0;
    map<int, int> freq;
    freq[0] = 1;
    int ac = 0, pot = 1;
    for (int i=n-1; i>=0; i--){
        ac = ((s[i] - '0')*pot + ac)%p;
        ans += freq[ac]++;
        pot = (pot*10)%p;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,m,i,j,k,l,p;
    string s;
    cin>>s;
    i=0;j=0;
    while(s[i]!='\0')
    {
        k=s[i]-'0';
        j+=k;
        i++;
    }
    if(j%9==0)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}


Measured memory_bytes: 3728
n=int(input())
s=input()
res=0
for i in range(1,n):
    a=s[:i]
    b=s[i:]
    sum=0
    for j in range(97,123):
        x=chr(j)
        if x in a and x in b:
            sum+=1
    res=max(sum,res)
print(res)


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

const ll mod = 1e9+7;

//xをn乗してmodで割ったあまりを返す
ll mod_pow(ll x, ll n, ll mod){
    if(n == 0)return 1;
    ll res = mod_pow(x*x%mod,n/2,mod);
    if(n&1) res = res * x % mod;
    return res;
}

int main(){
  int n;
  cin >> n;
  map<int,int> mp;
  rep(i,n) {
    int a;
    cin >> a;
    mp[a]++;
  }
  bool ok = true;
  for (auto m : mp) {
    
    if (n%2 == 0) {
      if (m.first % 2 == 0) ok = false;
      if (m.second != 2) ok = false;
    } else {
      if (m.first == 0 && m.second != 1) ok = false;
      else if (m.first != 0 && m.second != 2) ok = false;

      if (m.first % 2 != 0) ok = false;
    }
    
  }
  if (!ok) cout << 0 << endl;
  else {
    ll res = mod_pow(2LL,ll(n/2), mod);    
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 3200
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<functional>
using namespace std;
const long long int mod = 1000000007;
const long long int big = 1152921504606846976;



int main(void) {
	//食べたいカード二枚があったとき、二枚を食べれる。
	int N, i, ans=0,a,et=0;
	static int A[100010];
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &a);
		if (A[a] == 0) { ans++; A[a]++; }
		else {et++;}

	}
	if (et % 2 == 1) { ans--;}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
//#define i_7 (long long)(1e9+7)
#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
using namespace std;
//using namespace boost::multiprecision;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}



int main(){
  
  long long n,m,v,p;
  cin>>n>>m>>v>>p;
  vector<long long> a(n);
  REP(i,n){
    cin>>a[i];
  }
  sort(ALL(a));
  long long s[n];
  REP(i,n){
    if(i == 0){
      s[i] = a[i];
    }else{
      s[i] = s[i-1] + a[i];
    }
  }
  long long ans = 0;
  REP(i,n){
    auto iter_upper = upper_bound(ALL(a), a[i]+m);
    long long idx_upper = distance(a.begin(), iter_upper);
    long long cnt = n - idx_upper;//a[i] + mより大きい要素数。
    //cout<<cnt<<endl;
    if(cnt >= p){
      continue;
    }
    long long j = idx_upper - 1;
    long long temp;
    if(j-i >= p-1-cnt){
      temp = m * (i + p - 1) + (a[i] + m) * (j + cnt - p - i + 1) - (s[j+cnt+1-p] - s[i]);
    }else{
      temp = m * (j + cnt);
    }
    if(temp >= m*(v-1)){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1920