akhauriyash/Code-Regression huggingface dataset:
C = []
for i in range(3):
    c = list(map(int, input().split()))
    C.append(c)

a = [None, None, None]
b = [None, None, None]
for a1 in range(101):
    a[0] = a1
    b[0] = C[0][0] - a[0]
    b[1] = C[0][1] - a[0]
    b[2] = C[0][2] - a[0]
    a[1] = C[1][0] - b[0]
    a[2] = C[2][0] - b[0]


ans = 'Yes'
for i in range(3):
    for j in range(3):
        if C[i][j] != a[i] + b[j]:
            ans = 'No'
print(ans)




Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
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;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve() {
  ll n,m;
  cin>>n>>m;
  vi a(m);
  rep(i,m) cin>>a[i];
  rep(i,m) n-=a[i];
  ll p=-1;
  out(max(p,n));
}

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


Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
int main () {
  vector<bool>P(300, true);
  int x, N;
  cin >> x >> N;
  for (int i = 0; i < N; i ++) {
    int p;
    cin >> p;
    P[p] = false;
  }
  for (int i = 0; i <= x; i ++) {
    for (int j = 0; j < 2; j ++) {
      int i_ = i;
      if (j == 0) i_ *= -1;
      if (P[x + i_]) {
        cout << x + i_ << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

string str_int(int num){
	string str, d;
	str = "";
	while(true){
		if(num == 0){
			break;
		}
		d = "D";
		d[0] = (num % 10) + '0';
		str = d + str;
		num /= 10;
	}
	return str;
}

string rewrite(string str){
	string res = "";
	string d = "D";
	char c = str[0];
	int count = 0;
	for(int i = 0; i < str.size(); i++){
		if(c != str[i] && i != 0){
			d[0] = c;
			res = res + str_int(count) + d;
			c = str[i];
			count = 1;
		}else{
			count++;
		}
	}
	d[0] = c;
	res = res + str_int(count) + d;
	return res;
}

int main(){
	
	int n;
	
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}
		string str;
		cin >> str;
		for(int i = 0; i < n; i++){
			str = rewrite(str);
		}
		cout << str << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1468
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main() {
  string s;
  cin >> s;
  vector<int> cnt(2);
  rep(i, s.size()) cnt[s[i] - '0']++;
  cout << 2 * min(cnt[0], cnt[1]) << endl;
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    ll N;
    cin >>N;
    
    ll fis,end;
    vector<ll>m(N,-1);
    rep(i,N+1){
        ll a;
        cin>>a;
        a--;
        if(m[a]==-1){
            m[a]=i;
        }else{
            fis=m[a];
            end=i;
        }
    }

    COMinit();
    cout<<N<<endl;
    rep3(i,2,N+2){
        //cout<<"OK"<<endl;
        ll ans=(COM(N+1,i)-COM(N+1-(end-fis+1),i-1)+MOD)%MOD;
        //cout<<"OK2"<<endl;
        //cout<<COM(N+1,i)<<" "<<COM(N-(end-fis+1),i-1)<<endl;
        cout<<ans<<endl;
    }
 



    return 0;
    

}

Measured memory_bytes: 15844
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>

typedef unsigned long long ULL;
typedef long long LL;

using namespace std;

void process();

int main(){
    int K,X;
    cin >> K >> X;
    if( K * 500 >= X){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

void process(){
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;
 
 int main(void){
     long long  A,B,C;
     cin >> A >> B >> C;
     if(A+B>=C){
         cout << B+C << endl;
     }else if(A+B<C){
         cout << A+B+B+1 << endl;
     }
 }

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

    class Program
    {
        static void Main(string[] args)
        {
            var boin = new [] { 'a', 'e', 'i', 'o', 'u' };
            var c = Console.ReadLine().ToCharArray();
            Console.WriteLine(boin.Contains(c[0])? "vowel": "consonant");
        }
    }

Measured memory_bytes: 13268
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main() {

    int a1, a2,a3;
    scanf("%d%d%d", &a1, &a2,&a3);

    if(a1+a2+a3>=22){
        puts("bust");
    }else{
        puts("win");
    }
    
    return 0;

}


Measured memory_bytes: 128
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
/**************************************************************************/
signed main()
{
    fast;
    int n;
    cin>>n;
    int dp[n+1];
    int h[n+1];
    for(int i=1;i<=n;i++)
        cin>>h[i];
    dp[1] = 0;
    dp[2] = abs(h[2]-h[1]);
    for(int i=3;i<=n;i++)
    {
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n];
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>

using namespace std;

int main() {
  constexpr int N = 100003;
  int X;
  cin >> X;
  vector<bool> is_prime(N + 1, true);
  is_prime[0] = false;
  is_prime[1] = false;
  for (int i = 2; i <= N; i++) {
    if (is_prime[i]) {
      if (i >= X) {
        cout << i << endl;
        return 0;
      }
      for (int j = i * 2; j <= N; j += i) {
        is_prime[j] = false;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);

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

  vector<int> h(n);
  rep(i,n) cin >> h[i];
  int cnt = 0;
  rep(i,n) {
    if(h[i] >= k) cnt++;
  }
  cout << cnt << endl;
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
def solve1(n, r, s, p, t):
    cur = {'r': 0, 's': 0, 'p': 0}
    for c in t:
        prv = cur
        cur = {'r': 0, 's': 0, 'p': 0}
        for x in 'rsp':
            if x == 'r' and c == 's':
                score = r
            elif x == 's' and c == 'p':
                score = s
            elif x == 'p' and c == 'r':
                score = p
            else:
                score = 0
            for y in 'rsp':
                if y != x:
                    cur[x] = max(cur[x], prv[y] + score)
    return max(cur.values())

def solve(n, k, r, s, p, t):
    u = [[] for _ in range(k)]
    for i, c in enumerate(t):
        u[i % k].append(c)
    return sum([solve1(n, r, s, p, u[j]) for j in range(k)])

def main():
    n, k = map(int, input().split())
    r, s, p = map(int, input().split())
    t = input()
    print(solve(n, k, r, s, p, t))
if __name__ == "__main__":
    main()


Measured memory_bytes: 17140
#include <bits/stdc++.h>
#include <ext/rope>
using namespace std;
using namespace __gnu_cxx;

using ci = const int;
using ld = long double;
using llint = long long;
using ullint = unsigned long long;
using pii = pair <int,int>;
using pcc = pair <char,char>;
using pll = pair <llint,llint>;
using pss = pair <string,string>;
using vi = vector <int>;
using vb = vector <bool>;
using vll = vector <llint>;
using vii = vi::iterator;

#define INF (1<<30)
#define MOD 1000000007
#define mt make_tuple
#define all(c) c.begin(), c.end()
#define ms(name,val) memset(name, val, sizeof name)
#define np nullptr
// inline functions



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

    int n;
    cin >> n;
    double a[n], dp[n+1][n+1];
    ms(dp, 0.0);
    dp[0][0] = 1.0;

    for (int t1 = 0; t1 < n; ++t1)
        cin >> a[t1];

    for (int t1 = 0; t1 < n; ++t1)
    {
        for (int t2 = 0; t2 <= n; ++t2)
        {
            if (dp[t1][t2] != 0.0)
            {
                dp[t1+1][t2+1] += (a[t1]*dp[t1][t2]);
                dp[t1+1][t2] += (1-a[t1])*dp[t1][t2];
            }
        }
    }

    double ans = 0.0;

    for (int t1 = n/2 + 1; t1 <= n; ++t1)
        ans += dp[n][t1];

    cout << setprecision(10) << fixed << ans << '\n';




































    return 0;
}

Measured memory_bytes: 70656
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

int main()
{
    int N, M, ans = 1e9, k;
    cin >> N;
    vector <int> A(N, 0);
    for (int i = 0; i < N; i++) cin >> A[i];

    sort(A.begin(), A.end());
    M = A[N-1];
    
    for (int i = 0; i < N; i++) {
        if (ans > abs(A[i]*2 - M)) {
            ans = abs(A[i]*2 - M);
            k = A[i];
        }
    }

    cout << A[N-1] << " " << k << endl;
    return 0;
}


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

int main() {
     ll a,b,c;
     cin>>a>>b>>c;
     ll d=a+b+c;
     if(d>=22)
     cout<<"bust"<<endl;
     else
     cout<<"win"<<endl;
   	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
using namespace std;
//scanf("%d%d",&W,&H);
//printf("%d\n",c);
int main() {
  int H,W,j,i;
  i=1;
  j=1;
  while(1){
    scanf("%d %d",&H,&W);
    
    if(H==0 && W==0) break;
   
    while(i<W+1){     //上枠
        i=i+1;
        printf("#");
    }
    i=1;
    printf("\n");
    
    while(j<H-1){
      printf("#");
      while(i<W-1){
        i=i+1;
        printf(".");
      }
      printf("#");
      printf("\n");
      j=j+1;
      i=1;
    }
    
    while(i<W+1){     //下枠
        i=i+1;
        printf("#");
    }
    i=1;
    j=1;
    printf("\n");
    printf("\n");
  }
}


Measured memory_bytes: 2616
//
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<ctime>
#include<cassert>
#include<algorithm>
#include<cmath>

#include<cstring>
#include<string>
#include<cctype>
#include<utility>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<list>

typedef long long ll;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
typedef std::vector<int> vi;

const int OO=(int)2e9;
const ll INF=(ll)4e18;
const double EPS=(double)1e-12;

#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front

#define INL(i,a,b) ((a<=i)&&(i<=b))
#define EXL(i,a,b) ((a< i)&&(i< b))
#define REPP(i,a,b,c) for(int i=a;i<=b;i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a;i>=b;i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
using namespace std;

int a,b,c;

int main(){
	scanf("%d %d %d",&a,&b,&c);
	if(b-a==c-b)puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
n = int(input())
MOD = 10**9 + 7

def prime_factorization(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

import math
prime_factors = prime_factorization(math.factorial(n))

from collections import Counter
c = Counter(prime_factors)

ans = 1
for v in c.values():
    ans *= (v+1)
    ans %= MOD
print(ans)

Measured memory_bytes: 3380
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

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

  map<char,int> mp;
  for(char c:s) mp[c]++;
  if(mp['N'] && !mp['S']){
    cout<<"No"<<endl;
    return 0;
  }
  if(mp['S'] && !mp['N']){
    cout<<"No"<<endl;
    return 0;
  }
  if(mp['W'] && !mp['E']){
    cout<<"No"<<endl;
    return 0;
  }
  if(mp['E'] && !mp['W']){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-2;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n;
int a[1 << 17];

struct SegT {
private:
	int sz; vector<LP> node;
	const LP init_c = { 0,0 };
public:
	SegT(int n) {
		sz = 1;
		while (sz < n)sz *= 2;
		node.resize(2 * sz - 1, init_c);
	}
	LP f(LP a, LP b) {
		return max(a, b);
	}
	void update(int k, LP a) {
		k += sz - 1;
		node[k] = a;
		while (k > 0) {
			k = (k - 1) / 2;
			node[k] = f(node[k * 2 + 1], node[k * 2 + 2]);
		}
	}
	LP query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0)r = sz;
		if (r <= a || b <= l)return init_c;
		else if (a <= l && r <= b)return node[k];
		else {
			LP vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			LP vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return f(vl, vr);
		}
	}
};
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}
	SegT st(100001);
	rep(i, n) {
		LP z = st.query(0, a[i]);
		z.first++; z.second += a[i];
		st.update(a[i], z);
	}
	LP z = st.query(0, 100001);
	cout << z.second << endl;
	//stop
	return 0;
}


Measured memory_bytes: 7348
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
#define ff first
#define ss second
#define int long long 
#define endl "\n"
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);	

const int inf = 1e9;
const int MOD = 998244353;
const int N = 1e5+4;

int n , x;

void solve(){	
	cin >> n >> x;
	map<int,int> m;
	for(int i=0 ; i<x ;i++){
		int d , a;
		cin >> d;
		for(int j=0 ; j<d ;j++){
			cin >> a;
			m[a]++;
		}
	}
	
	int sz = m.size();
	cout << n-sz << endl;
	
}

	
int32_t main(){
	FAST;
	int t=1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
}	

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

int main() {
  string s,fr = "",back = "";
  int q;
  cin >> s >> q;
  bool rev = true;
  for(int i = 0;i < q;i++){
    int t;
    cin >> t;
    if(t == 1){
      if(rev) rev = false;
      else rev = true;
    }
    else{
      int f;string c;
      cin >> f >> c;
      if((rev && f == 1)||(rev == false && f == 2)){
        fr += c;
      }
      else{
        back += c;
      }
    }
  }
  reverse(fr.begin(),fr.end());
  s = fr+s+back;
  if(rev == false) reverse(s.begin(),s.end());
  cout << s << endl;
}


Measured memory_bytes: 1348
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <functional>
#include <stdlib.h>
#include <climits>
#include <iomanip>
#include <complex>
#include <cmath>
using namespace std;
signed main(void)
{
	int n, k;
	cin >> n >> k;
	long long ans = 0;
	for (int b = k + 1; b <= n; b++) {
		ans+=((n+1) / b)*(b-k) + max((n+1)%b - k, 0);
	}
	if (k == 0)ans -= n;
	cout << ans;
	return 0;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (true) {
        ll d;
        cin >> d;
        if (d == 0) break;
        ll n, m;
        cin >> n >> m;
        vector<ll> S(n);
        S.at(0) = 0;
        for (int i = 1; i < n; ++i) {
            cin >> S.at(i);
        }
        sort(S.begin(), S.end());
        ll sum = 0;
        for (int i = 0; i < m; ++i) {
            ll c;
            cin >> c;
            auto itr = upper_bound(S.begin(), S.end(), c);
            if (itr != S.end()) {
                sum += min(*itr - c, c - *(itr - 1));
            } else {
                sum += min(d - c, c - *(itr - 1));
            }
        }
        cout << sum << endl;
    }

    return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);

	if (a <= c && c <= b)
	{
		printf("Yes\n");
	}else
	{
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 256
#1  から N の番号がついた N 個の重りがあり、番号 i の重りの重さは Wi です。
#ある整数 1≤T<N に対してこれらの重りを、番号が T 以下の重り と 番号が T より大きい重りの 2
# グループに分けることを考え、それぞれのグループの重さの和を S1,S2 とします。
#このような分け方全てを考えた時、S1 と S2 の差の絶対値の最小値を求めてください。

N = int(input())
W = list(map(int, input().split()))
S = sum(W)
s = []

for i in range(N):
    S1 = sum(W[:i])
    S2 = sum(W[i:N])
    S12 = abs(S1 - S2)
    s.append(S12)

print(min(s))

Measured memory_bytes: 38512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
using namespace std;

typedef pair<int,int> pii;

int dx[] = {1, 0, -1, -1, 0, 1};
int dy[] = {-1, -1, 0, 1, 1, 0};

vector<pii> form(const string &record, char first){
	vector<pii> v(record.size() + 1);
	int x = 0, y = 0;
	int mx = 0, my = 0;

	for(int i = 0; i < record.size(); ++i){
		int t = (record[i] - first+ 6) % 6;
		x += dx[t];
		y += dy[t];
		v[i + 1] = pii(x, y);
		
		mx = min(mx, x);
		my = min(my, y);
	}
	
	for(int i = 0; i < v.size(); ++i){
		v[i].first -= mx;
		v[i].second -= my;
	}
	
	sort(v.begin(), v.end());
	return v;
}

int main(){
	int n;
	string s, t, u;

	cout << boolalpha;
	cin >> n;
	cin.ignore();
	
	while( n-- ){
		getline(cin, s);
		getline(cin, t);
		getline(cin, u);

		vector<pii> v1 = form(s, 'a');
		bool f = false;
		for(char c = 'a'; !f && c <= 'f'; ++c){
			if( form(t, c) == v1 ){
				f = true;
				break;
			}
		}
		
		cout << f << '\n';
	}
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
typedef pair<int,int> P;
#define mod 1000000007

int main(){
    int a,b,x;
    bool flag=true;
    cin >> a >>b >> x;
    if(a+b<x) flag=false;
    if(a>x) flag=false;
    if(flag) cout << "YES" <<endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
x = 0
y = 0
for i in range(N):
    if S[i]=='A':
        x = 1
    elif S[i]=="B" and x==1:
        x = 2
    elif S[i]=="C" and x==2:
        y+=1
        x = 0
    else:
        x = 0
print(y)

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

#define YES "Yes"
#define NO "No"

int main()
{
    int k, x, a = 0;

    scanf("%d %d", &k, &x);

    a = k*500;

    if (a >= x)
        printf("%s", YES);
    else 
        printf("%s", NO);

    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a, b, c;
  cin >> a >> b >> c;
  if(a == 'A' && b == 'A' && c == 'A'){
    cout << "No" << endl;
  }
  else if(a == 'B' && b == 'B' && c == 'B'){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}

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

int main(void) {
  ll n;
  cin >> n;
  ll ans=1;
  for(ll i = 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int a = scan.nextInt();
		int b = scan.nextInt();

		if(a>b){
			System.out.println("a > b");
		}else if (a<b) {
			System.out.println("a < b");

		}else {
			System.out.println("a == b");
		}


	}

}

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

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

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 11

int main()
{
    int cnt = 0;
    int n; cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    for(int i = 0; i < n; i++){
        if(i % 2 == 0 && a[i] % 2 == 1) cnt++;
    }
    cout << cnt << endl;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  while (true){
    C -= B;
    if (C <= 0) {
      cout << "Yes" << endl;
      break;
    }
    A -= D;
    if (A <= 0) {
      cout << "No" << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>
#define N 10000

int main()
{
  int num,q,t,i;
  int S[N],count;

  scanf("%d", &num);
  for(i = 0; i < num; ++i) {
    scanf("%d", &S[i]);
  }

  count = 0;

  scanf("%d", &q);
  while(q--){
    scanf("%d", &t);
    for(i = 0; i < num; ++i) {
      if(S[i] == t) {
        ++count;
        break;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 2108
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <bitset>
#include <limits>

using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(int i = (a); i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i)
#define FLOAT setprecision(16)
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const double EPS = 1.0e-9;

template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
// all_of

#if 1234567891
#include <array>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

#if _DEBUG
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#endif

int H, W, D;
string s[500];
void ki() {
	REP(i, 0, H) {
		REP(j, 0, W) {
			if (i % 2 == j % 2) {
				s[i][j] = 'R';
			} else {
				s[i][j] = 'Y';
			}
		}
	}
}
void kigu() {
	REP(i, 0, H) {
		REP(j, 0, W) {
			s[i][j] = "RYGB"[(i % 4 + ((j / 2) % 2) * 2) % 4];
		}
	}
}
void gu() {
	REP(i, 0, H) {
		REP(j, 0, W) {
			bool b = i / D % 2 == j / D % 2;
			int p = b ? i % D : (D - 1 - i % D);
			int q = j % D;
			int r = 4;
			if (p <= q && p < D - q - 1)r = 0;
			if (p > q && p <= D - q - 1)r = 1;
			if (p < q && p >= D - q - 1)r = 2;
			if (p >= q && p > D - q - 1)r = 3;
			s[i][j] = b ? "RYGB."[r] : "RGYB."[r];
		}
	}
}

int main() {
	cin >> H >> W >> D;
	REP(i, 0, H) {
		s[i].resize(W);
	}
	if (D % 2 == 1) {
		ki();
	} else {
		if (D % 4 == 2) {
			kigu();
		} else {
			gu();
		}
	}


	REP(i, 0, H) {
		cout << s[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 768
s=[]
top=-1
a=list(input().split())
for i in range(len(a)):
    if a[i]=='+':
        s[top-1]=s[top-1]+s[top]
        top-=1
        del s[-1]
    elif a[i]=='-':
        s[top-1]=s[top-1]-s[top]
        top-=1
        del s[-1]
    elif a[i]=='*':
        s[top-1]=s[top-1]*s[top]
        top-=1
        del s[-1]
    else:
        s.append(int(a[i]))
        top+=1
print(s[0])


Measured memory_bytes: 5604
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;

int main() {

	long r; cin >> r;

	cout << 3 * r * r;

}

Measured memory_bytes: 256
/*input
7
abcdbbd
6
2 3 6
1 5 z
2 1 1
1 4 a
1 7 d
2 1 7
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;

void run() {
	int n, i, q;
	cin >> n;
	string str;
	cin >> str;
	cin >> q;
	set<int> s[26];
	for(i=0; i<n; i++) {
		s[str[i]-'a'].insert(i);
	}
	while(q--) {
		int op;
		cin >> op;
		if(op == 1) {	// Update
			cin >> i;
			--i;
			char ch;
			cin >> ch;
			s[str[i]-'a'].erase(s[str[i]-'a'].find(i));
			s[ch-'a'].insert(i);
			str[i] = ch;
		}
		else {	// Query
			int l, r;
			cin >> l >> r;
			--l; --r;
			int count = 0;
			for(i=0; i<26; i++) {
				if(s[i].lower_bound(l) != s[i].end()) {
					auto it = s[i].lower_bound(l);
					if(*it <= r)
						count++;
				}
			}
			cout << count << endl;
		}
	}
}

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


Measured memory_bytes: 24220
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i ;
    cin >> i;
    if(i >= 30)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    // std::vector<double> x;
    // x.push_back(0.0);
    // cout << x.size() << endl;
    // int a, b, c;
    // cin >> a >> b >> c;
    // string s;
    // cin >> s;
    // cout << a+b +c << " " << s<< endl;
    // std::cout << "Hello, World" << std::endl;
    // int i = 0;
    // if( i == 0 )
    // {
    //     std::cout << "say hello!!!" << std::endl;
    // }
    // for(int i = 0 ; i < 10 ; ++i)
    // {
    //     std::cout << i << std::endl;
    // }
    // std::cin>>i;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int ll
#define mpp make_pair
#define endl '\n'
#define ff first 
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()


const int mod = 1e9 + 7;
const int N = 2e5 + 6;
int arr[N];
int cost[N];
int DP[1005][1 << 13];
int n, m;

int f(int idx, int mask)
{
	if(idx == m)
	{
		if(__builtin_popcount(mask) == n) return 0;
		else return 9999999999;
	}
	if(DP[idx][mask] != -1) return DP[idx][mask];
	int ans1 = f(idx + 1, mask | arr[idx]) + cost[idx];
	int ans2 = f(idx + 1, mask);
	return DP[idx][mask] = min(ans1, ans2);
}

void solve()
{
	memset(DP, -1, sizeof(DP));
	cin >> n >> m;
	for(int i = 0; i < m; i++)
	{
		int cost, boxes;
		cin >> cost >> boxes;
		::cost[i] = cost;
		while(boxes--)
		{
			int data;
			cin >> data;
			arr[i] |= (1ll << data);
		}
	}
	int ret = f(0, 0);
	if(ret >= 9999999999) cout << -1;
	else cout << ret;
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif
	solve();
	return 0;
}          

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        int x = sc.nextInt();

        int t = x / 200 - 2;
        System.out.println(8 - t);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32840
#include <algorithm>
#include <chrono>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using llong = long long;
using ullong = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()
#define loop(i, times) for(llong i = 0; i < times; i++)
#define rloop(i, times) for(llong i = times -1; 0 <= i; i--)

std::chrono::system_clock::time_point  start;

void TimeStart(void)
{
	start = std::chrono::system_clock::now();
}

void TimeEnd(void)
{
	auto time = std::chrono::system_clock::now() - start;
	auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(time).count();
	cerr << endl <<msec << " msec" << endl;
}

#endif

struct Box
{
	bool red_;
	llong count_;
};

struct Move
{
	llong x_;
	llong y_;
};

class AGC002B
{
public:
	AGC002B()
	{
		cin >> n_;
		cin >> m_;

		box_collection_.resize(n_);
		for(llong i = 0; i < n_; i++)
		{
			box_collection_[i].red_ = false;
			box_collection_[i].count_ = 1;
		}
		box_collection_[0].red_ = true;

		move_collection_.resize(m_);
		for (llong i = 0; i < m_; i++)
		{
			cin >> move_collection_[i].x_;
			cin >> move_collection_[i].y_;
			move_collection_[i].x_--;
			move_collection_[i].y_--;
		}

		ans_ = 0;
	}
	void Run(void)
	{
		for (const auto& elm_move : move_collection_)
		{
			if (0 < box_collection_[elm_move.x_].count_)
			{
				box_collection_[elm_move.y_].count_++;
				box_collection_[elm_move.x_].count_--;
				if (box_collection_[elm_move.x_].red_)
					box_collection_[elm_move.y_].red_ = true;
			}
			if (box_collection_[elm_move.x_].count_ == 0)
				box_collection_[elm_move.x_].red_ = false;
		}

		for (const auto& elm_box : box_collection_)
		{
			if (elm_box.red_)
				ans_++;
		}

		cout << ans_;
	}
private:
	llong n_;
	llong m_;
	llong ans_;
	vector<Move> move_collection_;
	vector<Box> box_collection_;
};

int main()
{
	AGC002B agc002b;

	TimeStart();
	agc002b.Run();
	TimeEnd();

	return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>

int main(void){
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	int x = b-a;
	int ans=0;
	int i;
	for(i=1;i<=x;i++){
		ans+=i;
	}
	ans -= b;
	printf("%d",ans);
	
	return 0;}

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

const int N=200100;
int a[N],b[N],f[N],g[N],n;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i],b[a[i]]=i;
	for(int i=n;i>1;--i){
		if(!f[i]){
			if(b[i]<b[i-1])f[i-1]=1,g[0]=i;
		}else{
			int u=b[i-1],v=b[i],w=b[g[f[i]-1]];
			if((w<u&&(v<w||v>u))||(u<v&&v<w))f[i-1]=f[i];
			else{
				f[i-1]=f[i]+1;
				g[f[i]]=i;
			}
		}
	}
	cout<<f[1]<<'\n';
	return 0;
}


Measured memory_bytes: 3328
#ABC-136-C
N = int(input())
H = list(map(int, input().split()))
ans = "Yes"

for i in reversed(range(0, N-1)):
    if H[i] == H[i+1] + 1:
        H[i] -= 1
    elif H[i] > H[i+1] + 1:
        ans = "No"
        break

print(ans)

Measured memory_bytes: 15020
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;

int main(){
  int n;
  cin>>n;
  string s;
  map<string, int> mapa;
  for(int i=0; i<n; i++){
    cin>>s;
    sort(s.begin(), s.end());
    mapa[s]++;
  }
  lli contador=0;
  for(auto a:mapa){
    contador+=(1LL*a.second*(a.second-1))/2;
  }
  cout<<contador<<endl;
}


Measured memory_bytes: 11136
#include <stdio.h>
 
using namespace std;
 
int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if((x >= r && x <= W-r) && (y >= r && y <= H-r))
        printf("Yes\n");
    else{
        printf("No\n");
    }
}


Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n), abs_a(n);
    ll ans = 0;
    rep(i, 0, n){
        cin >> a[i];
        abs_a[i] = abs(a[i]);
        ans += abs_a[i];
    }

    rep(i, 0, n-1){
        if(a[i] < 0){
            a[i] = -a[i];
            a[i+1] = -a[i+1];
        }
    }

    if(a[n-1] < 0){
        ans -= 2* *min_element(abs_a.begin(), abs_a.end());
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define mod 1000000007
using namespace std;

int main(){
    int n,k,ans=0,h;

    cin >> n >> k;

    rep(i,1,n){
        cin >> h;
        if(h>=k){
            ans++;
        }
    }

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long 
#define N 1000005
using namespace std;
LL int n,ar[N],sum,a;
char c[N];
pair<int,int> p[N];
int main()
{
	for(int i=1;i<=3;i++)
		cin>>ar[i];
	sort(ar+1,ar+4);
	printf("%lld",ar[1]*ar[2]*(ar[3]%2));
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int a[200000];

int lis_fast2(vector<int> v) { // O(n log n)
  int n = v.size();
  vector<int> A(n,INF);
  int res = 0;
  REP(i,n) {
    int id = upper_bound(ALL(A), v[i]) - A.begin();
    A[id] = v[i];
    res = max(res, id);
  }
  return res + 1;
}

int main() {
  int n;
  while(cin>>n) {
    inputs(a,n);
    vector<int> v;
    REP(i,n) v.push_back(-a[i]);
    int res = lis_fast2(v);
    cout << res << endl;
  }
}


Measured memory_bytes: 1912
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};

vector<LL> a(1<<18);
vector<LL> ans(1<<18,0);
vector<LL> x;
vector<LL> dp(1<<18,LINF);
vector<int> G[1<<18];

void dfs(int u,int v){
    int id = lower_bound(ALL(x), a[u]) - x.begin();
    auto p = lower_bound(ALL(dp), id);
    LL buf = *p;
    *p = id;
    for(auto g:G[u]){
        if(g == v) continue;
        dfs(g, u);
    }
    ans[u] = lower_bound(ALL(dp), LINF) - dp.begin();
    *p = buf;
}


int main(){
    int n;cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        x.pb(a[i]);
    }
    sort(ALL(x));
    x.erase(unique(ALL(x)),x.end());
    for (int i = 0; i < n-1; i++) {
        int u,v;cin >> u >> v;
        u--,v--;
        G[u].pb(v);
        G[v].pb(u);
    }
    dfs(0,0);
    for (int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 37588
#include<stdio.h>
int main()
{
	long long n,m;
	scanf("%lld %lld",&n,&m);
    long long t=m/2;
    if(n>=t)
    printf("%lld\n",t);//t为c一半，s比c的一半多。 
    else
    {
    	t=t-n;//s用完，多余c的一半 
    	t=t/2;//多余的c组成的scc 
    	printf("%lld\n",n+t);
	}
	return 0;
 } 

Measured memory_bytes: 128
#include <bits/stdc++.h>
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; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }


int main() {
    int x; cin >> x;
    if(x == 0) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main (){
    ll n;
    cin >> n;
    bool k[114514];
    ll a;
    ll mi = 10000000000;
    ll ans = 0;
    for (ll i = 0; i < n; i++){
        cin >> a;
        if (a>=0){
            k[i]=true;
        } else {
            k[i]=false;
        }
        mi = min(mi,abs(a));
        ans += abs(a);
    }
    for (ll i = 0; i < n-1;i++){
        if (k[i]==false){
            k[i] = true;
            if (k[i+1]==true) k[i+1]=false;
            else k[i+1]=true;
        }
    }
    if (k[n-1]==false){
        cout << ans-mi*2 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}



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

int main() {
  long int nI, nO, nJ, nL, gomi;
  cin >> nI >> nO >> gomi >> nJ >> nL >> gomi >> gomi;
  int oddnum = nI % 2 + nJ % 2 + nL % 2;
  if (oddnum > 1 && nI * nJ * nL != 0) oddnum = 3 - oddnum;
  cout << nI + nO + nJ + nL - oddnum << endl;
  return 0;
}


Measured memory_bytes: 256
def bubblesort(n,l):
  flag=True
  m=0
  c=0
  for j in range(n):
    for i in range(n-1,m,-1):
      if int(l[i])<int(l[i-1]):
        l[i],l[i-1]=l[i-1],l[i]
        
        c+=1
    m+=1
  print(" ".join(l))
  print(c)
n=int(input())
l=list(input().split())
bubblesort(n,l)


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


vector < pair <int, int> > edge;

int main() {
        int n; cin >> n;
        int bad = n - (n & 1);
        for(int i = 1; i <= n; i++) {
                for(int j = i + 1; j <= n; j++) {
                        if(j != bad) {
                                edge.push_back({i, j});
                        }
                }
                --bad;
        }
        cout << edge.size() << endl;
        for(auto x: edge) {
                cout << x.first <<  ' ' << x.second << endl;
        }
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int n;
	cin >> n;
	cout << "ABC" << n << endl;

} 

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int n;
    cin >> n;
    V<int> w(n), s(n), v(n), p(n);
    rep(i, n) {
        cin >> w[i] >> s[i] >> v[i];
        p[i] = i;
    }
    sort(ALL(p), [&](int a, int b) { return w[a] + s[a] < w[b] + s[b]; });
    V<ll> dp(20001, 0);
    for(int i : p) {
        int x = min(20000 - w[i], s[i]);
        FORR(j, x + 1) chmax(dp[j + w[i]], dp[j] + v[i]);
    }
    ll ans = 0;
    for(ll x : dp)
        chmax(ans, x);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+10;

int main(){
	int n;
	cin>>n;
	string a;
	cin>>a;
	int ans=0;
	for(int i=0;i<=a.size()-3;i++)
	{
		if(a[i]=='A'&&a[i+1]=='B'&&a[i+2]=='C')ans++;
	}
cout<<ans;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n+1];
        for (int i=1;i<=n;i++)a[i]=sc.nextInt();
        int count = 0;
        int[] ANS = new int[n+1];
        HashSet<Integer> ans = new HashSet<>();
        for (int i=n;i>0;i--){
            if (2*i>n){
                if (a[i]==1){
                    count++;
                    ans.add(i);
                    ANS[i]=1;
                }else ANS[i]=0;
            } else {
                int ins = 2*i;
                int total = 0;
                while (ins<=n){
                    total+=ANS[ins];
                    ins+=i;
                }
                if (total%2!=a[i]){
                    count++;
                    ans.add(i);
                    ANS[i]=1;
                }else ANS[i]=0;
            }
        }
        System.out.println(count);
        for (int i : ans)System.out.print(i+" ");
        System.out.println();
    }
}


Measured memory_bytes: 67072
#include<stdio.h>
int main()
{
    int i,j;
    char arr[100][100];
    scanf("%s",arr[0]);
    for(i=0;i<strlen(arr[0]);i++)
    {
        if(arr[0][i]==44)
        {
            printf(" ");
        }
        else
        {
            printf("%c",arr[0][i]);
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1<<29;
typedef long long ll;

int dp[100][2][100];//dp[keta][未満である][0でない数の個数]

struct UnionFind {
  vi parent;
  UnionFind(int N) : parent(N) {
    rep(i, N)parent[i] = i;
  }

  int getRoot(int child){
    return ((parent[child] == child) ? child : parent[child] = getRoot(parent[child]));
  }
  void unite(int x, int y){
    int root_x = getRoot(x);
    int root_y = getRoot(y);
    if(root_x == root_y)return;
    parent[root_x] = parent[root_y];
  }
  bool isSame(int x, int y){
    return getRoot(x) == getRoot(y);
  }
};
int N, M;
vivi G(10);
bool visited[100];

int dfs(int i){
    int ret = 0;
    bool flg = true;
    rep(i, N)if(!visited[i])flg = false;
    if(flg)return 1;
    for(int v : G[i]){
        if(visited[v])continue;
        visited[v] = true;
        ret += dfs(v);
        visited[v] = false;
    }
    return ret;
}

int main(){
    cin >> N >> M;
    rep(i, M){
        int a, b;cin >> a >> b;
        --a;--b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    visited[0] = true;
    cout << dfs(0);
}


Measured memory_bytes: 256