akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define MOD 998244353

using namespace std;

int main()
{
    IOS;
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
}
 

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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define REP64(i, s,  n) for(int64 i = s;i < (n);i++)
#define INF 999999999
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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

//---------------------------------------------------------------
//---------------------------------------------------------------

string S, T;

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

	cin >> S >> T;
	int j;
	for(int i = S.size() - T.size(); i >= 0; i--) {
		for(j=0; j < T.size(); j++) {
			if(S[i + j] != '?' && S[i + j] != T[j]) break;
		}
		if(j == T.size()) {
//		    cout << "[" << S << "] i=" << i << "  T.size()=" << T.size() << endl;
			S.replace(i, T.size(), T);
//		    cout << " --> [" << S << "]" << endl;
			REP(j, 0, S.size())
				if(S[j] == '?')	S[j] = 'a';
			cout << S << endl;
			return 0;
		}
	}
	cout << "UNRESTORABLE" << endl;
	
	return 0;
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n, m;
LL a[101010];

int main(){
    cin >> n >> m;
    REP(i, n)cin >> a[i];
    priority_queue<LL> pq;
    REP(i, n)pq.push(a[i]);
    while(m > 0){
        m--;
        int p = pq.top();
        pq.pop();
        pq.push(p / 2);
    }
    LL ans = 0;
    while(!pq.empty()){
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 2168
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define M 4000
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,less_equal<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

int main() 
{
    FAST;
    char ch;
    cin>>ch;
    ll x=ch-'A';
    if(x<=26)
        cout<<'A';
    else
        cout<<'a';
    subt;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  int m;
  cin >> m;
  vector<string> t(m);
  rep(i, m) cin >> t[i];
  
  map<string, int> b, r;
  rep(i, n) ++b[s[i]];
  rep(i, m) ++r[t[i]];

  int x = 0;
  rep(i, n) x = max(x, b[s[i]] - r[s[i]]);
  rep(i, m) x = max(x, b[t[i]] - r[t[i]]);
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int N;cin>>N;
    cout<<N*800-(N/15)*200<<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;

ll inf = 1e9 + 7;

ll pw(ll x, ll y) {
    if (y == 0) return 1;
    else if (y == 1) return x % inf;
    else if (y % 2 == 0)  {
        ll k = pw(x, y / 2);
        return k * k % inf;
    }
    else {
        ll k = pw(x, y / 2);
        return k * k % inf * x % inf;
    }
}
 
ll dv(ll x, ll y) {
    return x * pw(y, inf - 2) % inf;
}

ll comb(ll p, ll q) {
    ll v = 1;
    for (int i = 1; i <= q; i++) {
        v = (v * (p - i + 1)) % inf;
        v = (v * dv(1, i)) % inf;
    }
    return v;
}

int main() {
    ll x, y;
    cin >> x >> y;

    ll b = (2 * x - y) / 3, a = x - 2 * b;
    if ((2 * x - y) % 3 == 0 && a >= 0 && b >= 0) {
        cout << comb(a + b, a) << endl;
    }
    else {
        cout << 0 << endl;
    }

}


Measured memory_bytes: 256
"use strict";
function I(s,f){this._s=s.split("\n");this._c=0;this._l=0;this._f=f||Number}I.prototype.a=function(){var l=this._s[this._l];if(!l)return;var t=l.trim().split(" ");var a=t[this._c];this._c++;if(t.length===this._c){this._c=0;this._l++}return this._f(a)};I.prototype.l=function(){var l=this._s[this._l];if(!l)return;this._c=0;this._l++;return l.split(" ").map(this._f)};module.exports=I;

function main(input) {
  const o = new I(input, String);

  const S = o.a();

  let largest = 0;
  let count = 0;
  for (let i = 0; i < S.length; i++) {
    let cur = S[i];
    if ("ATCG".includes(cur)) {
      count += 1;
    } else {
      if (count > largest) {
        largest = count;
      }
      count = 0;
    }
  }

  if (count > largest) {
    largest = count;
  }

  console.log(largest);
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n;
  cin >> n;
  int cnt=0;
  if(n > 2){
    while(n>2){
      n = n - 3;
      cnt++;
    }
    cout << cnt << endl;
  }
  else cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int now = 0;
    int nx = 0,ny = 0;
    rep(i,n) {
        int t,x,y;
        cin >> t >> x >> y;
        int d = abs(x-nx)+abs(y-ny);
        if(t-now < d) {
            cout << "No" << endl;
            return 0;
        }
        if((t-now-d)%2 != 0) {
            cout << "No" << endl;
            return 0;
        }
        now = t;
        nx = x;
        ny = y;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const int N_MAX = 200010;
ll Per[N_MAX] = {}; // n!
ll Per_inv[N_MAX] = {}; //(n!)^-1

ll nCr(ll n, ll r){
    if(n<r) return 0;
 
    if (n == r || r == 0)
        return 1;
    else
        return Per[n] * Per_inv[n-r] % mod * Per_inv[r] % mod;  
}
 
// a^b mod p
ll mod_pow(ll a, ll b){
    if(b==0) return 1;
 
    // 肩が奇数
    if(b%2==1){
        return a * mod_pow(a, b-1) % mod;
    }
    else{
        return mod_pow(a*a % mod, b/2) % mod;
    }
}

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

    // input
    ll H, W, A, B;
    cin >> H >> W >> A >> B;

    // nCr高速化準備
    Per[1] = 1;
    FOR(i, 2, N_MAX){
        Per[i] = i * Per[i-1] % mod;
    }
    Per_inv[1] = 1;
    FOR(i, 2, N_MAX){
        Per_inv[i] = mod_pow(Per[i], 1000000005);
    }

    ll sum = 0;
    FOR(b, B, W){
        sum += nCr(H-A-1+b, b) * nCr(A-1+W-1-b, A-1);
        sum %= mod;
    }

    p(sum);
    
    return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n);
    map<int,int> even,odd;
    rep(i,n){
        cin>>a[i];
        if(i%2) odd[a[i]]++;
        else even[a[i]]++;
    }
    vector<Pi> cnt1,cnt2;
    for(auto itr:even) cnt1.push_back(Pi(itr.se,itr.fi));
    for(auto itr:odd) cnt2.push_back(Pi(itr.se,itr.fi));
    cnt1.push_back(Pi(0,0));
    cnt2.push_back(Pi(0,0));
    sort(begin(cnt1),end(cnt1),greater<Pi>());
    sort(begin(cnt2),end(cnt2),greater<Pi>());
    if(cnt1[0].se!=cnt2[0].se){
        cout<<n-cnt1[0].fi-cnt2[0].fi<<endl;
    }else{
        cout<<min(n-cnt1[0].fi-cnt2[1].fi,n-cnt1[1].fi-cnt2[0].fi)<<endl;
    }
}

Measured memory_bytes: 6524
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    cs
    ll a,b,c,k,t=0;cin>>a>>b>>c>>k;
    if(k>=a) {t+=a;k-=a;}
    else bye(k)
    if(k>=b) k-=b;
    else bye(t)
    if(k) t-=k;
    cout<<t; 
}

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

#define INF int(1e9)

int n, m, ans;
int c[21], dp[50001];
/*
int c[21], memo[50001];
int solve(int v) {
    if (v < 0) return INF;
    if (v == 0) return 0;
    if (memo[v] != INF) return memo[v];

    int ret = INF;

    for (int i = 0; i < m; ++i) {
        ret = min(ret, solve(v - c[i]) + 1);
    }

    return memo[v] = ret;
}
*/

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) cin >> c[i];

    //ans = solve(n);

    fill(dp, dp + 50001, INF);
    dp[0] = 0;

    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (i - c[j] >= 0) {
                dp[i] = min(dp[i], dp[i - c[j]] + 1);
            }
        }
    }

    //cout << ans << endl;
    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 3284
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.h"
#include <set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N;
string S;





int main()
{

	cin >> N >> S;
	if(N%2==1){
		cout << "No";
		return 0;
	}

	REP(i,N/2){
		if(S[i] != S[i+N/2]){
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";



}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define MOD 998244353

ll power(int x, int y) {
    if (y == 1) return x;
    ll p = power(x, y >> 1);
    if (y & 1) return p * p % MOD * x % MOD;
    else return p * p % MOD;
}

int main() {
    ll N, a[300], sum = 0;
    cin >> N;
    REP(i, N) {
        cin >> a[i]; 
        sum += a[i];
    }
    
    vector<ll> dp1(sum + 1, 0), dp2(sum + 1, 0);
    dp1[0] = 1, dp2[0] = 1;
    REP(i, N) RREP(j, sum + 1) {
        if (dp1[j] > 0 && j + a[i] <= sum) {
            dp1[j + a[i]] += dp1[j];
            dp1[j + a[i]] %= MOD;
            dp1[j] *= 2;
            dp1[j] %= MOD;
        }
        if (dp2[j] > 0 && j + a[i] <= sum) {
            dp2[j + a[i]] += dp2[j];
            dp2[j + a[i]] %= MOD;
        }
    }
    
    ll s1 = 0, s2 = 0;
    FOR(i, (sum + 1) / 2, sum + 1) 
        s1 = (s1 + dp1[i]) % MOD;
    if (sum % 2 == 0) 
        s2 = dp2[sum / 2];

    ll ans = (power(3, N) - (s1 - s2) * 3) % MOD;
    ans = (ans + MOD) % MOD;
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll n, k;
    cin >> n >> k;
    vector<pair<int, int>> ab;
    for(int i = 0; i < n; i++)
    {
        ll a, b;
        cin >> a >> b;
        ab.push_back(make_pair(a, b));
    }
    sort(ab.begin(), ab.end());
    ll cnt=0;
    for(int i = 0; i < ab.size(); i++)
    {
        cnt += ab[i].second;
        if(cnt>=k){
            cout << ab[i].first << endl;
            return 0;
        }
    }
    
    
}


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

int main(){
  int N; cin >> N;
  
  int pt = 0, px = 0, py = 0;
  bool cmp = true;
  for(int i = 0; i < N; i++){
    int t, x, y; cin >> t >> x >> y;
    int dt = t - pt, dx = abs(x - px), dy = abs(y - py);
    
    if(dt < dx + dy) cmp = false;
    if( (dt ^ (dx + dy)) & 1) cmp = false; 
    if(!cmp) break;
    pt = t, px = x, py = y;
  }
  
  if(cmp) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int N=100;
 
int x[N],y[N];
vector <pair <int, int>> q;
 
int main(){
	int n; cin>>n;
	for (int i=1;i<=n;i++)
		scanf("%d%d",x+i,y+i);
	for (int i=1;i<=n;i++)
		for (int j=i+1;j<=n;j++){
			int tx=x[i]-x[j],ty=y[i]-y[j];
			if (tx<0) tx=-tx,ty=-ty;
			else if (tx==0) ty=abs(ty);
			q.push_back(make_pair(tx,ty));
		}
	sort(q.begin(),q.end());
	pair <int, int> last(0,0);
	int cnt=0,s=0;
	for (auto &val: q){
		if (val==last) cnt++;
		else cnt=1;
		last=val; s=max(s,cnt);
	}
	cout<<n-s<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
        "fmt"
)

type node struct {
        n   int
        cnt int
}

func main() {
        var n int
        fmt.Scan(&n)

        m := make([]int, n+1)
        for i := range m {
                m[i] = 1 << 30
        }
        m[0] = 0

        v := []int{1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049}
        for i := range m {
                for _, w := range v {
                        if i+w <= n && m[i]+1 < m[i+w] {
                                m[i+w] = m[i] + 1
                        }
                }
        }
        fmt.Println(m[n])
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
int n,m,a[1000005],b[1000005],sum[1000005];
string s;
void build(int x,int l,int r){
	if(l==r){
		b[x]=a[l],sum[x]=1<<b[x];
		return ;
	}
	int mid=l+r>>1;
	build(x*2,l,mid);
	build(x*2+1,mid+1,r);
	sum[x]=sum[x*2]|sum[x*2+1];
}
void gao(int x,int l,int r,int l1,int w){
	if(l==l1 and r==l1){
		b[x]=w,sum[x]=1<<w;
		return ;
	}
	int mid=(l+r)>>1;
	if(l1<=mid)gao(x*2,l,mid,l1,w);
	else gao(x*2+1,mid+1,r,l1,w);
	sum[x]=sum[x*2]|sum[x*2+1];
}
int query(int x,int l,int r,int l1,int r1){
	if(l>=l1 and r<=r1)return sum[x];
	int res=0,mid=(l+r)>>1;
	if(l1<=mid)res|=query(x<<1,l,mid,l1,r1);
	if(r1>mid)res|=query(x<<1|1,mid+1,r,l1,r1);
	return res;
}
int main(){
	n=read();
	cin >> s;
	for(int i=0;i<s.size();i++)
		a[i+1]=s[i]-'a'+1;
	build(1,1,n);
	m=read();
	while(m--){
		int ab=read(),x=read(),y;
		if(ab==1){
			y=getchar();
			while(y==' ')y=getchar();
			y-='a'-1;
			gao(1,1,n,x,y);
		}
		else{
			y=read();
			printf("%d\n",__builtin_popcount(query(1,1,n,x,y)));
		}
	}
	return 0;
}

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

using namespace std;

const int MOD = int(1e9) + 7;
int add(int x, int y)
{
    return (x + y) % MOD;
}
int sub(int x, int y)
{
    return add(x, MOD - y);
}
int mul(int x, int y)
{
    return (x * 1ll * y) % MOD;
}
int main()
{
    int n, k;
    cin >> n >> k;
    int arr[n];
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    vector<int> presum(k + 1, 0);
    vector<vector<int>> dp(k + 1, vector<int>(n, 0));
    dp[0][0] = presum[0] = 1;
    for (int i = 1; i <= k; i++)
    {
        if (i <= arr[0])
            dp[i][0] = 1;
        else
            dp[i][0] = 0;
        presum[i] = add(presum[i - 1], dp[i][0]);
    }
    for (int i = 1; i < n; i++)
    {
        for (int j = 0; j <= k; j++)
        {
            dp[j][i] = presum[j];
            if (j - arr[i] - 1 >= 0)
                dp[j][i] = sub(dp[j][i], presum[j - arr[i] - 1]);
        }
        presum[0] = dp[0][i];
        for (int j = 1; j <= k; j++)
            presum[j] = add(presum[j - 1], dp[j][i]);
    }
    cout << dp[k][n - 1] << "\n";
    return 0;
}


Measured memory_bytes: 43648
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //
        Scanner sc = new Scanner(System.in);
        List<Integer> l1 = new ArrayList<>();
        List<Integer> l2 = new ArrayList<>();
        List<Integer> l3 = new ArrayList<>();
        for (int i = 0;i<3;++i) l1.add(sc.nextInt());
        for (int i = 0;i<3;++i) l2.add(sc.nextInt());
        for (int i = 0;i<3;++i) l3.add(sc.nextInt());
        int n = sc.nextInt();
        List<Integer> b = new ArrayList<>();
        for (int i = 0;i<n;++i) b.add(sc.nextInt());

        boolean tf[][] = new boolean[3][3];
        for (int i=0;i<3;++i)
        {
            for (int j = 0;j<3;++j)
            {
                tf[i][j] = false;
            }
        }

        for (int i:b)
        {
            if (l1.contains(i))
            {
                tf[0][l1.indexOf(i)] = true;
            }else if (l2.contains(i))
            {
                tf[1][l2.indexOf(i)] = true;
            }else if (l3.contains(i))
            {
                tf[2][l3.indexOf(i)] = true;
            }
        }

        if (tf[0][0] && tf[0][1] && tf[0][2]) System.out.println("Yes");
        else if (tf[1][0] && tf[1][1] && tf[1][2]) System.out.println("Yes");
        else if (tf[2][0] && tf[2][1] && tf[2][2]) System.out.println("Yes");
        else if (tf[0][0] && tf[1][0] && tf[2][0]) System.out.println("Yes");
        else if (tf[0][1] && tf[1][1] && tf[2][2]) System.out.println("Yes");
        else if (tf[0][2] && tf[1][2] && tf[2][2]) System.out.println("Yes");
        else if (tf[0][0] && tf[1][1] && tf[2][2]) System.out.println("Yes");
        else if (tf[0][2] && tf[1][1] && tf[2][0]) System.out.println("Yes");
        else System.out.println("No");

        sc.close();
    }
}

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

using namespace std;
using ll=long long;

void solve() {
    ll n;cin >> n;
    int res = 1;
    for (ll d = 2; d*d <= n; d++) {
        if (n % d == 0) {
            ll x = n;
            while (x % d == 0) {
                x /= d;
            }
            if (x % d == 1) res++;
        }
    }
    res += (n>2);
    for (ll d = 2; d*d <= n-1; d++) {
        if ((n-1) % d == 0) {
            res++;
            if (d*d != n-1)res++;
        }
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	int A,B;

	public void solve() {
		A = nextInt();
		B = nextInt();

		out.println(A + B < 10 ? A + B : "error");
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 21076
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

struct edge {
	ll u;
	ll v;
	ll cost;
	edge() {}
	edge(ll u, ll v, ll c) :u(u), v(v), cost(c) {}
};

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	ll V, E; cin >> V >> E;
	vector<vector<edge>> G(V);
	for (int i = 0; i < E;i++) {
		ll s, t, d; cin >> s >> t >> d;
		G[s].emplace_back(edge(s, t, d));
	}
	/* dp[i][j] := ?????????j???????????¨???, bit???i??????????????°????????§???????????????????????¢ */
	vector<vector<ll>> dp(1 << V, vector<ll>(V, INF));
	dp[0][0] = 0;
	for (int i = 0; i < (1 << V);i++) {
		for (int j = 0; j < V;j++) {
			for (auto e : G[j]) {
				if (!((i >> e.v) & 1)) {
					dp[i | (1 << e.v)][e.v] = min(dp[i | (1 << e.v)][e.v], dp[i][e.u] + e.cost);
				}
			}
		}
	}
	ll ret = dp[(1 << V) - 1][0];
	if (ret == INF)ret = -1;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 7928
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
    int tmp = 0;
    int count = 0;
    boolean allzero = true;
    for(int i=0;i<N;i++){
      int nextNum = sc.nextInt();
      tmp = tmp^nextNum;
      count = (count+1)%3;
      if(nextNum!=0)allzero = false;
    }
    if((count==0&&tmp==0) || allzero){
        System.out.println("Yes");
    }else{
      System.out.println("No");
    }
	}
}


Measured memory_bytes: 48040
x = input().split()

x_int = [int(i) for i in x]
d = x_int[0]//x_int[1]
r = x_int[0] % x_int[1]
f = (x_int[0]) / (x_int[1])
print('{0} {1} {2:f}'.format(d,r,f))

Measured memory_bytes: 7660
#include<iostream>

using namespace std;

int main()
{
    int h,w,n;
    int i;
    cin>>h;
    cin>>w;
    int b[h][w];
    cin>>n;
    int a[n];
    int c[h*w];
    for(i=0;i<n;++i)
    {
        cin>>a[i];
    }
    int j=0;
    for(i=0;i<n;++i)
    {
        while(a[i]!=0)
        {
            c[j]=i+1;
            ++j;
            --a[i];
        }
    }
    for(i=0;i<h;i=i+2)
    {
        for(j=0;j<w;++j)
        {
            b[i][j]=c[i*w+j];
        }
    }
    for(i=1;i<h;i=i+2)
    {
        for(j=0;j<w;++j)
        {
            b[i][w-1-j]=c[i*w+j];
        }
    }
    for(i=0;i<h;++i)
    {
        for(j=0;j<w;++j)
        {
            cout<<b[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}


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


// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef complex<int> ci;
typedef complex<double> cd;
typedef complex<long double> cld;

// macros
#define rep(i, a, b) for(int i=a; i<b; i++)
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define tr(c, it) for(auto it=(c).begin(); it!=c.end(); it++)
#define pb push_back
#define mp make_pair
#define bitcount __builtin_popcount
#define ispresent(c, x) ((c).find(x) != (c).end())
#define watch(x) cout<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// template functions
template <typename T>
inline void printV(vector<T>& a) { rep(i, 0, sz(a)) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printV(vector<T>& a, int n) { rep(i, 0, n) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a)
{
	rep(i, 0, sz(a)) {
		printV(a[i]);
	}
	cout<<"\n";
}

template <typename T>
inline void clearVV(vector<vector<T>>& a)
{
	for(auto& x:a) {
		x.clear();
	}
	a.clear();
}
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val)
{
	for(int i=0; i<sz(a); i++) {
		for(int j=0; j<sz(a[i]); j++) {
			a[i][j]=val;
		}
	}
}


// constants
const long double eps = 1e-9;
const ll inf = 1e17;
const int modn = 1e9+7;
const int MAX = 1e5;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
	int n, W;
	cin>>n>>W;
	vector<ll> w(n+1);
	vector<ll> val(n+1);
	ll maxval=0;
	for(int i=1; i<=n; i++) {
		cin>>w[i]>>val[i];
		maxval+=val[i];
	}
	
	vector<vector<ll>> dp(n+1, vector<ll>(maxval+1));
	for(int i=0; i<=n; i++) {
		dp[i][0]=0;
	}
	for(ll i=1; i<=maxval; i++) {
		dp[0][i]=inf;
	}
	for(int j=0; j<=maxval; j++) {
		for(int i=1; i<=n; i++) {
			ll ans1=dp[i-1][j];
			ll ans2=inf;
			if(j>=val[i])
				ans2=dp[i-1][j-val[i]]+w[i];
			dp[i][j]=min(ans1, ans2);
		}
	}
	
	//~ printVV(dp);
	
	ll ans=0;
	for(int i=1; i<=n; i++) {
		for(int j=0; j<=maxval; j++) {
			if(dp[i][j]<=W) {
				ans=j;
			}
		}
	}
	cout<<ans<<"\n";
    return 0;
}



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

ll res = 0;
void dfs(string s, ll sum) {
  for (int i = 0; i < s.size() - 1; ++i) {
    dfs(s.substr(i + 1), sum + stoll(s.substr(0, i + 1)));
  }
  res += stoll(s) + sum;
}

int main() {
  string s;
  cin >> s;
  dfs(s, 0);
  cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(x, n)              for (int x = 0; x < n; x++)
#define forr(x, n)              for (int x = n; x >= 0; x--)
#define fore(x, a, b, c)        for (int x = a; x <= b; x += c)
#define forre(x, a, b, c)       for (int x = a; x >= b; x -= c)
#define clr                     cin.ignore(numeric_limits<streamsize>::max(), '\n')
#define all(container)          (container).begin(), (container).end()
#define rall(container)         (container).rbegin(), (container).rend()
#define tracev(v)               for (auto& x: v) cerr << x << " "; cerr << '\n';
#define trace2v(v)              for (auto& x: v) cerr << x.fi << " - " << x.se << '\n'; cerr << '\n';
#define FILL(x, val)            memset(x, val, sizeof(x))
#define pb                      push_back
#define eb                      emplace_back
#define fi                      first
#define se                      second
#define mod                     (int)1000000007
#define INF                     (int)0x3f3f3f3f

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }  

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

int main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifndef ONLINE_JUDGE
    freopen("errlog", "w", stderr);
#endif
    ll n, k; cin >> n >> k;
    map<ll, ll> cnt;
    forn(i, n) {
        ll num, times; cin >> num >> times;
        cnt[num] += times;
    }
    for (auto& x: cnt) {
        if (x.se >= k) {
            cout << x.fi << '\n';
            break;
        } else k -= x.se;
    }
    return 0;
}

Measured memory_bytes: 4224
def slove():
    import sys
    input = sys.stdin.readline
    a, b, c = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    if a == b == c:
        if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
            print(-1)
        else:
            print(0)
    else:
        while True:
            if a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
                a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2
                cnt += 1
            else:
                print(cnt)
                exit()


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int n = sc.nextInt();
        for(int i = 0; i < n; i++){
            h -= sc.nextInt();
        }
        if(h <= 0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 48852
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
  int s=0,a[5];
  for(int i=0;i<5;++i){
    cin>>a[i];
    if(i){
      if(a[i]%10==0||a[i]%10>a[i-1]%10)swap(a[i],a[i-1]);
    }
  }
  for(int i=0;i<5;++i){
    if(i==4){s+=a[i];break;}
    if(a[i]%10)a[i]+=10;
    a[i]/=10;
    s+=a[i]*10;
  }
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <iomanip>
#include <limits>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;

int main() {
	double r;
	cin >>r;
	cout << fixed<< setprecision(15)<< r*r*M_PI <<" "<<2*r*M_PI<<"\n";
	return 0;
}



Measured memory_bytes: 3232
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> a(N); rep(i, 0, N) {
		cin >> a[i];
	}
	int b[8] = { 400,800,1200,1600,2000,2400,2800,3200 };
	bool f[8] = {};
	int ans = 0, r = 0;
	rep(i, 0, N) {
		rep(j, 0, 8) {
			if (a[i] < b[j]) {
				f[j] = true;
				break;
			}
		}
		if (a[i] >= 3200) {
			r++;
		}
	}
	rep(j, 0, 8)
		if (f[j])
			ans++;
	if (ans == 0 && r) {
		cout << 1 << " " << r << endl;
	}
	else
		cout << ans << " " << ans + r << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

enum Face
{
	TOP = 0,
	FRONT = 1,
	RIGHT = 2,
	LEFT = 3,
	BACK = 4,
	BOTTOM = 5,
};

class Dice
{
private:
	vector<int> f;

	void alignTopFront(int top, int front)
	{
		if (top != f[TOP])
		{
			if (top == f[FRONT])
			{
				roll("N");
			}
			else if (top == f[RIGHT])
			{
				roll("W");
			}
			else if (top == f[LEFT])
			{
				roll("E");
			}
			else if (top == f[BACK])
			{
				roll("S");
			}
			else if (top == f[BOTTOM])
			{
				roll("NN");
			}
			else
			{

			}
		}
		if (front == f[FRONT])
		{

		}
		else if (front == f[RIGHT])
		{
			roll("WSE");
		}
		else if (front == f[LEFT])
		{
			roll("ESW");
		}
		else if (front == f[BACK])
		{
			roll("WSSE");
		}
		else
		{

		}
	}

public:
	Dice()
	{
		f.resize(6, 0);
	}

	Dice(vector<int> &fi)
	{
		f.resize(6, 0);
		copy(fi.begin(), fi.end(), f.begin());
	}

	void roll(string cmd)
	{
		int tmp;
		for (int i = 0; i < cmd.size(); i++)
		{
			switch (cmd[i])
			{
			case 'E':
				tmp = f[TOP];
				f[TOP] = f[LEFT];
				f[LEFT] = f[BOTTOM];
				f[BOTTOM] = f[RIGHT];
				f[RIGHT] = tmp;
				break;
			case 'N':
				tmp = f[TOP];
				f[TOP] = f[FRONT];
				f[FRONT] = f[BOTTOM];
				f[BOTTOM] = f[BACK];
				f[BACK] = tmp;
				break;
			case 'S':
				tmp = f[TOP];
				f[TOP] = f[BACK];
				f[BACK] = f[BOTTOM];
				f[BOTTOM] = f[FRONT];
				f[FRONT] = tmp;
				break;
			case 'W':
				tmp = f[TOP];
				f[TOP] = f[RIGHT];
				f[RIGHT] = f[BOTTOM];
				f[BOTTOM] = f[LEFT];
				f[LEFT] = tmp;
				break;
			default:
				break;
			}
		}
	}

	bool isIdenticalTo(Dice d)
	{
		for (int i = 0; i < 6; i++)
		{
			for (int j = 0; j < 6; j++)
			{
				if (f[i] != d.f[j])
				{
					this->alignTopFront(f[i], d.f[j]);
					d.alignTopFront(f[i], d.f[j]);
					if (this->f == d.f)
					{
						return true;
					}
				}
			}
		}
		return false;
	}
};

int main()
{
	int n;
	cin >> n;
	vector<int> fi(6);
	vector<Dice> d(n);
	bool alldif = true;
	for (int i = 0; i < 6; i++)
	{
		cin >> fi[i];
	}
	d[0] = Dice(fi);
	for (int i = 1; i < n; i++)
	{
		for (int j = 0; j < 6; j++)
		{
			cin >> fi[j];
		}
		d[i] = Dice(fi);
		for (int j = 0; j < i; j++)
		{
			alldif &= !d[j].isIdenticalTo(d[i]);
		}
		if (alldif == false)
		{
			break;
		}
	}
	if (alldif)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3236
n=int(input())
a=sorted(list(map(int,input().split())),reverse=True)
x,y=0,0
def groupby(a):
    a2=[[a[0],1]]
    for i in range(1,len(a)):
        if a2[-1][0]==a[i]:
            a2[-1][1]+=1
        else:
            a2.append([a[i],1])
    return a2
b=groupby(a)
l=len(b)
for i in range(l):
    if x==0:
        if b[i][1]>=4:
            x,y=b[i][0],b[i][0]
        elif b[i][1]>=2:
            x=b[i][0]
    elif y==0:
        if b[i][1]>=2:
            y=b[i][0]
    else:
        break
print(x*y)

Measured memory_bytes: 17424
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << "\t";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << "\t"; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<string>

using namespace std;
string s;
int n;
const int MOD = 1000000007;
int dp[3000][3001];

int main()
{
    cin >> n >> s;
    REP(i, n) {
        dp[n - 1][i] = 0;
    }
    dp[n - 1][0] = 1;
    for (int i = n - 2; i >= 0; --i) {
        int rest = n - (i + 1);
        int sm = 0;
        if (s[i] == '<') {
            for (int less = rest; less >= 0; --less) {
                sm = (sm + dp[i + 1][less]) % MOD;
                dp[i][less] = sm;
            }
        } else {
            REP(less, rest + 1) {
                dp[i][less] = sm;
                sm = (sm + dp[i + 1][less]) % MOD;
            }
        }
    }
    int ans = 0;
    for (int less = 0; less <= n - 1; ++less) {
        ans = (ans + dp[0][less]) % MOD;
    }
    // REP(i, n) {
    //     cout << i << ": "; DA(dp[i], n);
    //     if (i < n - 1) cout << s[i] << endl;
    // }
    cout << ans << endl;
}


Measured memory_bytes: 35200
import java.util.*;
import java.lang.Math; 


public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int count = scan.nextInt();
		int[] values = new int[count];
		for(int i = 0; i<count; i++) {
			values[i] = scan.nextInt();
		}
		
		// root
		//System.out.println("node 1: key = " + values[0] + ", ");
		for(int i=1; i<=count; i++) {
			System.out.print("node " + (i) + ": key = " + values[i-1] + ", ");
			if(i > 1) {
				int parentpos = (int) Math.sqrt((i));
				System.out.print("parent key = " + values[(i/2)-1] + ", ");
			}
			
			//int levels = (int) Math.ceil(Math.sqrt(17));
			int lchild = 2*i;
			int rchild = 2*i + 1;
			if(lchild <= count) {
				System.out.print("left key = " + values[lchild-1] + ", ");
			}
			if(rchild <= count) {
				System.out.print("right key = " + values[rchild-1] + ", ");
			}
			//if(i<count) {
			System.out.println("");
			//}
		}
		
	}
}



Measured memory_bytes: 27340
N = gets.to_i
A1 = gets.chomp.split.map(&:to_i)
A2 = gets.chomp.split.map(&:to_i)

max = 0
N.times do |i|
    sum = A1[0..i].inject(:+) + A2[i...N].inject(:+)
    max = sum if max < sum
end

print max

Measured memory_bytes: 1788
#  --*-coding:utf-8-*--

import math

def main():
    N = int(input())
    
    N2 = int(math.sqrt(N))

    for k in range(N2, 0, -1):
        if N%k == 0:
            print(N//k + k - 2)
            return


if __name__ == '__main__':
    main()


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

int main(){
	int n;
	cin>>n;
	
	int v[20],c[20];
	REP(i,n) cin>>v[i];
	REP(i,n) cin>>c[i];
	
	int sum=0;
	REP(i,n){
		int val=v[i]-c[i];
		if(val>=0) sum+=val;
	}
	
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*};
use superslice::*;
fn main() {
    input! {
        n: usize, m: usize,
        ai: [i64; m],
    }

    let sum = ai.iter().sum::<i64>();
    if sum > n as i64 {
        println!("{}", -1);
    } else {
        println!("{}", n as i64 - sum);
    }
}


Measured memory_bytes: 2260
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld n,i,p,k,m,l,x,y;
    cin>>n;
    set<lld>s;
    rep(i,0,n)
    {
        cin>>x;
        if(s.find(x)!=s.end())
        {
            s.erase(x);
        }
        else
            s.insert(x);
    }
    cout<<s.size();
}





Measured memory_bytes: 4992
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> H(N);
    for(auto& in:H) cin >> in;
    ll maxH = 0;
    for(int i = 0; i < N;i++){
        res += maxH <= H[i];
        maxH = max(maxH,H[i]);
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    int inning;
    cin >> inning;
    for(int i=0;i<inning;i++){
        int point,runner,out;
        point=runner=out=0;
        while(out!=3){
            char c[8];
            cin >> c;
            if(c[0]=='O')
                out+=1;
            if(c[0]=='H' && c[1]=='I'){
                if(runner==3)
                    point+=1;
                else
                    runner+=1;
            }
            if(c[0]=='H' && c[1]=='O'){
                point +=runner+1;
                runner =0;
            }
        }
        cout << point << endl;
    }
}

Measured memory_bytes: 1164
#include <iostream>
typedef long long ll;

using namespace std;

int N;
int T;
int tim[200001];
int tmp[200001];
ll ans;

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

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

  for(int i = 0; i < N-1; i++) {
    tmp[i] = tim[i+1]-tim[i];
  }

  for(int i = 0; i < N-1; i++) {
    if(tmp[i] < T) {
      ans += tmp[i];
    }
    else ans += T;
  }
  cout << ans + T <<endl;
}
  


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>

using namespace std;
long N, A, B;
vector<long> X;
int mod = 1000000007;

int main() {
  cin >> N >> A >> B;
  long ans = 0;
  long before;
  cin >> before;
  for (int i=1; i<N; i++) {
    long after;
    cin >> after;
    ans += min(A*(after-before), B);
    before = after;
  }
  cout << ans << endl;
}


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

#define DL "delicious"
#define SF "safe"
#define DG "dangerous"

int x, a, b;

int main() {
    cin >> x >> a >> b;

    if (a >= b) {
        cout << DL << endl;
    }
    else if (a < b && a + x >= b) {
        cout << SF << endl;
    }
    else { 
        cout << DG << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	static Map<Long, List<Long>> task = new TreeMap<Long, List<Long>>();
	public static void myadd(long key, long value) {
		List<Long> tmp = new ArrayList<Long>();
		if(task.containsKey(key)) {
			for(Long t : task.get(key)) {
				tmp.add(t);
			}
		}
		tmp.add(value);
		task.put(key, tmp);
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int an = 0;
		for (int i = 0; i < n; ++i) {
			long a = sc.nextLong();
			long b = sc.nextLong();
			if (a > b)
				an = 1;
			myadd(b, a);
		}
		sc.close();
		String ans[] = { "Yes", "No" };
		if (an != 1) {
			long present = 0;
			Long b[] = task.keySet().toArray(new Long[0]);
			for(Long t : b) {
				List<Long> tmp = task.get(t);
				for(Long t2 : tmp) {
					present += t2.longValue();
				}
				if(present > t.longValue()) {
					an = 1;
					break;
				}
			}
		}
		System.out.println(ans[an]);
	}
}


Measured memory_bytes: 161152