akhauriyash/Code-Regression huggingface dataset:
String=input()
String=list(String)
String=[(String[i:i+2]) for i in range(0, len(String),2)]
String[0]="".join(String[0])
String[1]="".join(String[1])
String[0]=int(String[0])
String[1]=int(String[1])
if(String[0]>0 and String[0]<=12and String[1]>0 and String[1]<=12):
    print("AMBIGUOUS")
elif(String[0]==String[1]==0 or String[0]>12 and String[0]!=0 and String[1]>12 and String[1]!=0):
    print("NA")
elif(String[1]>0 and String[1]<13):
    print("YYMM")
elif(String[0]>0 and String[0]<13):
    print("MMYY")
elif(String[0]==0 and String[1]>12):
    print("NA")
else:
    print("NA")

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }



int main() {
	IOS;
	int n;
	cin >> n;
	vector<int> p(n);
	REP(i, n) {
		cin >> p[i];
		p[i]--;
	}
	vector<int> a(n), b(n);
	const int t = 2e4;
	REP(i, n) {
		a[i] = t * (i + 1);
		b[i] = t * (n - i);
	}
	REP(i, n) {
		a[p[i]] += i;
	}
	putn(a,b);
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  vector<bool> v(26, true);
  for(int i=0; i<s.size(); i++) v[s[i]-'a'] = false;
  
  char ans;
  for(int i=0; i<26; i++) {
    if(v[i]) {
      ans = i+'a';
      cout << ans << endl;
      break;
    }
    else if(i==25) cout << "None" << endl;
  }
  return 0;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int a,b,k;
    cin>>a>>b>>k;
    if (a-k==0) {
        a=0;
    } else if (a-k<0) {
        k-=a;
        a=0;
        if (b-k>=0&&b!=0) {
            b-=k;
        } else {
            b=0;
        }
    } else {
        a-=k;
    }
    cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
import java.io.*;


public class Main {
    public static void main(String[] args) throws IOException {
        Reader reader=new Reader();
        PrintWriter pw=new PrintWriter(System.out);
        long a=reader.nextLong();
        long b=reader.nextLong();
        long n=reader.nextLong();
        //long[] ary=new long[(int) (n+1)];
        long max=0;
        if (n<b)
            max=((a*n)/b)-a*(n/b);
        else {
            n=b-1;
            max = ((a * n) / b) - a * (n / b);
        }

        System.out.println(max);


        pw.close();
    }
}

 class Reader {
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader() {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException {
        byte[] buf = new byte[64];
        int cnt = 0, c;
        while ((c = read()) != -1) {
            if (c == '\n') break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException {
        int ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = (c == '-');
        if (neg) c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');
        if (neg) return -ret;
        return ret;
    }

    public long nextLong() throws IOException {
        long ret = 0;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = (c == '-');
        if (neg) c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');
        if (neg) return -ret;
        return ret;
    }

    public double nextDouble() throws IOException {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ') c = read();
        boolean neg = (c == '-');
        if (neg) c = read();
        do {
            ret = ret * 10 + c - '0';
        } while ((c = read()) >= '0' && c <= '9');
        if (c == '.') while ((c = read()) >= '0' && c <= '9') ret += (c - '0') / (div *= 10);
        if (neg) return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1) buffer[0] = -1;
    }

    private byte read() throws IOException {
        if (bufferPointer == bytesRead) fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException {
        if (din == null) return;
        din.close();
    }
}



Measured memory_bytes: 32632
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
void chmin(LL& a, LL b) {
	a = min(a, b);
}
//////////////

void solve() {
	int N, W;
	cin >> N >> W;
	vector<vector<LL>>dp(N + 1, vector<LL>(401, -LINF));
	vector<LL> w(N), V(N);
	dp[0][0] = 0;
	for (int i = 0; i < N; ++i) {
		cin >> w[i] >> V[i];
	}
	for (int i = 0; i < N; ++i) {
		for (int j = N-1; j >=0; --j) {
			for (int k = 0; k <= 400; ++k) {
				if (dp[j][k] < 0) continue;
				chmax(dp[j + 1][k + w[i] - w[0]], dp[j][k] + V[i]);
			}
		}
	}
	
	LL ans = 0;
	for (int j = 0; j <= N; ++j) {
		for (int k = 0; k <= 400; ++k) {
			if (dp[j][k] < 0) continue;
			LL WW = w[0] * j + k;
			if (WW <= W) {
				chmax(ans, dp[j][k]);
			}
		}
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S; cin >> S;
    int a = 0, b = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '0') a++;
        else b++;
    }
    cout << min(a, b) * 2 << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }    
    vector<int> y = x;
    sort(x.begin(),x.end());
    int big = x[n/2];
    int sma = x[n/2-1];
    for(int i = 0; i < n; i++){
        if(y[i] <= x[n/2-1]) cout << big << endl;
        else cout << sma << endl;
    }
}

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

int main() {
  int N;
  scanf("%d", &N);
  string S;
  cin >> S;

  int ans = 0;
  for (int i = 0; i < N - 1; i++) {
    if (S.at(i) == S.at(i + 1)) {
      continue;
    } else {
      ans++;
    }
  }

  printf("%d", ans + 1);
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
const int N=2007;
int n,m,d[N][N],up[N],ss[N],ls[N],rs[N],ans;
char s[N][N];
int main(){
	scanf("%d%d",&n,&m);
	ans=std::max(n,m);
	for(int i=1;i<=n;++i)scanf("%s",s[i]+1);
	for(int i=2;i<=n;++i){
		for(int j=2;j<=m;++j)(s[i][j]^s[i][j-1]^s[i-1][j]^s[i-1][j-1])?(up[j]=0):(++up[j]);
		int sp=0;
		for(int j=2;j<=m;ss[++sp]=j++)while(sp&&up[ss[sp]]>up[j])rs[ss[sp--]]=j-1;
		while(sp)rs[ss[sp--]]=m;
		for(int j=m;j>=2;ss[++sp]=j--)while(sp&&up[ss[sp]]>up[j])ls[ss[sp--]]=j+1;
		while(sp)ls[ss[sp--]]=2;
		for(int j=2;j<=m;++j){
			int v=(rs[j]-ls[j]+2)*(up[j]+1);
			if(v>ans)ans=v;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4352
N=int(input())
A = list(map(int,input().split()))
prev = A[0]
count=1
direction = 0
for i in range(1,N):
    if A[i] > prev:
        if direction==0:
            direction=1
        elif direction==-1:
            count+=1
            direction=0
    elif A[i] < prev:
        if direction==0:
            direction=-1
        elif direction==1:
            count+=1
            direction=0
    prev=A[i]
    
print(count)

Measured memory_bytes: 14252
//Fast IO + Debug Template
#include <bits/stdc++.h>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define pb push_back
#define gl(x) getline(cin,x)
#define gc(x) cin.get(x)
#define sz(x) (int)(x.size())
#define al(x) (x).begin(),(x).end()
#define ms(a, b) memset(a,b,sizeof(a))
#define sp ' '
#define nl '\n'
#define f first
#define s second
#define lsb(x) ((x)&(-x))
#define mp make_pair
#define m(x, y) (x + y) / 2
#define MOD 1000000007
#define gcd(x,y) __gcd(m,n);
#define perm(x) next_permutation(x.begin(), x.end());
#define bs(x,z) binary_search(x.begin(),x.end(),z);
#define lb(x,z) lower_bound(x.begin(),x.end(),z);
#define ub(x,z) upper_bound(x.begin(),x.end(),z);
#define nl '\n'


void sc(){}template<class T,class...A>void sc(T&t,A&...a){cin>>t,sc(a...);}
void pr(){}template<class T,class...A>void pr(T t,A...a){cout<<t,pr(a...);}
typedef long long ll;
typedef pair<int, int> pi;
//weighted (with adjList[])
typedef vector<pi> vii;
//unweighted (with adjList[])
typedef vector<int> vi;
typedef double db;
typedef long double ld;


const int INF = 0x3f3f3f3f;
const int NINF = -INF;
int TC, a, b, c;
int total;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
	sc(a); 
	sc(b);
	vi use;
	for(int i = 0; i < a; i ++){
		sc(c);
		use.pb(c);
	}
	sort(use.begin(), use.end());
	for (int i = 0; i < b; i ++){
		total += use[i];
	}
	pr(total);
return 0;
	}


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

int main() {
	// your code goes here
	int n,a,b,c,d;
	cin >>n;
	a=n/1000;
	b=(n%1000)/100;
	c=(n%100)/10;
	d=n%10;
	
	if(a+b+c+d==7){
		cout << a << "+" << b << "+" << c << "+" << d << "=" << 7 << endl; 
	}
	
	else if(a+b+c-d==7){
		cout << a << "+" << b << "+" << c << "-" << d << "=" << 7 << endl; 
	}
	else if(a+b-c+d==7){
		cout << a << "+" << b << "-" << c << "+" << d << "=" << 7 << endl; 
	}
	else if(a+b-c-d==7){
		cout << a << "+" << b << "-" << c << "-" << d << "=" << 7 << endl; 
	}
	else if(a-b+c+d==7){
		cout << a << "-" << b << "+" << c << "+" << d << "=" << 7 << endl; 
	}
	else if(a-b+c-d==7){
		cout << a << "-" << b << "+" << c << "-" << d << "=" << 7 << endl; 
	}
	else if(a-b-c+d==7){
		cout << a << "-" << b << "-" << c << "+" << d << "=" << 7 << endl; 
	}
	else if(a-b-c-d==7){
		cout << a << "-" << b << "-" << c << "-" << d << "=" << 7 << endl; 
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define F first
#define S second
#define db double
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
using namespace std;

set<char> st={'a','e','i','o','u'};

 ll mod=1e10 +7;


const int M=200006;
int f[M],inv[M];
int expo(int base,int exponent,int mod){
    int ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2,mod);
    for(int i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
int C(int n,int r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}




int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    compute();
    
    ll tests=1;
   // cin>>tests;
    while(tests--)
    {
      ll n,i;
      cin>>n;
      vector<ll>a(n);
      map<ll,set<ll>> mpp;
      for(i=0;i<n;i++) {cin>>a[i];mpp[a[i]].insert(i);}
      map<ll,ll>ans;
      for(auto &x:mpp)
      {
          set<ll>tmp=x.second;
          ll siz=tmp.size();
          ans[x.first]=(siz*(siz-1))/2;
      }
      ll val=0;
      for(auto &x:ans) val+=x.second;
      for(i=0;i<n;i++)
      {
          ll print=val;
          val-=ans[a[i]];
          ll siz=mpp[a[i]].size();
          siz--;
          val+=(siz*(siz-1))/2;
          cout<<val<<"\n";
          val=print;
      }



    }
    
    return 0;
}


Measured memory_bytes: 33920
#include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 3e3 + 9, M = 1e7 + 9, OO = 1e9 + 7, MOD = 1e9 + 7, MOD2 = 998244353;
const ll INF = 2e18;

vector<int> adj[N];
ll freq[N];
int n, x, y;

void bfs(int node) {
	vector<bool> vis(n + 1);
	vector<int> dist(n + 1);
	vis[node] = 1;
	queue<int> q;
	q.push(node);
	while(!q.empty()) {
		int tp = q.front();
		q.pop();
		for(auto it: adj[tp]) {
			if(vis[it]) continue;
			vis[it] = 1;
			dist[it] = dist[tp] + 1;
			++freq[dist[it]];
			q.push(it);
		}
	}
}

int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rt", stdin);
#endif
	cin >> n >> x >> y;
	adj[x].push_back(y);
	adj[y].push_back(x);
	for (int i = 1; i < n; ++i) {
		adj[i].push_back(i + 1);
		adj[i + 1].push_back(i);
	}
	for (int i = 1; i <= n; ++i)
		bfs(i);
	for (int i = 1; i < n; ++i)
		cout << freq[i] / 2 << '\n';
	return 0;
}


Measured memory_bytes: 384
from collections import defaultdict
N, K = map(int, input().split())
dic = defaultdict(int)
for i in range(N):
    a, b = map(int, input().split())
    dic[a] += b
count = 0
for k, v in sorted(dic.items()):
    count += v
    if count >= K:
        print(k)
        break


Measured memory_bytes: 51800
#include "stdio.h"
 
int main()
{
	char str[128]={0};
	int length,ans=0;
	scanf("%s", str);
	for (int i = 0; i < 110; i++) {
		if (str[i] == 0) {
		    length = i;
		    break;
		}
		    
	}
 
	for (int i = 0; i < length / 2; i++) {
		if (str[i] != str[length - i-1])ans++;
	}
	printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;

int main()
{
   int x,y;
   cin>>x>>y;
   int a=max(x,y);
   int c=min(x,y);
   for(int i=0;i<a;i++)
   {
       cout<<c;
   }

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    int N,M,sum=0;
    cin>>N>>M;
    vi A(M);
    rep(i,M){
        cin>>A[i];
        sum+=A[i];
    }
    sum=N-sum;
    if(sum<0)cout<<-1<<endl;
    else cout<<sum<<endl;

    return 0;
}

//a=97,z=122

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

int main(){
  long long N,K; cin >> N >> K;
  long long result=0;
  
  for(long long i=K; i<=N+1; i++){
    result+=(N*i-i*(i-1)+1);
    result%=(1000000007);
  }
  cout << result << endl;
}

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

int main() {
  int k,a,b;
  cin >> k >> a >> b;
  bool ans = false;
  
  for(int i=a; i<b+1;i++){
    if(i % k == 0)
      ans = true;
  }
  if(ans)
    cout << "OK" << endl;
  else
    cout << "NG" << endl;
}


Measured memory_bytes: 3596
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int N, A, B;

int main(int argc, char const *argv[])
{
    cin>>N>>A>>B;
    int ans=0;
    for(int i=1;i<=N;i++){
        int sum=0;
        int temp=i;
        for(int j=4;j>=0;j--){
            sum+=temp/pow(10,j);
            temp=temp%(int)pow(10,j);
        }
        if(A<=sum&&sum<=B) ans+=i;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
h,w = map(int,input().split())
s = [input() for _ in range(h)]
ans = 0
dir = ((1,0),(0,1),(-1,0),(0,-1))

def bfs(x,y):
  dis_map = [[None if s[i][j] == '.' else -1 for j in range(w)] for i in range(h)]
  q = deque()
  dis_map[y][x] = 0
  q.append((x,y))
  while q:
    i,j = q.popleft()
    for dx,dy in dir:
      ni = i+dx
      nj = j+dy
      if 0 <= ni <= w-1 and 0 <= nj <= h-1:
        if dis_map[nj][ni] == None:
          dis_map[nj][ni] = dis_map[j][i] + 1
          q.append((ni,nj))
  ans =  max(max(dis) for dis in dis_map)
  return ans
  


for i in range (h):
  for j in range (w): #スタートの選択
    if s[i][j]=='#':continue
    dis = bfs(j,i)
    if ans < dis:
      ans = dis
print(ans)

Measured memory_bytes: 3444
import java.io.*;
import java.util.*;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        char[] S = in.s(N);

        int[] black = new int[N + 1];
        for (int i = 0; i < N; i++) {
            black[i + 1] = black[i] + (S[i] == '#' ? 1 : 0);
        }

        int[] white = new int[N + 1];
        for (int i = N - 1; i >= 0; i--) {
            white[i] = white[i + 1] + (S[i] == '.' ? 1 : 0);
        }
        
        int ans = Integer.MAX_VALUE;
        for (int i = 0; i <= N; i++) {
            ans = Math.min(ans, black[i] + white[i]);
        }
        System.out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; (c = next()) != ' ' && c != '\n'; i++) cbuf[i] = c;
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


Measured memory_bytes: 37388
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int a, b, c;
    cin >> a >> b >> c;

    cout << min(c, b / a) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int s,t;//２人それぞれの合計店
    int ja,sa,ra,ea;
    int jb,sb,rb,eb;
    
    scanf("%d %d %d %d",&ja,&sa,&ra,&ea);
    scanf("%d %d %d %d",&jb,&sb,&rb,&eb);
    
    s=ja+sa+ra+ea;
    t=jb+sb+rb+eb;
    
    if(s>t){
        printf("%d\n",s);
    }else{
        printf("%d\n",t);
    }
    
    return 0;
}

Measured memory_bytes: 592
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const double pi = 3.1415926535897932;
const double eps = 0.000000000001;
const int inf = 1145141919;
struct edge { int to, cost; };
typedef pair<int, int>P;


signed main() {
	int n, k; cin >> n >> k;
	
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int b = 1000000*k - i;
		if (2 * b%k == 0) {
			int m = i%k;
			if (m == 0)m = k;
			int x = (n - m) / k + 1;
			ans +=x*x;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;cin>>n>>k;
	vector<int> h(n,0);
	vector<int> dp(n+1,0);
	for(int i=0;i<n;i++)	cin>>h[i];
	dp[1]=abs(h[1]-h[0]);
	//~ dp[2]=min(dp[1]+abs(h[2]-h[1]),abs(h[2]-h[0]));
	
	if(n==2)	{cout<<abs(h[1]-h[0])<<endl;return 0;}
	
	for(int i=2;i<n;i++)
	{
		int mini=INT_MAX;
		for(int j=1;j<=k;j++)
		{
			if(i-j>=0)	mini=min(dp[i-j]+abs(h[i]-h[i-j]),mini);
		}
		dp[i]=mini;
	}
	

	cout<<dp[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

long long eucledean(long long a, long long b){
    long long r;
    if(a<b) std::swap(a,b);
    if(b<1) return b;
    while((r=a%b)!=0){
        a = b; b = r;
    }
    return b;
}

int main(){
    ll a,b,c,d,e;
    std::cin >> a >> b >> c >> d;
    e = c*d/eucledean(c,d);

    ll ans = 0;
    ans += b - b/c - b/d + b/e;
    ans -= (a-1) - (a-1)/c - (a-1)/d + (a-1)/e;

    std::cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3600
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
 

fn main() {
    input!{
        a: usize,
        b: usize,
        h: usize,
    }
    println!("{}",(a + b) * h / 2);
}


Measured memory_bytes: 4352
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax=1e5;
const int C[9] = {2,5,5,4,5,6,3,7,6};
int N, M, A[9];
int dp[Nmax][9], b[9];

int main(){
	cin >> N >> M;
	for(int i=0; i<M; i++){
		cin >> A[i];
		A[i]--;
		b[A[i]] = 1;
	}

	for(int i=1; i<N+1; i++){
		for(int j=0; j<9; j++) dp[i][j] = -1;
		for(int j=0; j<9; j++){
			if(!b[j]) continue;
			for(int k=0; k<9; k++){
				if(i-C[j]>=0 && dp[i-C[j]][k]>=0) dp[i][j] = max(dp[i-C[j]][k]+1, dp[i][j]);
			}
		}
	}

	/*
	for(int i=0; i<N+1; i++){
		for(int j=0; j<9; j++){
			cout << dp[i][j] << (j==8?'\n':'\t');
		}
	}
	*/

	int len=0;
	for(int j=0; j<9; j++) len=max(dp[N][j], len);
	//cout << len << endl;

	int i=N;
	while(i>0){
		for(int j=8; j>=0; j--){
			if(dp[i][j]==len){
				len--;
				//cout << j+1 << ' ' << i << endl;
				cout << j+1;
				i -= C[j];
				break;
			}
		}
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> va, vb;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        va.push_back(a);
        vb.push_back(b);
    }
    sort(va.begin(), va.end());
    sort(vb.begin(), vb.end());
    if (n % 2 == 1) {
        cout << vb[n / 2] - va[n / 2] + 1 << endl;
    } else {
        cout << (vb[n / 2] + vb[n / 2 - 1]) - (va[n / 2] + va[n / 2 - 1]) + 1 << endl;
    }
}


Measured memory_bytes: 5096
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    long double a,b; int h,m; cin>>a>>b>>h>>m;
    
    long double ans = 0;
    
    if( cos(abs(30*h-5.5*m)*M_PI/180) < M_PI ){
        ans = sqrt(a*a+b*b -2*a*b*cos(abs(30*h-5.5*m)*M_PI/180));
    }else{
        cout << cos(360-abs(30*h-5.5*m)) << ln;
        ans = sqrt(a*a+b*b -2*a*b*cos(360-abs(30*h-5.5*m)*M_PI/180));
    }
    
    cout << setprecision(20) << ans << ln;
    return 0;
}

Measured memory_bytes: 4188
#include <bits/stdc++.h>
 
#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif
 
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	long long a, b, c, d;
	cin>>a>>b>>c>>d;
	cout.precision(9);
	cout<<fixed<<a*b/2.<<' '<<(a%2==0 && b%2==0 && a/2==c && b/2==d)<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    string n;
    cin >> n;
    int ans = 0;
    for (int i=0; i<n.size(); i++) {
        ans += n[i] - '0';
        ans %= 9;
    }

    cout << (ans?"No":"Yes") << endl;
}


Measured memory_bytes: 3372
import java.util.Scanner;

public class Main {

	/**
	 * problem solver
	 */
	public static class Problem {

		/**
		 * paramters
		 */
		private long r;
		private long d;
		private long x2000;

		/**
		 * constructor
		 */
		Problem() {
			r = 0;
			d = 0;
			x2000 = 0;
		}

		/**
		 * standard input
		 */
		void input() {
			Scanner sc = new Scanner(System.in);
			r = sc.nextInt();
			d = sc.nextInt();
			x2000 = sc.nextInt();
			sc.close();
		}

		/**
		 * solver
		 */
		void solve() {
			long x = x2000;
			
			for (int i=2001; i<=2010; i++) {
				x = r * x - d;
				System.out.println(x);
			}
		}

	}

	public static void main(String args[]) {

		Problem p = new Problem();

		p.input();

		p.solve();
	}
}


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

using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

int main (){
    int W,H,N;
    cin >> W >> H >> N;
    int p[150], q[150], a[150];
    REP(i, N){
        cin >> p[i] >> q[i] >> a[i]; 
    }
    int mix= 0 , miy = 0;
    int max = W, may = H;
    REP(i, N){
        if(a[i] ==1){
            if(p[i] > mix){
                mix = p[i];
            }
        }
        if(a[i] ==2){
            if(p[i] < max){
                max = p[i];
            }
        }
        if(a[i] == 3){
            if(q[i] > miy){
                miy = q[i];
            }
        }
        if(a[i] == 4){
            if(q[i] < may){
                may = q[i];
            }
        }
    }
    
    if(mix >= max || miy >= may){
        cout << 0 << endl;
    }else{
        int sq = (max - mix) * (may - miy);
        cout << sq << endl;
    }


    return 0;
}

//acでず　だめ　解き方はあってる　２通りある

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    a = input()
    b = input()
    c = input()
    i = 0
    j = 0
    k = 0
    t = 'a'
    while 1:
        if t == 'a':
            if i == len(a):
                print('A')
                return
            t = a[i]
            i += 1
        elif t == 'b':
            if j == len(b):
                print('B')
                return
            t = b[j]
            j += 1
        else:
            if k == len(c):
                print('C')
                return
            t = c[k]
            k += 1
        
    
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

7
3 1
4 1
5 9
2 6
5 3
5 8
9 7 5

"""


Measured memory_bytes: 9292
#include<stdio.h>
#include<string.h>

int main()
{
    char s[100005];
    scanf("%s", s);
    int len = strlen(s);
    int ans = 0;
    for(int i = 1; i < len; i++)
    {
        if(s[i] != s[i-1])
            ans++;
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int num = Integer.parseInt(line);
        for(int i = 1; i <= num; i++) {
            if(i % 3 == 0 || i % 10 == 3 || Integer.toString(i).contains("3")) {
                System.out.print(" ");
                System.out.print(i);
            }
        }
        System.out.println("");
    }
}


Measured memory_bytes: 31740
#include <stdio.h>
#include <stdlib.h>
#define MAX 1000000

struct queue{
    char name[10];
    int time;
};

void initialize();
int isFull();
int isEmpty();
void enqueue(struct queue);
struct queue dequeue();

int head;
int tail;

struct queue A[MAX];
struct queue Q[MAX];

int main(){
    int n,q;
    int total = 0;
    int flag = 1;
    struct queue x;

    scanf("%d %d",&n,&q);

    initialize();

    for(int i = 0;i < n;i++){
        scanf("%s %d",A[i].name,&A[i].time);
        enqueue(A[i]);
    }

    while(flag){
        x = dequeue();
        
        if(x.time - q > 0){
            total += q;
            x.time = x.time - q;
            enqueue(x);
        }
        else if(x.time - q == 0){
            total += q;
            printf("%s %d\n",x.name,total);
        }
        else{
            total += x.time;
            printf("%s %d\n",x.name,total);
        }

        flag = isEmpty() - 1;
    }

    return 0;
}

void initialize(){
    head = 0;
    tail = 0;
}

int isEmpty(){
    if(head == tail)return 1;
    return 0;
}

int isFull(){
    if(head == (tail+1) % MAX)return 1;
    return 0;
}

void enqueue(struct queue x){
    if(isFull()){
        fprintf(stderr,"OverFlow");
        exit(1);
    }
    Q[tail] = x;
    if(tail + 1 == MAX)tail = 0; 
    else tail++;
}

struct queue dequeue(){
    struct queue x;
    if(isEmpty()){
        fprintf(stderr,"AnderFlow");
        exit(1);
    }
    x = Q[head];
    if(head + 1 == MAX)head = 0;
    else head++;
    return x;
}



Measured memory_bytes: 5432
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std; 
template<class T> void read(T &x) {
	x = 0; int f = 1, ch = getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=getchar();}
	x *= f; 
}
typedef long long ll;
const int maxn = 1e5 + 5;
int n;
char s[maxn];
int head[maxn];
struct edge {
	int to, nex;
	edge(int to=0,int nex=0):to(to),nex(nex){}
};
vector<edge> G;
inline void addedge(int u, int v) {
	G.push_back(edge(v, head[u])), head[u] = G.size() - 1;
	G.push_back(edge(u, head[v])), head[v] = G.size() - 1;
}
namespace dvt {
	ll an;
	int k;
	int sum;
	int maxlen;
	int cnt[maxn];
	int siz[maxn];
	int son[maxn];
	char ch;
	bool mark[maxn];
	void getpoint(int u, int fa) {
		siz[u] = 1;
		son[u] = 0;
		for(int i = head[u]; ~i; i = G[i].nex) {
			int v = G[i].to; if(v == fa || mark[v]) continue; 
			getpoint(v, u);
			siz[u] += siz[v];
			son[u] = max(son[u], siz[v]);
		}
		son[u] = max(son[u], sum - siz[u]);
		if(k == -1 || son[k] > son[u]) k = u; 
	}
	void rebuild(int u, int fa) {
		siz[u] = 1;
		for(int i = head[u]; ~i; i = G[i].nex) {
			int v = G[i].to; if(v == fa || mark[v]) continue;
			rebuild(v, u);
			siz[u] += siz[v];
		}
	}
	void findan(int u, int fa, int now, int sum) {
		if(s[u] == ch) {
			if(now) --now;
			else ++sum;
		}
		else {
			++now;
		}
		if(now == 0) an += cnt[sum]; 
		for(int i = head[u]; ~i; i = G[i].nex) {
			int v = G[i].to; if(v == fa || mark[v]) continue;
			findan(v, u, now, sum);
		}
	}
	void update(int u, int fa, int now, int sum) {
		if(s[u] != ch) {
			if(now) --now;
			else ++sum;
		}
		else {
			++now;
		}
		if(now == 0) {
			++cnt[sum];
			if(sum > maxlen) maxlen = sum;
		}
		for(int i = head[u]; ~i; i = G[i].nex) {
			int v = G[i].to; if(v == fa || mark[v]) continue;
			update(v, u, now, sum);
		}
	}
	void divide(int u) {
		mark[u] = 1, rebuild(u, -1);
		maxlen = 0;
		if(s[u] != ch) {
			cnt[1] = maxlen = 1; 
		} 
		for(int i = head[u]; ~i; i = G[i].nex) {
			int v = G[i].to; if(mark[v]) continue; 
			findan(v, u, 0, 0); 
			if(s[u] != ch) update(v, u, 0, 1);
			else update(v, u, 1, 0);
		}
		for(int i = 0; i <= maxlen; ++i) cnt[i] = 0;
		for(int i = head[u]; ~i; i = G[i].nex) {
			int v = G[i].to; if(mark[v]) continue;
			k = -1, sum = siz[v], getpoint(v, u);
			divide(k);
//			debug("%d %d\n", u, k);
		}
	}
	ll solve() {
		ch = '(';
		k = -1, sum = n, getpoint(1, -1);
		divide(k);
		memset(mark, 0, sizeof(mark));
		ch = ')';
		k = -1, sum = n, getpoint(1, -1);
		divide(k);
		return an;
	}
}
int main() {
	read(n);
	scanf("%s", s + 1);
	memset(head, -1, sizeof(head));
	for(int i = 1; i < n; ++i) {
		int u, v; read(u), read(v);
		addedge(u, v);
	} 
	printf("%lld\n", dvt :: solve());
	return 0; 
}


Measured memory_bytes: 10524
#include<cstdio>
#include<algorithm>
using namespace std;
#define MOD 1000000007
#define MAXN 200005
#define LL long long
LL inv[MAXN],s[MAXN];
int N;
int n,m,x,y;
LL Pow(LL a,int b)
{
    LL ans=1;
    while(b)
	{
        if(b&1) ans=ans*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return ans;
}
void Pre()
{
    s[0]=1;
    for(int i=1; i<=N; i++)
        s[i]=s[i-1]*i%MOD;
    inv[0]=1;
    inv[N]=Pow(s[N],MOD-2);
    for(int i=N-1; i>0; i--)
        inv[i]=inv[i+1]*(i+1)%MOD;
}
LL C(int a,int b)
{
    if(a<0||b<0) return 1;
    return s[a]*inv[b]%MOD*inv[a-b]%MOD;
}
int main()
{
 
    scanf("%d%d",&n,&m);
    scanf("%d%d",&x,&y);
    N=n+m-2;
    Pre();
    LL ans=0;
    for(int i=y+1;i<=m;i++)
    {
        ans+=C(n-x+i-2,i-1)*C(x+m-i-1,x-1)%MOD;
        ans%=MOD;
    }
    printf("%lld\n",ans);
}

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

using namespace std;

const ll mod=1e9+7;


int main(){
    ll n;
    cin >> n;
    multiset<ll> a;
    ll ans=0;
    rep(i,n){
        ll x;
        cin >> x;
        auto it=a.lower_bound(x);
        if(it==a.begin()){
            a.insert(x);
        }
        else{
            it--;
            ll v=*it;
            a.erase(a.find(v));
            a.insert(x);
        }
    }
    cout << a.size() << endl;
    return 0;
}

Measured memory_bytes: 8244
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,i,cnt=0,ans=0;
  cin>>n;
  vector<int> h(n);
  for(i=0;i<n;i++){
    cin>>h.at(i);
    if(i>0){
      if(h.at(i)<=h.at(i-1)){
        cnt++;
        if(ans<cnt) ans=cnt;
      }
      else cnt=0;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int main(void){
	char ans=0, a, b;
	while(scanf("%c,%c%*c",&a,&b)==2){	/* ツ嘉シツ行ツ閉カツ篠堋づーツ偲個づづゥツづつォツづ債つアツつ、ツつキツづゥツづァツつオツつ「 */
		if(a-'A'==ans) ans=b-'A';
		else if(b-'A'==ans) ans=a-'A';
	}
	printf("%c\n",ans+'A');
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<(n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c;cin>>a>>b>>c;
  ll cnt=0;
  for(ll i=min(a,b);i>=1;i--){
    if(a%i==0&&b%i==0)cnt++;
    if(cnt==c){cout<<i<<endl;return 0;}
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,i,a[4],b,c;
    for(i=1;i<=3;i++)
    {
        cin>>a[i];

    }
    sort(a+1,a+4);
    if(a[1]+a[2]==a[3])
        printf("Yes\n");
    else printf("No\n");
    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<bitset>
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<ctime>
#include<complex>
#include<functional>
#include<climits>
#include<cassert>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
using namespace std;

#define MAX 102

int n;
int k2;

int way[102][10002];
int sum[102][10002];
#define MOD 1000000007
int main() {
	cin >> n >> k2;
	way[0][0] = 1;
	int ds = n + 1;
	for (int i = 0; i < n; i++) {
		ds--;
		for (int j = 0; j < 10002; j++) {
			if (way[i][j] == 0)continue;
			for (int k = 0; k <= k2; k++) {
				if (k > ds) {
					way[i + 1][j] += way[i][j];
					long long int nex = k+j;
					nex *= way[i][j];
					nex += sum[i][j];
					nex %= MOD;
					sum[i + 1][j] += nex;
					way[i + 1][j] %= MOD;
					sum[i + 1][j] %= MOD;
				}
				else{
					int sum2 = k + j;
					int N = j + sum2 / ds;
					long long int nex = sum2%ds;
					nex *= way[i][j];
					nex += sum[i][j];
					nex %= MOD;
					way[i + 1][N] += way[i][j];
					way[i + 1][N] %= MOD;
					sum[i + 1][N] += nex;
					sum[i + 1][N] %= MOD;
				}
			}
		}
	}
	long long int ans = 0;
	for (int j = 0; j < 10002; j++) {
		ans += sum[n][j];
		ans %= MOD;
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
    int a[5];
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
    }

    int min = 100;
    int all = 0;
    for (int i = 0; i < 5; i++) {
        int b = a[i] % 10;
        int c = a[i] / 10;
        if (b == 0) {
            all += c;
        } else {
            all += c + 1;
            if (b < min) {
                min = b;
            }
        }
    }
    int result = 0;
    if (min == 100) {
        result = all * 10;
    } else {
        result = (all - 1) * 10 + min;
    }
    cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader tec = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		for (String line; (line = tec.readLine()) != null;) {
			StringTokenizer st = new StringTokenizer(line);
			long a=Long.parseLong(st.nextToken());
			long b=Long.parseLong(st.nextToken());
			long cont=0;
			if(a==b){
				out.println(0);
				continue;
			}
			if(a<b){
				if(a<0&&b>0){
					cont++;
				}
			}else{	
				
				if(b>0&&a>0){
					cont+=2;
				}
				if(b<=0&&a>=0){
					cont++;
				}
				if(b<0&&a<0){
					cont+=2;
				}
			}
			cont+=Math.abs(Math.abs(a)-Math.abs(b));
			out.println(cont);
		}
		out.close();
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;


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


  int n;
  int max = 0;
  int count = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int h;
    cin >> h;
    if (h >= max) {
      count++;
      max = h;
    }
  }

  pr(count);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>
#include <regex>
#include <functional>
#include <algorithm>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int MAX_N = 100000;

typedef long long ll;

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

    string S;
    cin >> S;
    string T;
    cin >> T;
    string T_ = T.substr(0, S.length());
    if (S.length() + 1 == T.length() && S == T_) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
    string s;
    cin>>s;
    bool check = true;
    bool check2 = true;
    for(int i=0;i<s.size();++i)
    {
        if(i%2==0)
        {
            if(s[i]!='R' && s[i]!='U' && s[i]!='D')
            {
                check = false;
                break;
            }
        }
        else
        {
            if(s[i]!='L' && s[i]!='U' && s[i]!='D')
            {
                check2 = false;
                break;
            }
        }
    }
    if(check && check2)
    {
        cout<<"Yes";
    }
    else cout<<"No";
}


Measured memory_bytes: 256