akhauriyash/Code-Regression huggingface dataset:
s = input()
K = int(input())
n = len(s)

dp = [[[0 for _ in range(2)] for _ in range(4)] for _ in range(n+5)]


dp[0][0][0] = 1

for i in range(n):
    for j in range(4):
        for k in range(2):
            nd = int(s[i])  # 今見ている桁の数値
            for d in range(10):
                ni = i+1
                nj = j
                nk = k
                if d != 0:  # 0以外が一個増える
                    nj += 1
                if nj > K:  # これ以上0以外使えないとき
                    continue
                if k == 0:  # そこまでの桁はNと一致しているとき
                    if d > nd:  # Nを超えてしまう
                        continue
                    if d < nd:  # N以下確定である
                        nk = 1
                dp[ni][nj][nk] += dp[i][j][k]

ans = dp[n][K][0] + dp[n][K][1]

print(ans)


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

#define maxn 100010
    ll c[3010][3010];
    char d[3010][3010];
ll lcs_l(string a, string b)
{
    ll l1=a.length() , l2=b.length();


    for(int i=0;i<l1+1;i++)
        c[i][0]=0;
    for(int i=0;i<l2+1;i++)
        c[0][i]=0;
    for(int i=1;i<l1+1; i++)
    {
        for(int j=1;j<l2+1;j++)
        {
            if(a[i-1]==b[j-1])
            {
                c[i][j]=c[i-1][j-1]+1;
                d[i][j]='q';

            }
            else
            {
                if(c[i][j-1]>=c[i-1][j])
                {
                    c[i][j]=c[i][j-1];
                    d[i][j]='a';
                }
                else
                {
                    c[i][j]=c[i-1][j];
                    d[i][j]='w';

                }

            }
        }
    }
    return c[l1][l2];
}
void print(string s ,ll  i ,ll j)
{
    if(i==0 || j==0)
    return;

    if(d[i][j]=='q')
        {
            print( s, i-1, j-1);
            cout<<s[i-1];
        }
    else if(d[i][j]=='w')
        print( s, i-1,j);
    else print( s, i, j-1);
}
int main()
{
    string s, t;
    cin>>s>>t;
    lcs_l(s,t);
    print( s, s.length(), t.length());
}


Measured memory_bytes: 79872
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

void print(int l[],int r[],int vv[],int n)
{
    for (int i=1;i<=n;i++) printf("%d %d %d\n",l[i],r[i],vv[i]);
}


int main()
{
    int n,t[300],l[300],r[300],v[300],vv[300];
    double ans=0.00000000,t1,t2;
    scanf("%d",&n);
    memset(v,0,sizeof(v));memset(t,0,sizeof(t));
    memset(l,0,sizeof(l));memset(r,0,sizeof(r));
    for (int i=1;i<=n;i++) scanf("%d",&t[i]);
    for (int i=1;i<=n;i++) scanf("%d",&v[i]);
    for (int i=n+1;i>=2;i--)
        if (v[i-1]>v[i])    v[i-1]=min(v[i-1],v[i]+t[i-1]);

    for (int i=0;i<=n-1;i++)
        if (v[i + 1] > v[i])    v[i + 1] = min(v[i + 1], v[i] + t[i + 1]);

    for (int i=1;i<=n;i++)
        {
            l[i]=min(v[i-1],v[i]);
            r[i]=min(v[i],v[i+1]);


        }
    for (int i=1;i<=n;i++)
        {
            if ((l[i]==r[i])&&(l[i]==v[i])) {ans=ans+v[i]*t[i];continue;}

                    t1=v[i]-l[i];t2=v[i]-r[i];
                    if (t1+t2>t[i])
                        {
                            t1=(r[i]+t[i]-l[i])/2.000000;
                            t2=t[i]-t1;
                            ans=ans+(2*l[i]+t1)*t1/2.0000000+(2*r[i]+t2)*t2/2.0000000;

                        }
                    else
                        {
                            t1=v[i]-l[i];t2=v[i]-r[i];
                            ans=ans+(l[i]+v[i])*t1/2.000000+(r[i]+v[i])*t2/2.000000+v[i]*(t[i]-t1-t2);

                        }
                  // printf("%lf %lf %d\n",t1,t2,vv[i]);


        }
    printf("%lf\n",ans);
   // print(l,r,vv,n);
    return 0;
}










Measured memory_bytes: 256
import math
a, b, h, m = map(int, input().split())

dega = - 30*h - 0.5*m + 90
degb = - 6*m + 90

x_a = a*math.cos(math.radians(dega))
y_a = a*math.sin(math.radians(dega))
x_b = b*math.cos(math.radians(degb))
y_b = b*math.sin(math.radians(degb))
# print(dega, degb)
# print(x_a, x_b, y_a, y_b)
print(((x_a-x_b)**2+(y_a-y_b)**2)**0.5)


Measured memory_bytes: 9396
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int sum = 0;
		for(int i=0; i<2; i++) {
			if(a>b) {
				sum +=a;
				a--;
			}else {
				sum += b;
				b--;
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000
#define rep(i,a,b) for(int (i)=a;(i)<(int)(b);(i)++)

int main(){
    vector<vector<int>> A(3,vector<int>(3,0));
    vector<vector<int>> flag(3,vector<int>(3,0));
    rep(i,0,3){rep(j,0,3) cin >>A[i][j];}
    int N;
    cin >> N;
    vector<int>b(N,0);
    rep(i,0,N) cin >> b[i];

    rep(i,0,N){
        rep(j,0,3){
            rep(k,0,3){
                if(b[i] == A[j][k]) flag[j][k]=1;                
            }
        }
    }
    if(flag[0][0]+flag[0][1]+flag[0][2]==3) cout << "Yes" << endl;
    else if(flag[1][0]+flag[1][1]+flag[1][2]==3) cout << "Yes" << endl;
    else if(flag[2][0]+flag[2][1]+flag[2][2]==3) cout << "Yes" << endl;
    else if(flag[0][0]+flag[1][0]+flag[2][0]==3) cout << "Yes" << endl;
    else if(flag[0][1]+flag[1][1]+flag[2][1]==3) cout << "Yes" << endl;
    else if(flag[0][2]+flag[1][2]+flag[2][2]==3) cout << "Yes" << endl;
    else if(flag[0][0]+flag[1][1]+flag[2][2]==3) cout << "Yes" << endl;
    else if(flag[0][2]+flag[1][1]+flag[2][0]==3) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
int dgts2(int n){return (n?dgts2(n>>1)+1:0);}
int dgts(int n, int k){return (n?dgts(n/k,k)+1:0);}
inline int v2(int n){return __builtin_ctzll(n);}
 
const int maxn=5005;
//i_am_noob
int q,x,a;
string str;
char c;
deque<char> dq;
bool bl=false;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> str;
	rep(sz(str)) dq.pb(str[i]);
	cin >> q;
	while(q--){
		cin >> x;
		if(x==1) bl=1-bl;
		else{
			cin >> a >> c;
			a--;
			if(a^bl) dq.pb(c);
			else dq.push_front(c);
		}
	}
	if(bl){
		while(!dq.empty()){
			cout << dq.back();
			dq.pop_back();
		}
	}
	else{
		while(!dq.empty()){
			cout << dq.front();
			dq.pop_front();
		}
	}
	cout << '\n';
	return 0;
}


Measured memory_bytes: 976
/* 

И пусть меня погубит, то к чему я
Бегу, не жалея ног.
И если мне суждено сгореть на восходе,
Я буду идти вперёд.

*/

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define S second
#define F first
#define all(x) (x).begin(), (x).end()

using namespace std;

const bool dbg_flg = 0;
#define debug(x) if (dbg_flg) cerr << #x << ' ' << x << '\n'
#define debug_pair(x) if (dbg_flg) cerr << #x << ' ' << x.F << ' ' << x.S << '\n' 

const int inf = 1e9 + 7;
const int MAXN = 2e5 + 5;

int n;
int a[MAXN];
int k;
int pref[MAXN];

void solve() {
	cin >> n >> k;

	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		pref[i] = pref[i - 1] + a[i];
	}

	double res = 0.00;
	
	for (int i = 1; i <= n; i++) {
		
		int val = pref[i + k - 1] - pref[i - 1];
		
		res = max(res, double(val + k) / 2.00);			
		
	}

	cout.precision(12);
	cout << fixed;
	cout << res;

}

int main() {
	
	//~ freopen(".in", "r", stdin);
	//~ freopen(".out", "w", stdout);
	
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);

	int tt = 1;
	// cin >> tt;
	while (tt--) {
		solve();
	}

	return 0;
}

Measured memory_bytes: 1792
using System;

class Poker
{
	static public void Main(string[] args)
	{
		int A, B;
		string[] vals = Console.ReadLine().Split(' ');
		A = int.Parse(vals[0]);
		B = int.Parse(vals[1]);

		if(A == 1)
		{
			if(B == 1)
			{
				Console.WriteLine("Draw");
			}
			else
			{
				Console.WriteLine("Alice");
			}
			return;
		}
		if(B == 1)
		{
			Console.WriteLine("Bob");
			return;
		}
		if(A > B)
		{
			Console.WriteLine("Alice");
			return;
		}
		else if(A < B)
		{
			Console.WriteLine("Bob");
			return;
		}
		else
		{
			Console.WriteLine("Draw");
			return;
		}
		

	}
}


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

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

    int total = 0;
    if(n>9) total += 9; 
    else total += n;
    if(n>999) total += 900; 
    else total += max(n-99,0);
    if(n>99999) total += 90000;
    else total += max(n-9999,0);

    cout<<total<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int INF=0x3f3f3f3f;
ll a[100006];
int main()
{
    string s,t;cin>>s>>t;

    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
        {
            cout<<"No"<<endl;return 0;
        }
    }

    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 3624
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String[] S = sc.next().split("");
    String[] T = sc.next().split("");
    int ans = T.length;
    for (int i = 0; i < S.length-T.length+1; i++) {
      int t = T.length;
      for (int j = 0; j < T.length; j++) {
        if (S[i+j].equals(T[j])) t--;
      }
      ans = Math.min(ans, t);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 37100
// In The Name Of The Queen
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 19, Mod = 1e9 + 7;
ll n;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    ll tot = 0;
    ll m = n - 1;
    for (ll i = 1; i * i <= m; i ++)
        if (m % i == 0)
        {
            if (i != 1)
                tot ++;
            if (m / i != i)
                tot ++;
        }
    vector < ll > A;
    for (ll i = 1; i * i <= n; i ++)
        if (n % i == 0)
        {
            A.push_back(i);
            if (n / i != i)
                A.push_back(n / i);
        }
    for (ll a : A)
    {
        if (a == 1)
            continue;
        ll tmp = n, c = 0;
        while (tmp % a == 0)
            tmp /= a, c = 1;
        if (c == 0)
            continue;
        if (tmp % a == 1)
            tot ++;
    }
    printf("%lld\n", tot);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define ll long long
#define ld long double

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)

#define pii pair<int, int>
#define pll pair<ll, ll>

#define fi first
#define se second

#define pb push_back
#define eb emplace_back

#define vi vector<int>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define all(a) a.begin(), a.end()

#define endl '\n'
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
const int MOD=1e9+7;
const ll INF=1e18;
const double PI=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
int ddx[5] = {2,1,0,-1,-2};
int ddy[5] = {2,1,0,-1,-2};
 
const int MAX=510000;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  vector<ll> s(n+1);
  rep(i,n) s[i+1] = s[i] + a[i];
  
  map<ll,ll>mp;
  rep(i,n+1){
    ll x = s[i];
    x %= m;
    mp[x]++;
  }
  ll ans = 0;
  for(auto p:mp){
    ans += p.second*(p.second-1)/2;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 8060
import java.util.Scanner;
class Main{
 
    public void solve(){
        Scanner sc = new Scanner(System.in);
        int max, min;
        for(int i = 0;i < 7;i++){
            max = sc.nextInt();
            min = sc.nextInt();
			int total = max - min;
            System.out.println(total);
        } 
    }
    
    public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template<class T> bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b){if(a<b) {a = b; return true;} return false;}
#define all(x) (x).begin(),(x).end()
#define debug(x)  cerr << #x << " = " << (x) << endl;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,Q;
    cin >> N >> Q;
    ll ans = (N-2)*(N-2);
    set<int> row,col;
    row.insert(N-1),col.insert(N-1);
    vec<int> valrow(N,-1),valcol(N,-1);
    int r = N-1,c = N-1;
    while(Q--){
        int t,x;
        cin >> t >> x;
        x--;
        if(t==1){
            if(valcol[x]!=-1) ans -= valcol[x];
            else{
                ans -= r-1;
                for(int i=x+1;i<c;i++) valcol[i] = r-1;
                c = x;
            }
        }else{
            if(valrow[x]!=-1) ans -= valrow[x];
            else{
                ans -= c-1;
                for(int i=x+1;i<r;i++) valrow[i] = c-1;
                r = x;
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 4780
MOD = 10**9+7
n, m = map(int, input().split())


def factorization(n):
    retval = []
    tmp = n
    for i in range(2, int(-(-n**.5//1))+1):
        if tmp % i == 0:
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            retval.append((i, cnt))
    if tmp != 1:
        retval.append((tmp, 1))
    if not retval:
        retval.append((n, 1))
    return retval


fact = factorization(m)


def com(n, r):
    X = Y = 1
    if n-r < r:
        r = n-r
    for i in range(1, r+1):
        Y = Y*i % MOD
        X = X*(n-i+1) % MOD
    Y = pow(Y, MOD-2, MOD)
    return X*Y


ans = 1
for f in fact:
    ans *= com(n+f[1]-1, n-1)
if m == 1:
    print(1)
else:
    print(ans % MOD)

Measured memory_bytes: 3316
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

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

  vec A(101010);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
  }

  int k = N * (N + 1) / 2;
  if (sum % k != 0) {
    cout << "NO" << endl;
    return 0;
  } else {
    k = sum / k;
  }

  vec d(101010);
  for (int i = 0; i < N; i++) {
    if (i != N - 1) {
      d[i] = A[i + 1] - A[i] - k;
    } else {
      d[N - 1] = A[0] - A[N - 1] - k;
    }

    if (d[i] > 0 || d[i] % N != 0) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define rep(i,a,n) for(int i=(a);i<(n);i++)
using namespace std;

int main() {
	map<string, long long> a;
	set<string> st;
	int n;
	cin >> n;
	rep(i, 0, n) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		if (a.count(s))a[s]++;
		else a[s] = 1;
		st.insert(s);
	}
	long long ans = 0;
	for (auto value : st) {
		long long  x = a.at(value);
		ans += (x * (x - 1)) / 2;
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

struct UndirectionalCompare
{
  bool operator() (const Edge& e, const Edge& f) const {
    if (min(e.src,e.dst) != min(f.src,f.dst))
      return min(e.src,e.dst) < min(f.src,f.dst);
    return max(e.src,e.dst) < max(f.src,f.dst);
  }
};

void visit(const Graph &g, int v, int u, vi& art, vi& num, vi& low, int& time)
{
  low[v] = num[v] = ++time;
  vrep(e, g[v]) {
    int w = e->dst;
    if (num[w] == 0) {
      visit(g, w, v, art, num, low, time);
      low[v] = min(low[v], low[w]);
      if ((num[v] == 1 && num[w] != 2) ||         // for arts
          (num[v] != 1 && low[w] >= num[v])) art.push_back(v);
    } else low[v] = min(low[v], num[w]);
  }
}

void ArticulationPoint(const Graph& g, vi& art)
{
  const int n = g.size();
  vi low(n), num(n);
  rep(u, n) if (num[u] == 0) {
    int time = 0;
    visit(g, u, -1, art, num, low, time);
  }
}

int V, E;
int s, t;

int main()
{
  cin >> V >> E;
  Graph g(V);
  vi art;
  rep(i, E){
    cin >> s >> t;
    g[s].pb(Edge(s, t, 1));
    g[t].pb(Edge(t, s, 1));
  }

  ArticulationPoint(g, art);

  sort(ALL(art));
  art.erase(unique(ALL(art)), art.end());

  vrep(v, art) cout << *v  << endl;

  return 0;
}

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

int main(){
	int A, B, ans=0;
	cin >> A >> B;
	for(int i=A; i<=B; i++){
		int p=i/10000, q=(i%10000)/1000, r=(i%100)/10, s=i%10;
		if(p==s&&q==r) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long int64;
int MOD = 1e9 + 7;

int64 inv(int64 a, int64 mod) {
  a %= mod;
  int64 v[] = { 0, 1, mod };
  int64 u[] = { 1, 0, a };
  while (v[2] != 1) {
    if (v[2] < u[2]) {
      int64 tmp[] = { v[0], v[1], v[2] };
      v[0] = u[0]; v[1] = u[1]; v[2] = u[2];
      u[0] = tmp[0]; u[1] = tmp[1]; u[2] = tmp[2];
      continue;
    }
    int64 coe = v[2] / u[2];
    for (int i = 0; i < 3; ++i) v[i] = v[i] - u[i] * coe;
  }
  return v[0] < 0 ? v[0] + mod : v[0];
}

int64 pow(int64 a, int64 p, int64 mod) {
  a %= mod;
  int64 ret = a;
  while (p > 1) {
    if (p % 2) {
      ret = (ret * ret) % mod;
      ret = (ret * a) % mod;
    } else {
      ret = (ret * ret) % mod;
    }
    p /= 2;
  }
  return ret;
}

int main() {
  //cout << fixed << setprecision(15);
  string S;
  cin >> S;
  cout << S[0] << S.size()-2 << S[S.size()-1] << "\n";
  return 0;
}


Measured memory_bytes: 256
A, B = map(int, open(0).read().split())

grid = [["#"] * 100 for _ in range(50)] + [["."] * 100 for _ in range(50)]

for i in range(A - 1):
    grid[i // 50 * 2][i % 50 * 2] = "."

for i in range(B - 1):
    grid[i // 50 * 2 + 51][i % 50 * 2] = "#"

print(100, 100)
for v in grid:
    print("".join(v))


Measured memory_bytes: 38416
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n,k;cin>>n>>k;
    VL a(n);
    REP(i,n){
        cin>>a[i];
    }

    REP(i,n-k){
        if(a[i]<a[i+k]){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    
	return;
}

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

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	ll x=0,cnt=0;
	for(ll i=0;i<s.length();i++){
		if(s.substr(i,1)=="W"){
			cnt+=i-x;
			x++;
		}
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 720
R=[0]
L=list()
N=int(input())
for i in range(N):
  k=int(input())
  L.append(k)
  if k==0:
    R.append(len(L))
S=sum(L)
R.append(N)
for i in range(len(R)-1):
  if sum(L[R[i]:R[i+1]])%2==1:
    S=S-1
print(S//2)

Measured memory_bytes: 7840
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define rep(N) for(int i=0;i<N;i++)
#define repj(N) for(int j=0;j<N;j++)
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define For(I,N) for(int I=0;I<N;I++)
#define cinone(N) int N;cin>>N;
#define scanfone(N) int N;cin>>N;
#define cinng(N,M) int N[M];for(int yiuytvnm=0;yiuytvnm<M;yiuytvnm++) cin>>N[yiuytvnm];
#define scanfng(N,M) int N[M];for(int qrwuoiq=0;qrwuoiq<M;qrwuoiq++) scanf("%d",&N[qrwuoiq]);
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
typedef unsigned long long ull;
const int inf=1039074182;
const int mod=1e9+7;
using namespace std;
int dp[1<<21];
int n;
int a[21][21];

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>a[i][j];
		}
	}
	dp[0]=1;
	for(int mask=0;mask<(1<<n);mask++)
	{
		int len=__builtin_popcount(mask);
		for(int j=0;j<n;j++)
		{
			if(mask & (1<<j)) continue;
			if(a[len][j]==0) continue;
			dp[mask | (1<<j)]+=dp[mask];
			dp[mask | (1<<j)]%=mod;
		}
	}
	cout<<dp[(1<<n)-1]<<endl;
	return 0;
}

Measured memory_bytes: 8448
n = int(input())
seen = set()
tmp = ""
for _ in range(n):
    x = input()
    if not tmp:
        seen.add(x)
        tmp = x[-1]
        continue
    elif x[0] != tmp or x in seen:
        print("No")
        exit(0)
    else:
        seen.add(x)
        tmp = x[-1]
print("Yes")


Measured memory_bytes: 9180
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;

int cnt = 0;

void merging(vi *a, int s, int m, int t) {
	int n1 = m - s + 1;
	int n2 = t - m + 1;
	vi l(n1), r(n2);
	Loop(i, n1 - 1) l[i] = (*a)[s + i];
	Loop(i, n2 - 1) r[i] = (*a)[m + i];
	l[n1 - 1] = INF*20;
	r[n2 - 1] = INF*20;
	int i = 0, j = 0;
	for (int k = s;k < t;k++) {
		if (l[i] <= r[j]) {
			(*a)[k] = l[i];
			i++;
		}
		else {
			(*a)[k] = r[j];
			j++;
		}
		cnt++;
	}
	return;
}


void merge_sort(vi *a, int s, int t) {
	if (s + 1 < t) {
		int m = (s + t) / 2;
		merge_sort(a, s, m);
		merge_sort(a, m, t);
		merging(a, s, m, t);
	}
	return;
}

int main() {
	int n;
	cin >> n;
	vi a(n);
	Loop(i, n) cin >> a[i];
	merge_sort(&a, 0, n);
	cout << a[0];
	Loop1(i, n - 1) cout << " " << a[i];
	cout << endl << cnt << endl;
	return 0;
}

Measured memory_bytes: 6780
#include <iostream>

int main() {
	int a, b, c;
	std::cin >> a >> b >> c;
	if (a + b < c) {
		std::cout << "NA" << std::endl;
	}
	else{
		if (a >= c) {
			std::cout << "0" << std::endl;
		}
		else {
			std::cout << c - a << std::endl;
		}
	}

	return 0;
}


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

int main()
{
  int p[5];
  while( cin >> p[0], p[0] ) {
    bool flag[3] = {0};
    flag[p[0]-1] = true;
    for(int i=1; i<5; i++) {
      cin >> p[i];
      flag[p[i]-1] = true;
    }

    int flag2[3];
    int cnt = 0;
    for(int i=0; i<3; i++) {
      if( flag[i] ) cnt++;
    }

    if( cnt != 2 ) {
      flag2[0] = flag2[1] = flag2[2] = 3;
    }
    else {
      if( flag[0] && flag[1] ) {
	flag2[0] = 1; flag2[1] = 2;
      }
      if( flag[1] && flag[2] ) {
	flag2[1] = 1; flag2[2] = 2;
      }
      if( flag[2] && flag[0] ) {
	flag2[2] = 1; flag2[0] = 2;
      }
    }

    for(int i=0; i<5; i++) {
      cout << flag2[p[i]-1] << endl;
    }
  }
}

Measured memory_bytes: 1164
def basket_count(arr):
    basket = []
    tmp = arr[0]
    cnt_ele = 0
    for ele in arr:
        if ele == tmp:
            cnt_ele += 1
        else:
            basket.append([tmp, cnt_ele])
            # reset count for basket
            tmp = ele
            cnt_ele = 1
    basket.append([tmp, cnt_ele])
    return basket

def solve():
    n = int(raw_input())
    v = [int(_) for _ in raw_input().split()]
    v0 = []
    v1 = []
    for i in range(n):
        if i % 2 == 0:
            v0.append(v[i])
        else:
            v1.append(v[i])
    v0.sort()
    v1.sort()
    bask_v0 = basket_count(v0)
    bask_v0.sort(reverse = True, key = lambda x: x[1])
    bask_v1 = basket_count(v1)
    bask_v1.sort(reverse = True, key = lambda x: x[1])
    if bask_v0[0][0] != bask_v1[0][0]:
        ret = n - (bask_v0[0][1] + bask_v1[0][1])
    elif len(bask_v1) <= 1:
        if len(bask_v0) > 1:
            ret = n - (bask_v0[1][1] + bask_v1[0][1])
        else:
            ret = n - bask_v0[0][1]
    else: # len(bask_v1) > 1
        if len(bask_v0) <= 1:
            ret = n - (bask_v0[0][1] + bask_v1[1][1])
        else:
            ret = n - max(bask_v0[0][1] + bask_v1[1][1], \
                          bask_v0[1][1] + bask_v1[0][1])
    print str(ret)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 21420
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String args[]) throws NumberFormatException, IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		long x = Long.parseLong(br.readLine());
		System.out.println(x * x * x);
	}
}

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

const int dirx[4] = {1, 0, -1, 0};
const int diry[4] = {0, 1, 0, -1};

char s[1005][1005];
int used[1005][1005];
queue < tuple <int, int, int> > q;
int h, w;

bool check(int x, int y){
	return x >= 1 && x <= h && y >= 1 && y <= w;
}

int main(){
	int ans, x, y, d, x0, y0;
	scanf("%d %d",&h,&w);
	for (int i = 1; i <= h; i++) scanf("%s", s[i] + 1);
	ans = 0;
	for (int i = 1; i <= h; i++){
		for (int j = 1; j <= w; j++){
			if (s[i][j] == '#'){
				q.push(make_tuple(i, j, 0));
				used[i][j] = 1;
			}
		}
	}
	while (!q.empty()){
		tie(x, y, d) = q.front(); q.pop();
		ans = max(ans, d);
		for (int i = 0; i < 4; i++){
			x0 = x + dirx[i]; y0 = y + diry[i];
			if (check(x0, y0) && !used[x0][y0]){
				q.push(make_tuple(x0, y0, d + 1));
				used[x0][y0] = 1;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 17296
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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() {
    println!("{}", {
        input!{
            n: u64,
        }
        let mut ans: u64 = 0;
        let mut t: u64 = 10;
        while n >= t {
            ans += n / t;
            t *= 5;
        }
        if n % 2 == 0 { ans } else { 0 }
    });
}


Measured memory_bytes: 4352
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 0, mod = (int) 0;

int main() {
	map<int, int> cnt;
	int n;
	cin >> n;
	while (n--) {
		int x;
		cin >> x;
		cnt[x]++;
	}
	cin >> n;
	while (n--) {
		int x;
		cin >> x;
		cnt[x]--;
		if (cnt[x] < 0) {
			cout << "NO\n";
			return 0;
		}
	}
	cout << "YES\n";
}





Measured memory_bytes: 9600
N = int(input())
towers = list(map(int, input().split()))
max_c = 0
c = 0
prev = 0
prev = towers[0]

for i in range(1, N):
    # print(i, c, prev, towers[i])
    if prev >= towers[i]:
        c += 1
    else:
        max_c = max(c, max_c)
        c = 0
    prev = towers[i]

max_c = max(c, max_c)
print(max_c)


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

int h, w, dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
long long c1, c2;
string s[409];
bool vs[409][409];

void dfs(int x, int y)
{
	vs[y][x] = true;
	if (s[y][x] == '#') c1++;
	else c2++;
	for (int i = 0; i < 4; i++) {
		int tx = x + dx[i], ty = y + dy[i];
		if (tx < 0 || tx >= w || ty < 0 || ty >= h || s[y][x] == s[ty][tx] || vs[ty][tx]) continue;
		dfs(tx, ty);
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> h >> w;
	for (int i = 0; i < h; i++)
		cin >> s[i];
	long long ans = 0;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++) {
			if (vs[i][j]) continue;
			c1 = c2 = 0;
			dfs(j, i);
			ans += c1 * c2;
		}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 18048
s = input()

count_p = len([_ for _ in s if _ == 'p'])
count_g = len(s) - count_p

if count_g - count_p <= 1:
    print(0)
elif len(s) % 2 == 0:
    print(count_g - len(s)//2)
else:
    print(len(s) // 2 - count_p)

Measured memory_bytes: 3572
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const double EPS = 1e-9;
const double INF = 1e9;




int main(){
	int n;cin>>n;
	REP(i,n){
		string str;cin>>str;
		sort(ALL(str),greater<long>());
		long ma=toLong(str);
		SORT(str);
		long mi=toLong(str);
		cout<<ma-mi<<endl;
	}
	return 0;
}
/*

*/

Measured memory_bytes: 1240
def main():
    N, Y = map(int, input().split())

    exhaustive_search(N, Y)

def exhaustive_search(N, Y):
    # 2000**2 => 4 * 10 * 6:Not TLE
    for m in range(N + 1):
        for g in range(N + 1):
            s = N - m - g
            #print(m, g, s)
            if 0 <= s <= N and \
                    m + g + s == N and \
                    m * 10000 + g * 5000 + s * 1000 == Y:
                print(m, g, s)
                return

    print(-1, -1, -1)

main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(int _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 200000

using namespace std;

int n;
int h[maxn+5];
ll a[maxn+5], d[maxn+5];///frum max pt subsecv care se termina in i

struct sgtree {
  sgtree () {}
  ll yy[4*maxn+5];
  void update (int p, pii itv, int ok, ll val) {
    if (ok < itv.fi || ok > itv.se) return;
    if (itv.fi == itv.se) { yy[p] = val; return; }
    int mid = (itv.fi + itv.se) / 2;
    update (p*2, {itv.fi, mid}, ok, val);
    update (p*2+1, {mid+1, itv.se}, ok, val);
    yy[p] = max(yy[p*2], yy[p*2+1]);
  }
  void preupdate (int ok, ll val) { update (1, {1,n}, ok, val); }
  ll q_query;
  void query (int p, pii itv, pii ok) {
    if (ok.se < itv.fi || itv.se < ok.fi) return;
    if (itv.fi >= ok.fi && itv.se <= ok.se) { q_query = max(q_query, yy[p]); return; }
    int mid = (itv.fi + itv.se) / 2;
    query(p*2, {itv.fi, mid}, ok);
    query(p*2+1, {mid+1, itv.se}, ok);
  }
  ll prequery (pii ok) {
    if (ok.fi > ok.se) return 0;
    q_query = 0;
    query(1, {1,n}, ok);
    return q_query;
  }
};

sgtree aint;

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  int i, j, z;
  for (i = 1; i <= n; i++) cin >> h[i];
  for (i = 1; i <= n; i++) cin >> a[i];
  ll ans = 0;
  for (i = 1; i <= n; i++) {
    d[i] = a[i] + aint.prequery({1,h[i]-1});
    aint.preupdate(h[i], d[i]);
    ans = max(ans, d[i]);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 10368
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        String t = in.nextLine();
        int len = s.length();
        Set<Character>[] ary = new Set['z'-'a'+1];
        Set<Character>[] ary2 = new Set['z'-'a'+1];
        for( int i = 0; i < 'z'-'a'+1; i++ ) ary[i] = new TreeSet<>();
        for( int i = 0; i < 'z'-'a'+1; i++ ) ary2[i] = new TreeSet<>();
        String ans = "Yes";
        for( int i = 0; i < len; i++ ) {
            char a = s.charAt(i);
            char b = t.charAt(i);
            ary[b-'a'].add(a);
            ary2[a-'a'].add(b);
            if( ary[b-'a'].size() > 1 || ary2[a-'a'].size() > 1 ) {
                ans = "No";
                break;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 42636
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	int N;
	cin>>N;
	int r=0;
	int b=0;
	rep(i,N){
		char c;
		cin>>c;
		if(c=='R')r++;
		if(c=='B')b++;
	}
	if(r>b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string> 
using namespace std;
long long n,a,b,ans;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>a>>b;
	if ((b-a)%2==0) ans=(b-a)/2;
	else {
		if (abs(b-a)>2)	ans=min(n-b+1+(b-a-1)/2,a+(b-a-1)/2);
		else ans=min(b-1,n-a);
	}
	cout<<ans<<endl;
	return 0;
} 

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

int main() {
  int n;cin>>n;
  vector<string> vec(n);
  rep(i,n)cin>>vec[i];
  rep(i,n-1)for(int j=i+1;j<n;j++){
    if(vec[i]==vec[j]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  rep(i,n-1){
    if(vec[i][vec[i].size()-1]!=vec[i+1][0]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 3636
//
//  main.cpp
//  ABC124
//
//  Created by hiroaki on 2019/05/07.
//  Copyright © 2019年 hiroaki. All rights reserved.
//

#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <climits> //max & min

#define int long long
#define pb(n) push_back(n)
#define ForI(n) for(int i=0;i<n;i++)
#define ForJ(n) for(int j=0;j<n;j++)
#define ForK(n) for(int k=0;k<n;k++)
#define Pr(n) cout<<n<<endl;
#define INS(v,n) for(int i=0;i<n;i++){cin >>v.at(i);}//vector 代入
#define ELM 100001 //問題によっては1000000001に変更
using namespace std;

//int Move(vector<int> v,int n){
//    int m[ELM] ={0};
//    for(int i=0; i<n; i++){
//        m[v[i]]++;
//    }
//    vector<int> s;
//    for (int i=0; i<n; i++) {
//        if (m[v[i]]!=0) {
//            cout<<m[v[i]]<<endl;
//            s.pb(m[v[i]]);
//        }
//    }
//    int move = *max_element(s.begin(), s.end());
//    return move;
//}
signed  main(){
//    ABC124-a
//    int A,B;
//    cin >> A>>B;
//    int ans = 0;
//    sample(2){
//        if(A>B){
//            ans+=A;
//            A--;
//        }else{
//            ans+=B;
//            B--;
//        }
//    }
//    cout<<ans<<endl;
    
//    ABC124-b
    int ans = 0;
    int N;
    cin >> N;
    vector<int> h(N);
    INS(h, N);
    ForI(N){
        int flag=0;
        ForJ(N){
            if (h[i]<h[j]) {
                flag=1;
            }
            if(j>=i){
                break;
            }
        }
        if(flag==0){
            ans++;
        }
    }
    Pr(ans);
    return 0;
}



Measured memory_bytes: 256
//Har Har Mahadev
using namespace std;
#include <bits/stdc++.h>
#define booga cout << "booga" << endl
#define ll long long int
#define pb push_back
#define mp make_pair
#define debug(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...);
}
const ll mod = 1e9 + 7;
void testcase(){
	ll n;
	cin >> n;
	ll tot = 1;
	ll zer = 1,com = 1;
	for(int i{0};i < n;i++){
		tot *= 10;tot %= mod;
		zer *= 9;zer %= mod;
		com *= 8;com %= mod;
	}
	zer *= 2;zer %= mod;
	//debug(tot,zer,com);
	cout << (mod + (tot - zer + com)%mod)%mod;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	while(t--){
		testcase();
	}
	return 0;
}


Measured memory_bytes: 3688
package main

import "fmt"

func main()  {
	var a, b, c int
	fmt.Scan(&a,&b,&c)
	if a == b && b == c && a == c {
		fmt.Println("No")
	} else {
		if a != b && b != c && a != c {
			fmt.Println("No")
		} else {
			fmt.Println("Yes")
		}
	}
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;

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

        int n = sc.nextInt();
        List<Integer> list1 = new ArrayList<>();
        List<Integer> list2 = new ArrayList<>();
        List<Integer> list3 = new ArrayList<>();
        int score = 0;

        for(int i = 0; i < n ; i++){
            list1.add(sc.nextInt());
        } 
        for(int i = 0; i < n ; i++){
            list2.add(sc.nextInt());
        } 
        for(int i = 0; i < n - 1; i++){
            list3.add(sc.nextInt());
        } 

        for(int i = 0 ; i < n ; i++){
            score += list2.get(list1.get(i)-1);
        }

        for(int i = 0 ; i < n - 1 ; i++){
            if(list1.get(i) == list1.get(i+1) - 1){
                score += list3.get(list1.get(i)-1);
            }
        }

        System.out.println(score);
        






    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a.at(i);
    int64_t tmp = 1, counter = 0;
    rep(i,n){
        if(a.at(i)==tmp){
            tmp++;
        }else{
            counter++;
        }
    }
    if(counter == n){
        cout << -1 << endl;
    }else{
        cout << counter << endl;
    }
}


Measured memory_bytes: 1920
N, M = list(map(int, input().split()))
PY = []
for i in range(M):
    p, y = list(map(int, input().split()))
    PY.append([p, y, i, 0])
PY.sort(key=lambda x:(x[0], x[1]))

city = PY[0][0]
city_start = 0
for i in range(len(PY)):
    if city == PY[i][0]:
        city_start += 1
    else:
        city = PY[i][0]
        city_start = 1
    PY[i][3] = str(city).zfill(6) + str(city_start).zfill(6)

PY.sort(key=lambda x: x[2])
for i in range(len(PY)):
    print(PY[i][3])


Measured memory_bytes: 96856