akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<sstream>
#include<iomanip>
#include<vector>
#include<deque>
#include<list>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<bitset>
#include<string>
#include<numeric>
#include<algorithm>
#include<functional>
#include<iterator>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<complex>
#include<ctime>

typedef long long ll;
using namespace std;

int main()
{
    string t;
    cin>>t;
    //cout<<t.length()<<endl;
    for(int i=0;i<t.length();i++)
    {
        if(t.length()==1)
        {
            if(t[i]=='?')
                t[i]='D';
        }
        else
        {
        if(t[i]=='?')
        {
            if(i==0)
            {
                if(t[i+1]=='?')
                    t[i]='P';
                if(t[i+1]=='P')
                    t[i]='D';
                if(t[i+1]=='D')
                    t[i]='P';
            }
            else if(i==(t.length()-1))
            {
                if(t[i-1]=='P')
                    t[i]='D';
                if(t[i-1]=='D')
                    t[i]='D';
            }
            else if(i>0&&i<(t.length()-1))
            {
                if(t[i-1]=='P')
                    {
                    t[i]='D';
                    }
                else
                {
                    if(t[i+1]=='?')
                    t[i]='P';
                    if(t[i+1]=='P')
                    t[i]='D';
                    if(t[i+1]=='D')
                    t[i]='P';
                }
            }
        }
        }
        if(t[i]!='?')
            continue;
    }
    cout<<t<<endl;
}

Measured memory_bytes: 3748
#![allow(unused_imports)]
#![allow(non_snake_case)]
use proconio::*;
 
fn main() {
    input! {
        s: String,
        t: String,
    }
    
    let ans = if s[..] == t[..s.len()] {
      	"Yes"
  	} else {
      "No"
  	};
    
    println!("{}", ans);
}

Measured memory_bytes: 2164
#include<stdio.h>
int main(void)
{	
	int e,y,x;	
	scanf("%d %d",&e,&y);
	if(e==1){
	x=1867+y;
	printf("%d\n",x);
	}
	else if(e==2){
	x=1911+y;
	printf("%d\n",x);
	}
	else if(e==3){
	x=1925+y;
	printf("%d\n",x);
	}
	else if(e==4){
	x=1988+y;
	printf("%d\n",x);
	}
	else if(e==0){
		if(y>=1868&&y<=1911){
		x=y-1868+1;
		printf("M%d\n",x);
		}
		else if(y>=1912&&y<=1925){
		x=y-1912+1;
		printf("T%d\n",x);
		}
		else if(y>=1926&&y<=1988){
		x=y-1926+1;
		printf("S%d\n",x);
		}
		else if(y>=1989&&y<=2016){
		x=y-1989+1;
		printf("H%d\n",x);
		}
		}
	return 0;
}


Measured memory_bytes: 2136
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 2e18;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double dbl;
#define pb push_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define all(a) a.begin(),a.end()
bool debug = 0;
const int MAXN = 2e5 + 100;
const int LOG = 25;
const int mod = 998244353;
const int MX = 1e6 + 100;
typedef long long li;
const li MOD = 1000000000949747713ll;

vector<int> g[MAXN];


int dfs(int v, int p) {
    vector<int> vals;
    for (int to:g[v]) {
        if (to == p)
            continue;
        int res = dfs(to, v);
        vals.pb(res);
    }
    if (sz(vals) == 0) {
        return 1;
    } else if (sz(vals) == 1) {
        return vals[0] + 1;
    } else {
        int val = 0;
        for (int v:vals) {
            val ^= v;
        }
        return val + 1;
    }
}

void solve() {
    int n;
    cin >> n;
    for (int i = 1; i <= n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }
    int res = dfs(1,1);
    if(res == 1){
        cout <<"Bob";
    } else{
        cout <<"Alice";
    }
}

signed main() {
#ifdef zxc
    debug = 1;
    freopen("../input.txt", "r", stdin);
    //freopen("../output.txt", "w", stdout);
#else

#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(20);

    int t = 1;
    while (t--)
        solve();
    if (debug)
        cerr << endl << "time : " << (1.0 * clock() / CLOCKS_PER_SEC) << endl;
}

Measured memory_bytes: 17408
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,b;
	string s=a+b;
	int zh(string s);
	cin>>a>>b;
	int r=zh(a+b);
	if(int(sqrt(r))==sqrt(r))
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
}
int zh(string s){
	int tmp=0;
	for(int i=0;i<s.size();i++)
	{
		tmp=tmp*10+(s[i]-'0');
	}
	return tmp;
}

Measured memory_bytes: 256
import string

S = input()
if len(S) < 26:
  for a in string.ascii_lowercase:
    if a not in S:
      print(S+a)
      exit()
else:
  S = list(S)
  L = [S[len(S)-1]]
  for i in range(24,-1,-1):
    for a in sorted(L):
      if a > S[i]:
        if i > 0:
          print(''.join(S[:i])+a)
        else:
          print(a)
        exit()
    L.append(S[i])
  print(-1)


Measured memory_bytes: 38512
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int w, h, n;
    cin >> w >> h >> n;
    vi x(n), y(n), a(n);
    rep(i, n) {
        cin >> x[i] >> y[i] >> a[i];
    }


    vvi aa(w, vi(h));
    rep(i, n) {
        switch(a[i]) {
            case 1:
                rep(j, x[i]) {
                    rep(k, h) {
                        aa[j][k] = 1;
                    }
                }
                break;
            case 2:
                for(int j = x[i]; j < w; ++j) {
                    rep(k, h) {
                        aa[j][k] = 1;
                    }
                }
                break;
            case 3:
                rep(j, w) {
                    rep(k, y[i]) {
                        aa[j][k] = 1;
                    }
                }
                break;
            case 4:
                rep(j, w) {
                    for(int k=y[i]; k < h; k++) {
                        aa[j][k] = 1;
                    }
                }
        }
    }


    int ans = 0;
    rep (i, w) {
        rep(j, h) {
            if(!aa[i][j]) {
                ans++;
            }
        }
    }

    

    cout << ans << endl;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  ll N,A,B,C,D;
  cin>>N>>A>>B>>C>>D;
  bool ok = false;
  for (ll x = 1; x <= N; x++) {
    ll ly1 = A+C*(x-1);
    ll uy1 = A+D*(x-1);

    ll ly2 = B+C*(N-x);
    ll uy2 = B+D*(N-x);
    if (uy1 < ly2)
      continue;
    if (uy2 < ly1)
      continue;
    ok = true;
  }
  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


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

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

	vector<string> A;
	for (int i=0; i<N; i++) {
		string str;
		cin >> str;
		A.push_back(str);
	}

	vector<string> B;
	for (int i=0; i<M; i++) {
		string str;
		cin >> str;
		B.push_back(str);
	}

	for (int i=0; i<N-M+1; i++) {
		for (int j=0; j<N-M+1; j++) {
			bool unmatched = false;
			for (int k=0; k<M; k++) {
				for (int l=0; l<M; l++) {
					if (A[i+k][j+l] != B[k][l]) {
						unmatched = true;
					}
				}
			}
			if (!unmatched) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

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


Measured memory_bytes: 256
a,b,c = map(int, input().split())
k = int(input())

ans = False

for _ in range(k):
    if c>b>a:
        ans = True
        break

    if a >= c:
        c *= 2
    else:
        if b == c:
            c *= 2
        elif c < b:
            if b < a:
                b *= 2
            else:
                c *= 2
        else:
            b *= 2
            
if c>b>a:
    ans = True

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



Measured memory_bytes: 61808
#include"bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	long long answer = 1;
	for (int i = 1;i <= N;++i) {
		answer = answer * i % 1000000007;
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;

int main()
{
    ll a, b;
    cin >> a >> b;
    if (a <= 0 && 0 <= b)
    {
        cout << "Zero" << endl;
        return 0;
    }
    if (0 < a)
    {
        cout << "Positive" << endl;
        return 0;
    }
    if (b < 0)
    {
        if ((b - a) % 2 == 0)
        {
            cout << "Negative" << endl;
            return 0;
        }
        else
        {
            cout << "Positive" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
import sys
X,N=map(int, input().split())
p = list(map(int, input().split()))
a=X
for i in range(0,101):
    if (a-i in p)==False:
        print(a-i)
        sys.exit()
    if (a+i in p)==False:
        print(a+i)
        sys.exit()


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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

//size用
struct UnionFind
{
  vector<int> par;
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    REP(i,n) par[i] = i;
  }
    
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y) return;

    if (sizes[x] < sizes[y]) swap(x, y);

    par[y] = x;
    sizes[x] += sizes[y];
    sizes[y] = 0;
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  int size(int x) {
    return sizes[find(x)];
  }
};


ll N,M;
vector<PL> bridge;
vector<ll> sum;

int main() {
    cin>>N>>M;
    bridge.resize(M);
    sum.resize(M+1);
    REP(i,M){
        LCIN(A,B);
        bridge[i]={A,B};
    }
    UnionFind Uni(N);
    sum[M] = N*(N-1)/2;
    REPR(i,M-1){
        ll f = bridge[i].first;
        ll t = bridge[i].second;
        if(Uni.same(--f,--t)){
            sum[i]=sum[i+1];
        }else{
            sum[i]= sum[i+1] - Uni.size(f)*Uni.size(t);
            Uni.unite(f, t);
        }
    }
    REP(i,M){
        cout<<sum[i+1]<<"\n";
    }
    return 0;
}
        

Measured memory_bytes: 4480
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

int main() {
	int n;
	cin >> n;
	vector<vector<int>>to(n), co(n);
	rep(i, n - 1) {
		int a, b, w;
		cin >> a >> b >> w;
		a--;
		b--;
		to[a].push_back(b); co[a].push_back(w);
		to[b].push_back(a); co[b].push_back(w);
	}
	vector<int>ans(n,-1);
	queue<int>q;
	ans[0] = 0;
	q.push(0);
	while (!q.empty()) {
		int v = q.front(); q.pop();
		rep(i, to[v].size()) {
			int u = to[v][i];
			int w = co[v][i];
			if (ans[u] != -1)continue;
			ans[u] = (ans[v] + w) % 2;
			q.push(u);
		}
	}
	rep(i, n) {
		cout << ans[i] << endl;
	}
	return 0;

}

Measured memory_bytes: 14608
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> dp(3);
    for (int i = 0; i < n; i++)
    {
        vector<int> new_dp(3, 0);
        vector<int> c(3);
        for (int j = 0; j < 3; j++)
        {
            cin >> c[j];
        }
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 3; k++)
            {
                if (j != k)
                    new_dp[j] = max(new_dp[j], c[j] + dp[k]);
            }
        }
        dp = new_dp;
    }
    cout << max({dp[0], dp[1], dp[2]}) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;
int main(){
    IOS;
    int n,m;
    int a[110];
    cin >> n >> m;
    double sum=0;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        sum+=a[i];
    }
    sum/=1.0*(4*m);
    int cnt=0;
    for(int i=1;i<=n;i++){
        if(a[i]>=sum)++cnt;
    }
    if(cnt>=m)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
h,w = list(map(int, input().split()))
data = {}
mod = {0:0,1:0,2:0,3:0}
for i in range(h):
    temp = input()
    for x in temp:
        if x in data:data[x]+=1
        else:data[x] = 1
for x in data.values():
    temp = x%4
    mod[temp] += temp

if mod[1] == 1 and mod[3] == 0 and h%2 == 1 and w%2 == 1 and mod[2]<= h+w-2 and (h+w-2-mod[2])%4==0:print('Yes')
elif mod[1] == 0 and mod[3] == 1 and h%2 == 1 and w%2 == 1 and mod[2]<= h+w-4 and (h+w-4-mod[2])%4==0:print('Yes')
elif mod[1] == 0 and mod[3] == 0 and h%2 == 1 and w%2 == 0 and mod[2]<= w     and (w-mod[2])%2==0    :print('Yes')
elif mod[1] == 0 and mod[3] == 0 and h%2 == 0 and w%2 == 1 and mod[2]<= h     and (h-mod[2])%2==0    :print('Yes')
elif mod[1] == 0 and mod[3] == 0 and h%2 == 0 and w%2 == 0 and mod[2]==0:print('Yes')
else: print('No')


Measured memory_bytes: 3188
#include <iostream>
#include <stack>

using namespace std;

static const int MAX = 100;
static const int WHITE = 1;
static const int GRAY = 2;
static const int BLACK = 3;
static const int NIL = -1;

class DFS{
private:
    int color[MAX];
    int M[MAX][MAX];
    stack<int> S;
    int n;
    int discovery[MAX];
    int finish[MAX];
    int time = 0;
    int next_vertex[MAX];
public:
    DFS()
    {
        cin >> n;
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
                M[i][j] = 0;
        int vertex;
        int degree;
        for(int i = 0; i < n; i++)
        {
            color[i] = WHITE;
            next_vertex[i] = 0;
            cin >> vertex;
            cin >> degree;
            int to_v;
            for(int j = 0; j < degree; j++)
            {
                cin >> to_v;
                M[vertex - 1][to_v - 1] = 1;
            }
        }
    }

    int next(int u)
    {
        for(int v = next_vertex[u]; v < n; v++)
        {
            next_vertex[u] = v + 1;
            if(M[u][v]) return v;
        }
        return NIL;
    }

    void dfs_visit(int start)
    {
        for(int i = 0; i < n; i++)
            next_vertex[i] = 0;

        S.push(start);
        color[start] = GRAY;
        discovery[start] = ++time;

        while(S.size() != 0)
        {
            int u = S.top();
            int v = next(u);
            if(v != NIL)
            {
                if(color[v] == WHITE)
                {
                    color[v] = GRAY;
                    discovery[v] = ++time;
                    S.push(v);
                }
            }
            else
            {
                S.pop();
                color[u] = BLACK;
                finish[u] = ++time;
            }
        }
    }

    void dfs()
    {
        for(int u = 0; u < n; u++)
        {
            if(color[u] == WHITE)
                dfs_visit(u);
        }

        for(int i = 0; i < n; i++)
            cout << i + 1 << " " << discovery[i] << " " << finish[i] << endl;
    }
};

int main()
{
    DFS dfs;
    dfs.dfs();
}


Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,n) for(int i=a;i<n;i++)
#define ps(x) cout<<x<<" "
#define pn(x) cout<<x<<"\n"
#define sz(a) int((a).size())
#define pb push_back
typedef vector< int > vi;
typedef pair< int,int > pairs;

int main()
{
 ll n,x;
 cin>>n;
 int arr[n+1]={0};
 loop(i,0,n-1)
 {
     cin>>x;
     arr[x]++;
 }
 loop(i,1,n+1)
 pn(arr[i]);
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	int n;
	cin >> n;
	map<string, int> M;
	string s;
	for (int i = 0; i < n; i++) {
		cin >> s;
		M[s]++;
	}
	cout << "AC x " << M["AC"] << "\n";
	cout << "WA x " << M["WA"] << "\n";
	cout << "TLE x " << M["TLE"] << "\n";
	cout << "RE x " << M["RE"] << "\n";
	return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <limits.h>
#include <math.h>

#include <iostream>
#include <string>
#include <vector>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

const int INF = 1e+8;

const int V_MAX = 10;
int V, E;
int cost[V_MAX][V_MAX];
bool used[V_MAX];
int d[V_MAX];

void dijkstra(int s) {
	int i, j;
	for (i=0; i<V; i++) {
		d[i] = INF;		
		used[i] = false;
	}

	d[s] = 0;
	while (1) {
		//未使用の頂点を探す
		int v = -1;
		for (i=0; i<V; i++)
			if (!used[i] && (v == -1 || d[i] < d[v]))
				v = i;

		if (v == -1) break;	//もう更新する頂点が無いからwhile抜ける
	
		//未使用の頂点vからの距離を計算
		used[v] = true;
		for (i=0; i<V; i++)
			d[i] = min(d[i], d[v] + cost[v][i]);
	}
}

int main() {
	int i, j;
	int total;
	int minT;

	while (1) {
		scanf("%d ", &E);
		if (!E) break;

		for (i=0; i<V_MAX; i++)
			for (j=0; j<V_MAX; j++)
				cost[i][j] = INF;
		for (i=0; i<V_MAX; i++)
			cost[i][i] = 0;

		V = 0;
		for (i=0; i<E; i++) {
			int vFrom, vTo, vCost;
			scanf("%d%d%d ", &vFrom, &vTo, &vCost);
			cost[vTo][vFrom] = cost[vFrom][vTo] = vCost;
			V = max(V, vFrom);
			V = max(V, vTo);
		}
		V++;	//Vを頂点の個数にするため++

		total = INF;
		minT = INF;
		for (i=0; i<V; i++) {
			dijkstra(i);

			int sum = 0;
			for (j=0; j<V; j++)
				sum += d[j];

			if (sum < total) {
				total = sum;
				minT = i;
			} else if (sum == total && i < minT)
				minT = i;
		}

		printf("%d %d\n", minT, total);
	}	

	return 0;
}

Measured memory_bytes: 1188
/**
  * BInary Search tree
  * output 1)node_number, 2)parent_number, 3)depth, 4)kind_of_node, 5)child_list
  */

/* inclution */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

/* Definition */
#define MAX 500000
#define LEN 10

/* Global Variables */
struct Node {
  int key;
  struct Node *right, *left, *parent;
};

/* Prototype */
void insert(int);
void inOrderWalk(struct Node*);
void preOrderWalk(struct Node*);

struct Node *root, *NIL;

int n;

/* main */
int main(){
  int i,x; //n: length of input, z: insert node key
  char str[LEN]; //insert???????´?
  
  /* input the number of A[] */
  scanf("%d",&n);
  
  /* input datas */
  for(i=0;i<n;i++){
    scanf(" %s", str);
    if(!strcmp(str, "insert")) {
      scanf("%d", &x);
      insert(x);
    }else if(!strcmp(str, "print")) {
      inOrderWalk(root);
      printf("\n");
      preOrderWalk(root);
      printf("\n");
    }
  }

  return 0;
}

/* insertion */
void insert(int k) {
  struct Node *y = NIL; //x ??? ???
  struct Node *x = root;
  struct Node *z;

  z = (struct Node *)malloc(sizeof(struct Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL) {
    y = x; // ???????¨????
    if (z->key < x->key) {
      x = x->left; // ?????????????§????
    }else {
      x = x->right; // ?????????????§????
    }
  }
  z->parent = y;

  if (y == NIL) { // T ???????????´???
    root = z;
  }else if (z->key < y->key) {
    y->left = z; // z ??? y ?????????????????????
  }else {
    y->right = z; // z ??? y ?????????????????????
  }
}

void inOrderWalk(struct Node *v) {
  if(v==NIL) {
    return;
  }
  inOrderWalk(v->left);
  printf(" %d", v->key);
  inOrderWalk(v->right);
}

void preOrderWalk(struct Node *v) {
  if(v==NIL) {
    return;
  }
  printf(" %d", v->key);
  preOrderWalk(v->left);
  preOrderWalk(v->right);
}

Measured memory_bytes: 24040
#include <iostream>
using namespace std;
 
int main()
{
  while(1){
    int m,f,r;
    cin >> m >> f >> r;
    if(m == -1 && f == -1 && r == -1) break;
    int a = m+f;
    if(m == -1 || f == -1) cout << "F" << endl;
    else if(a >= 80) cout << "A" << endl;
    else if(a >= 65) cout << "B" << endl;
    else if(a >= 50) cout << "C" << endl;
    else if(a >= 30){
      if(r >= 50) cout << "C" << endl;
      else cout << "D" << endl;
    } else cout << "F" << endl;
  }
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> m(4);
  rep(i, 4){
    m[i] = N % 10;
    N /= 10;
  }
  
  if(m[0] == m[1] && m[1] == m[2]) cout << "Yes" << endl;
  else if (m[1] == m[2] && m[2] == m[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Bracket Sequencing
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000000;
const int MAX_L = 1000000;

/* typedef */

typedef pair<int,int> pii;

/* global variables */

char s[MAX_L + 4];
pii pfs[MAX_N], pbs[MAX_N];

/* subroutines */

int check(int n, pii ps[]) {
  sort(ps, ps + n, greater<pii>());

  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (sum + ps[i].first < 0) return -1;
    sum += ps[i].second;
  }
  return sum;
}

/* main */

int main() {
  int n;
  scanf("%d", &n);

  int pfn = 0, pbn = 0;
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    int d = 0, mind = 0;
    for (int j = 0; s[j]; j++) {
      if (s[j] == '(')
	d++;
      else {
	d--;
	if (mind > d) mind = d;
      }
    }

    if (d >= 0) pfs[pfn++] = pii(mind, d);
    else pbs[pbn++] = pii(mind - d, -d);
  }

  int fsum = check(pfn, pfs);
  int bsum = check(pbn, pbs);

  if (fsum >= 0 && fsum == bsum) puts("Yes");
  else puts("No");
  return 0;
}


Measured memory_bytes: 10952
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;
int main()
{
	string s, t;
	cin >> s >> t;
	t.resize(t.size() - 1);
	if (s == t)	cout << "Yes" << endl;
	else { cout << "No" << endl; }
	return 0;
}

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

void rotate(int dice[], string mode){
	int dice_c[6];
	for (int i = 0; i < 6; i++) dice_c[i] = dice[i];
	if (mode == "North"){
		dice[0] = dice_c[1];
		dice[1] = dice_c[5];
		dice[2] = dice_c[2];
		dice[3] = dice_c[3];
		dice[4] = dice_c[0];
		dice[5] = dice_c[4];
	}
	else if (mode == "East"){
		dice[0] = dice_c[3];
		dice[1] = dice_c[1];
		dice[2] = dice_c[0];
		dice[3] = dice_c[5];
		dice[4] = dice_c[4];
		dice[5] = dice_c[2];
	}
	else if (mode == "West"){
		dice[0] = dice_c[2];
		dice[1] = dice_c[1];
		dice[2] = dice_c[5];
		dice[3] = dice_c[0];
		dice[4] = dice_c[4];
		dice[5] = dice_c[3];
	}
	else if (mode == "South"){
		dice[0] = dice_c[4];
		dice[1] = dice_c[0];
		dice[2] = dice_c[2];
		dice[3] = dice_c[3];
		dice[4] = dice_c[5];
		dice[5] = dice_c[1];
	}
	else if (mode == "Right"){
		dice[0] = dice_c[0];
		dice[1] = dice_c[2];
		dice[2] = dice_c[4];
		dice[3] = dice_c[1];
		dice[4] = dice_c[3];
		dice[5] = dice_c[5];
	}
	else if (mode == "Left"){
		dice[0] = dice_c[0];
		dice[1] = dice_c[3];
		dice[2] = dice_c[1];
		dice[3] = dice_c[4];
		dice[4] = dice_c[2];
		dice[5] = dice_c[5];
	}
}

int main(){
	int n;
	string input;
	while (cin >> n, n){
		int dice[6] = { 1, 2, 3, 4, 5, 6 }, ans = 1;
		for (int i = 0; i < n; i++){
			cin >> input;
			rotate(dice, input);
			ans += dice[0];
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s;
    cin>>s;
    for (int i=0;i<s.size();i++) {
        if (s.at(i)!=',') {
            cout<<s.at(i);
        } else {
            cout<<" ";
        }
    }
    cout<<endl;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[100005];

ll gcd(ll a, ll b) {
    if (a < b)
        swap(a, b);
    ll c = a % b;
    if (c == 0)
        return b;
    return gcd(b, c);
}

ll modpow(ll n, ll p, ll mod) {
    ll ret = 1;
    ll r = n;
    while (p > 0) {
        if ((p & 1) == 1)
            ret = (ret * r) % mod;
        r = r * r % mod;
        p >>= 1;
    }
    return ret;
}

ll calc(ll x) {
    ll ret = 0;
    while (x % 2 == 0) {
        ret++;
        x /= 2;
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    REP(i, N) {
        cin >> A[i];
    }

    ll m = calc(A[0]);
    REP(i, N) {
        if (m != calc(A[i])) {
            cout << 0 << endl;
            return 0;
        }
    }

    ll p = 1;
    ll r = 1;
    REP(i, N) {
        r = r / gcd(r, A[i] / 2) * A[i] / 2;
        p = p / gcd(p, A[i]) * A[i];

        if (p > M)
            p = M;
        if (r > M) {
            cout << 0 << endl;
            return 0;
        }
    }

    cout << (M - r) / p + 1 << endl;

    return 0;
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int X;
    cin >> X;

    int ans = 0;

    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= b; j++){
            for(int k = 0; k <= c; k++){
                if(500*i + 100*j + 50*k == X) ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 764
def aaaa():
    n=int(input())
    a=list(map(int, input().split()))
    ans=0
    if a[0]>0:
        if a[0]==1 and n==0:
            return 1
        else:
            return -1
        return -1
    nezen=1
    hazen=0
    line=[]
    liha=[]
    line.append(nezen)
    liha.append(hazen)
    su=0
    su=sum(a[x] for x in range(len(a)))
    for x in range(1,n+1):
        if nezen<=0:
            return -1
        ha=a[x]
        su-=ha
        ne=min(nezen*2-ha,su)
        nezen=ne
        line.append(ne)
        liha.append(ha)
    if line[n]<0:
        return -1
    line[n]=0
    for x in range(len(line)):
        ans+=line[x]+liha[x]
    return ans
print(aaaa())

Measured memory_bytes: 20032
/*
 * @Author: AsilenceBTF
 * @Buff: ︿(￣︶￣)︿  芜湖塔台 起飞
 * @Date: 2019-06-20 09:22:24
 * @LastEditTime: 2020-08-30 15:10:14
 */
// #include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
using namespace std;

#define sz(x) int(x.size())
#define ALL(x) x.begin(), x.end()
#define INF 0x3f3f3f3f
typedef long long ll;

const int MOD = 1e9 + 7;
int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    int n; cin >> n;
    ll ans = 0;
    vector<ll> pre(n + 2);
    for(int i = 1; i <= n; ++i){
        cin >> pre[i];
        if(i == 1) continue;
        ans = (ans + pre[i]*pre[i - 1] % MOD) % MOD;
        pre[i] = (pre[i] + pre[i - 1]) % MOD;
    }
    cout << ans << endl;
    // system("pause");    
}

Measured memory_bytes: 4792
/* 【祝】初自力即答 */
#include<iostream>
 
typedef std::uint64_t u64;
using namespace std;
 
int main(int argc, const char* argv[]) {
  u64 n, m;
  cin >> n >> m;
  
  for(u64 i = m / n; i > 0; --i) {
    if(m % i == 0) {
      cout << i << endl;
      return 0;
    }
  }
  
  cout << 1 << endl;
  
  return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	
	ll n,m;cin >> n >> m;
	bool flag = false;
	
	for(int i = 2;i*i <= m;i++){
		if(m % i == 0)flag = true;
	}
	
	if(!flag){
		cout << 1 << endl;
		return 0;
	}
	
	for(int i = n;i <= m;i++){
		if(m % i == 0){
			cout << m / i << endl;
			return 0;
		}
	}
	
	return 0;
}


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

int main() {
    int N, H;
    int max = 0, cnt = 0;

    std::cin >> N;
    for (int i = 0; i < N; ++i) {
        std::cin >> H;
        if (i == 0) {
            ++cnt;
            max = H;
        } else {
            if (max <= H) {
                ++cnt;
                max = H;
            }
        }
    }

    std::printf("%d\n", cnt);

    return 0;
}


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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type / Class / Struct Definitions:
using ll = long long;
using ull = unsigned long long;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main() {
    int a, b;
    cin >> a >> b;
    int ans = -1;
    rep(i, 2000) {
        if(floor(i * 0.08) != a) continue;
        if(floor(i * 0.1) != b) continue;
        ans = i;
        break;
    }
    cout << ans << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // input
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        String ans = "";
        if (s.equals("ABC")) ans = "ARC";
        else ans = "ABC";
        System.out.println(ans);
    }
}


Measured memory_bytes: 35672
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
static const int MOD = 1e9+7;

static const int NMAX = 1e6+5;

ll fact[NMAX];
ll inv_fact[NMAX];

void gcd(ll a, ll b, ll &x, ll &y)
{
    if(b == 0)
    {
        x = 1;
        y = 0;
    }
    else
    {
        ll x0,y0,d;
        gcd(b,a%b,x0,y0);
        x = y0;
        y = x0 - (a/b)*y0;
    }
}


ll invers_modular(ll a, ll n)
{
    ll inv,ins;
    gcd(a,n,inv,ins);
 
    if(inv < 0)
    {
        inv = n + inv % n;
    }
    inv%=n;
    return inv;
}

void factorial(int n)
{
    fact[1] = 1;
    for(int i =2; i<= n; ++i)
    {
        fact[i] = (fact[i-1] * i) % MOD;
    }
    for(int i = 0; i <= n; ++i)
    {
        inv_fact[i] = invers_modular(fact[i], MOD);
    }
}

ll comb(ll n, ll m)
{
    if(n < m)
        return 0;
    
    return ((fact[n] * inv_fact[m]) % MOD * inv_fact[n-m]) % MOD; 
    
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int x,y;
	cin >> x >> y;
	
	if(1LL*(x+y) % 3 !=0)
	{
		cout << 0 << '\n';
		return 0;
	}
	if (max(x, y) > 2*min(x, y)) {
        cout << 0 << '\n'; return 0;
    }

	ll n = (x + y)/3;
	factorial(n);
	ll top_y = 1LL * n*2;
	ll diff = top_y - y ;
	if(diff == 0 || diff == n)
	{
		cout << 1;
		return 0;
	}
	cout << comb(n,diff) % MOD;


    return 0;
}

Measured memory_bytes: 14592
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll x;
    cin >> x;
    ll a,b,c=0;
    for(a=-120;a<120;a++)
    {
        for(b=-120;b<120;b++)
        {
            if(pow(b,5)-pow(a,5)==x)
                {
                    cout << b << " " << a << endl;
                    c=1;
                    break;
                }
        }
        if(c==1)
        break;
    }
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max()/2;
const int MOD = 1e9+7;

struct UF {
	vector<int> data;
	UF(int size) : data(size, -1) { }
	bool unite(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool find(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

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

    int n,h,w;cin>>n>>h>>w;
    vector<P> pos(n);
    int wall=0;
    for(int i=0;i<n;i++){
        int x,y;cin>>x>>y;
        pos[i]=P(x,y);
        if(x==1 || x==h || y==1 || y==w) wall=1;
    }
    UF uf(n);
    for(int i=0;i<n;i++){
        for(int j=1;j<n;j++){
            if(pos[i].first==pos[j].first || pos[i].second==pos[j].second) uf.unite(i,j);
        }
    }
    set<int> st;
    for(int i=0;i<n;i++){
        int r=uf.root(i);
        st.insert(r);
    }
    int sz=st.size();
    if(sz==1) cout<<n-1<<endl;
    else{
        cout<<n-1+sz-wall<<endl;
    }
}


Measured memory_bytes: 4656
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")

// #pragma GCC optimize("O3")
#pragma GCC target("avx2")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  vector<int> a = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  cin >> A;
  sort(all(A));
  reverse(all(A));
  int mi = INF;
  for (int ele : A) { chmin(mi, a[ele]); }
  vector<int> dp(N + 1, -INF);
  dp[0] = 0;
  for (int i = 1; i <= N; i++) {
    for (int j : A) {
      if (i - a[j] >= 0) chmax(dp[i], dp[i - a[j]] + 1);
    }
  }
  int cur = N;
  vector<int> ans;
  for (int i = 0; i < dp[N]; i++) {
    for (int j : A) {
      if (cur - a[j] >= 0 && dp[cur - a[j]] == dp[cur] - 1) {
        ans.push_back(j);
        cur -= a[j];
        break;
      }
    }
  }
  for (int i = 0; i < ans.size(); i++) cout << ans[i];
  cout << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


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

int N;
int A[100000];

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

  int color = 1;
  multiset<int> s;
  s.insert(A[0]);

  for(int i=1; i<N; i++) {
    int a = A[i];
    auto lb = s.lower_bound(a);
    if(lb == s.begin()) {
      s.insert(a);
      color++;
    }
    else {
      s.erase(prev(lb));
      s.insert(a);
    }
  }
  cout << color << endl;
}


Measured memory_bytes: 5376
/*
   Creator - Glitched
   Yeet!!
*/
#include "bits/stdc++.h"

using namespace std;

#define testcases ll T;cin>>T;while(T--)
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define loopr(i,x,n) for(ll i=n-1;i>=x;i--)
#define ff first
#define ss second
#define pb push_back
#define elif else if
#define flush cout<<"\n"
#define mod 1000000007
#define L LONG_MAX
#define fastio ios_base::sync_with_stdio(false)
const string yes = "YES", no = "NO";

int main()
{   
    ll n,k;
    cin>>n>>k;
    if(n>=10)
        cout<<k;
    else
        cout<<k + 100*(10-n);
    flush;
}


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


int main()
{
    long long a,b,x;
    std::cin >> a >> b >> x;
    long long aa = (a-1) / x;
    long long bb = b / x;
    if(a == 0){
        aa = 0;
        bb = b / x;
        bb++;
    }
    std::cout << bb - aa << std::endl;
}

Measured memory_bytes: 256
N=int(input())
C=list(map(int,input().split()))
Alice=0
Bob=0
new=sorted(C,reverse=True)
for i in range(N):
  if i%2==0:
    Alice+=new[0]
    new.pop(0)
  else:
    Bob+=new[0]
    new.pop(0)
print(Alice-Bob)

Measured memory_bytes: 9164
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    string s;
    cin >> s;
    cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long maxS = 1e6 + 7;
bool visited[maxS];

void dfs(vector<ll>g[] , int i , set<ll>&s){
    if(visited[i]){
        return ;
    }
    s.insert(i);
    visited[i] = 1;
    for(int j : g[i]){
        dfs(g , j , s);
    }
}


int main(){
    ll n , m , ans = 0;
    cin>>n>>m;
    vector<ll> g[n + 1];
    for(int i = 0; i < m; i++){
        ll u , v;
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for(int i = 0; i < n; i++){
        set<ll>s;
        if(!visited[i])
            dfs(g , i , s);
        // for(int j : s){
        //     cout<<j<<" ";
        // }
        // cout<<endl;
        ans = max(ans , (ll)s.size());
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 36576
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int a[3];
	while(a[0]=in(),a[1]=in(),a[2]=in()){
		int n=in();
		int i;
		sort(a,a+3);
		for(i=0;i<n;i++){
			int sz=in();
			if(a[0]*a[0]+a[1]*a[1]<4*sz*sz)cout<<"OK"<<endl;
			else cout<<"NA"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int aaa[50];

int main(){
  int atai,i;

  for(i=0;i<50;i++){
    aaa[i]=-1;
  }

  scanf("%d",&atai);
  printf("%d\n",fibonati(atai));

  return 0;
}

int fibonati(int q){
  if(q==0 || q==1){
    return aaa[q]=1;
  }
  if(aaa[q]!=-1){
    return aaa[q];
  }

  return aaa[q]=fibonati(q-1)+fibonati(q-2);
}



Measured memory_bytes: 2048
#include<iostream>
#include<iomanip>
#include<math.h>
#include<cstdio>
using namespace std;

int main(){

        int a, b;
        char op;

        while(true){

        cin >> a >> op >> b;

        if(op == '+'){cout << a + b << endl;}
        if(op == '-'){cout << a - b << endl;}
        if(op == '*'){cout << a * b << endl;}
        if(op == '/'){cout << a / b << endl;}

        if(op == '?'){break;}

        }

}




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

int main() {
  int N, A, B, n, sum = 0;
  cin >> N >> A >> B;
  
  for (int i = 0; i < N; i++) {
    n = i + 1;
    int nsum = 0;
    while (n != 0) {
       nsum += n % 10; n /= 10;
    }          
    
    if ((A <= nsum) && (nsum <= B)) sum += i + 1;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
N, W, *t = map( int, open( 0 ).read().split() )
d = [[ 0 for _ in range( W + 1 ) ] for _ in range( N + 1 ) ]
ans = 0
 
i = 0
for w, v in zip( *[ iter( t )] * 2 ):
  for j in range( 1, W + 1 ):
    d[ i + 1 ][ j ] = d[ i ][ j ]
    if j - w >= 0:
      d[ i + 1 ][ j ] = max( d[ i ][ j - w ] + v, d[ i ][ j ] )
  i += 1
print( d[N][W])

Measured memory_bytes: 171656
N = int(input())
A = list()
light = 1
count = 0
for i in range(N):
  A.append(int(input()))
for i in range(N):
  if light == 2:
    print(count)
    count = 0
    break
  else:
    light = A[int(light)-1]
    count += 1
    if count  == N:
      print(-1)
      break

Measured memory_bytes: 7084
import java.util.*;

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

        System.out.println(PowerSocket(1, A, B));
    }
    public static int PowerSocket(int SocketNum, int A, int B) {
        if (SocketNum >= B) {
            return 0;
        }
        return 1 + PowerSocket(SocketNum + A - 1, A, B);
    }
}


Measured memory_bytes: 24916
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> v(n), u(m);
    for (auto &&i : v) scanf("%d", &i);
    for (auto &&j : u) scanf("%d", &j);
    auto dp = make_v(n+1, m+1, 0);
    dp[0][0] = 1;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= m; ++j) {
            if(i) (dp[i][j] += dp[i-1][j]) %= MOD;
            if(j) (dp[i][j] += dp[i][j-1]) %= MOD;
            if(i > 0 && j > 0){
                (dp[i][j] += MOD - dp[i-1][j-1]) %= MOD;
                if(v[i-1] == u[j-1]){
                    (dp[i][j] += dp[i-1][j-1]) %= MOD;
                }
            }
        }
    }
    cout << dp[n][m] << "\n";
    return 0;
}

Measured memory_bytes: 16000