akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <limits>
using std::endl;
using std::cin;
using std::cout;
using std::vector;
using std::pair;
using std::string;
using std::map;
using std::multimap;
using std::make_pair;
using std::sort;
using std::reverse;

//std::numeric_limits<uint32_t>::max()
//for (uint32_t i = 0; i < N; i++){
//vector<uint32_t> A(N);

int main(void)
{
    string S;
    cin >> S;

    bool isGood = true;
    for (uint32_t i = 0; i < S.size(); i++){
        if (i%2 == 1) {
            if (S[i] == 'L' || S[i] == 'U' || S[i] == 'D') {
                //cout << i << ":" << S[i] << endl;
            } else {
                isGood = false;
            }
        } else {
            if (S[i] == 'R' || S[i] == 'U' || S[i] == 'D') {
                //cout << i << ":" << S[i] << endl;
            } else {
                isGood = false;
            }
        }
    }

    if (isGood) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <bitset>

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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 (a > b) {
      a = b;
      return 1;
   }
   return 0;
}

using namespace std;
using ll = long long;

const ll kInf = 1e18;

int gcd (int a, int b) {
   return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
   int n;
   cin >> n;
   int cnt = 0;
   REP(i, n) {
      int p;
      cin >> p;
      if (p != i + 1) {
         cnt++;
      }
   }
   if (cnt == 0 || cnt == 2) {
      cout << "YES" << endl;
   } else {
      cout << "NO" << endl;
   }
   return 0;
}


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

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    int n, t;
    scanf("%d %d", &n, &t);
    int a[n];
    rep(i, 0, n){
        scanf("%d", &a[i]);
    }
    int min[n], max[n];
    min[0] = a[0];
    rep(i, 1, n){
        min[i] = min[i-1];
        if(min[i] > a[i]){
            min[i] = a[i];
        }
    }
    max[n-1] = a[n-1];
    revrep(i, n-2, -1){
        max[i] = max[i+1];
        if(max[i] < a[i]){
            max[i] = a[i];
        }
    }
    int max_profit = 0;
    rep(i, 0, n){
        int buf = max[i] - min[i];
        if(max_profit < buf){
            max_profit = buf;
        }
    }
    int x = -1, y = -1;
    int cost = 0;
    rep(i, 0, n){
        int buf = max[i] - min[i];
        if(buf == max_profit){
            if(max[i] != x && min[i] != y){
                cost++;
                x = max[i];
                y = min[i];
            }
        }
    }
    printf("%d", cost);

    return 0;
}

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

const int maxn = 1e5+10;
const int mod = 1e9+7;

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,m,ans=0;
	cin>>n>>m;
	vector<pair<int,char>> vs(m);
	map<int,char> mp;
	for(int i=0;i<m;++i){
		cin >> vs[i].ff >> vs[i].ss;
		auto it = mp.find(vs[i].ff);
		if(it == mp.end()){
			mp[vs[i].ff] = vs[i].ss;
		}
		else if(mp[vs[i].ff] != vs[i].ss){
			ans = 1;
		}
	}
	auto it = mp.find(1);
	if(it!=mp.end() && mp[1] == '0' && n > 1)
		ans=1;
	if(ans){
		cout<<-1<<endl;
		exit(0);
	}
	if(n==1 && m==0){
		cout<<0<<endl;
		exit(0);
	}
	string res;
	for(int i=0;i<n;++i){
		auto it = mp.find(i+1);
		if(it!=mp.end()){
			res.pb(mp[i+1]);
		}
		else if(i>0){
			res.pb('0');
		}
		else
			res.pb('1');
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
/**
*    author:  yuya1234
*    created: 07.07.2020 15:37:55
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define ALL(v) (s).begin(), (s).end()
#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  string s;
  cin>>s;

  ll ans=0;
  int ss[SZ(s)+1];
  MEMSET(ss,0);

  REP(i,SZ(s))
  {
    if(s[i]=='<')ss[i+1]=max(ss[i+1],ss[i]+1);
  }

  REPD(i,SZ(s))
  {
     if(s[i]=='>')ss[i]=max(ss[i],ss[i+1]+1);
  }

  REP(i,SZ(s)+1)ans+=ss[i];
  cout<<ans<<endl;

  return 0;
}

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

using P = pair<long long, long long>;
long long n, m;
vector<P> g, v;

long long solve();

int main() {
  cin >> n;
  g.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> g[i].first >> g[i].second;
    v.emplace_back(g[i].first, i);
    v.emplace_back(g[i].second, i);
  }
  for (auto& p : g) cin >> p.first >> p.second;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = 1e18;
  {  // all a
    long long sum = 0;
    for (int i = 0; i < n; ++i) sum += g[i].first;
    res = min(res, sum);
  }
  {  // all
    long long sum = 0;
    for (int i = 0; i < n; ++i) sum += g[i].second;
    res = min(res, sum);
  }
  sort(v.begin(), v.end());
  {
    long long sum = 0;
    vector<int> cnt(n, 0);
    bool ch = 0;
    for (int i = 0; i < n; ++i) {
      sum += v[i].first;
      if (++cnt[v[i].second] == 2) ch = 1;
    }
    if (ch) return min(res, sum);
    for (int i = 0; i < n; ++i) {
      long long now = sum - min(g[i].first, g[i].second);
      if (v[n].second == i)
        now += v[n + 1].first;
      else
        now += v[n].first;
      res = min(res, now);
    }
  }
  return res;
}

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  if(n<10)
  cout<<n<<'\n';
  else if(n<100)
  cout<<9<<'\n';
  else if(n<1000)
  cout<<(9+(n-99))<<'\n';
  else if(n<10000)
  cout<<909<<'\n';
  else if(n<100000)
  cout<<(909+n-9999)<<'\n';
  else
  cout<<90909<<'\n';


  return 0;
}


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

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i=0; i<s.size(); i++) {
        if(s[i]!=t[i]) ans += 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3856
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;
int dp[101010][3];

int main() {
    int n, k; cin >> n >> k;
    int r, s, p; cin >> r >> s >> p;
    string t; cin >> t;


    map<char, int> value = { { 'r' , r }, { 's' , s }, { 'p' , p }};
    map<char, char> mp = { { 'r', 'p' }, { 's', 'r' }, { 'p', 's' }};

    long long sum = 0;
    rep(i, k) {
        char prev = mp[t[i]];
        sum += value[mp[t[i]]];
        for (int j = i + k; j < n; j += k) {
            char kachite = mp[t[j]];
            if (prev != kachite) {
                sum += value[kachite];
                prev = kachite;
            } else {
                prev = 'A';
            }

        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 512
import fractions

def cnt(a, b, c):
    cnt = b // c - (a - 1) // c
    return cnt

def main():
    a, b, c, d = map(int, input().split())
    lcm = c * d // fractions.gcd(c, d)
    c, d, lcm = cnt(a, b, c), cnt(a, b, d), cnt(a, b, lcm)
    print(b - a + 1 - c - d + lcm)

if __name__ == '__main__':
    main()

Measured memory_bytes: 5048
# ABC 143 D - Triangles
# https://atcoder.jp/contests/abc143/tasks/abc143_d

n = gets.chomp.to_i
l = gets.chomp.split(/ /).map(&:to_i).sort

# puts sticks.inspect
# puts ""

count = 0
0.upto(n - 3) do |i|
  a = l[i]
  (i + 1).upto(n - 2) do |j|
    b = l[j]
    c_candidates = l[(j + 1)..(n - 1)]
    t = a + b
    # puts "--------"
    # puts c_candidates.inspect
    # puts "a: #{a}, b: #{b}, a + b: #{t}"
    c_over_index = c_candidates.bsearch_index { |c| c >= t }
    if c_over_index.nil?
      count += (n - 1) - j
    else
      count += c_over_index
    end
  end
end

puts count


Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =1000000007;
int main()
{
        FastIO
        int x;
        cin>>x;

        int d5,d;

        d5= x/500;
        x%=500;
        d= x/5;
        cout<< d5*1000 + d*5;
        return 0;}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k; cin>>n>>k;
  int ans=0;
  rep(i,n){
    int h=0; cin>>h;
    if(h>=k) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



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



vector<string> vs;

string str;

int res = 0;
bool seen[15][15];

void dfs(int i, int j) {
    seen[i][j] = true;
    for (int k = 0; k < 4; ++k) {
        int ni = i + dx[k], nj = j + dy[k];
        if (ni < 0 || ni >= 12 || nj < 0 || nj >= 12) continue;
        if (seen[ni][nj]) continue;
        if ( vs[ni][nj] == '1' ) dfs(ni, nj);
    }
}

int main() {
    vs.clear();
    while (getline(cin, str)) {
        vs.PB(str);
        while ( getline(cin, str) ) {
            if (str == "") {
                break;
            }
            vs.PB(str);
        }
        
        res = 0;
        memset(seen, 0, sizeof(seen));
        for (int i = 0; i < 12; ++i) {
            for (int j = 0; j < 12; ++j) {
                if ( !seen[i][j] && vs[i][j] == '1') {
                    dfs(i, j);
                    ++res;
                }
            }
        }
        
        cout << res << endl;
        vs.clear();
    }
    
    return 0;
}


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

using namespace std;

vector<int> A, B;
char a[102], b[102];
int c = 0;

int main(){
	for (int i = 0; i < 102; i++){
		a[i] = 'a';
		b[i] = 'a';
	}

	cin >> a >> b;

	while (a[c] != 'a'){
		A.push_back(a[c]);
		c++;
	}
	c = 0;
	while (b[c] != 'a'){
		B.push_back(b[c]);
		c++;
	}
	c = 0;

	if (A.size() > B.size()){
		cout << "GREATER" << endl;
	}
	else if (A.size() < B.size()){
		cout << "LESS" << endl;
	}
	else{
		while (a[c] == b[c] && c < 101){
			c++;
		}

		if (a[c] > b[c]){
			cout << "GREATER" << endl;
		}
		else if (a[c] < b[c]){
			cout << "LESS" << endl;
		}
		else{
			cout << "EQUAL" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
n = gets
until n.nil?
    nn = n.split(" ").map{|k| k.to_f }
    a = nn[0]
    b = nn[1]
    c = nn[2]
    d = nn[3]
    e = nn[4]
    f = nn[5]
    x = 0
    y = 0
    if c*e - b*f == 0
        x = 0
    else
        x = ((c*e - b*f) / (a*e - b*d)).round(3)
    end
    if c*d - a*f == 0
        y = 0
    else
        y = ((c*d - a*f) / (b*d - a*e)).round(3)
    end
    
    puts "#{'%.3f' % x} #{'%.3f' % y}"
    n = gets
end



Measured memory_bytes: 6956
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double n,a,i,m;
    vector<double>s;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a;
        s.push_back(a);
    }
    sort(s.begin(),s.end());
    m=((s[0])+(s[1]))/2;
    for(i=2;i<s.size();i++)
    {
        m=(m+s[i])/2;
    }
    cout<<m<<endl;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

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 U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
    for(auto &e:u) fill_v<T>(e,v...);
}


int main(void) {
    int64 N, K;
    cin >> N >> K;
    int64 res = 0;
    REP(i, N) {
        int64 h;
        cin >> h;
        res += h >= K;
    }
    cout << res << endl;
}


Measured memory_bytes: 384
#include<cstring>
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int a[maxn];
int b[maxn];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n+1;i++)
        cin>>a[i];
    for(int j=0;j<n;j++)
        cin>>b[j];
    ll sum=0;
    for(int j=0;j<n;j++)
    {
        if(b[j]>=a[j])
        {

            sum+=a[j];

            b[j]-=a[j];
            a[j]=0;
        }
        else
        {

            sum+=b[j];

            a[j]-=b[j];
            b[j]=0;
        }
        if(b[j]>=a[j+1])
        {

            sum+=a[j+1];

            b[j]-=a[j+1];
            a[j+1]=0;
        }
        else
        {
            
            sum+=b[j];

            a[j+1]-=b[j];
            b[j]=0;
        }

    }
    cout<<sum;
    return 0;
}


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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 500000000000000;
constexpr auto MOD = 1000000007;


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

	vi r = {}, g = {}, b = {};

	rep(i, n){
		if (s[i] == 'R')r.push_back(i);
		if (s[i] == 'G')g.push_back(i);
		if (s[i] == 'B')b.push_back(i);
	}
	ll ans=0;

	rep(i, r.size())rep(j, g.size()) {

		if (b.size() == 0)break;

		ans += b.size();

		if ((r[i] + g[j]) % 2 == 0 && s[(r[i] + g[j]) / 2] == 'B')ans--;
		
		int le = min(r[i], g[j]) - abs(r[i] - g[j]);
		int ri = max(r[i], g[j]) + abs(r[i] - g[j]);

		if (n - 1 >= le && le >= 0)if (s[le] == 'B') ans--;
		if (0 <= ri && ri <= n - 1)if (s[ri] == 'B') ans--;
	}

	cout << ans << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
#define NUM 100005
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int GCD(int a,int b){int c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
int LCM(int a,int b){return a*b/GCD(a,b);}
int POW(int a,int n){int i;LL x=a;if(n==0)return 1;else if(n==1)return a;else FOR(i,0,n-1){x=x*a;if(x>MOD)x%=MOD;}return (int)x;}
int cmp(const void* a,const void* b){return *(int*)a-*(int*)b;}

int main(){
  int K,X,i,j,k,ans=0;
  scanf("%d%d",&K,&X);
  i=X-K+1;j=X+K-1;
  FOR(k,i,j+1)printf("%d ",k);
  //printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;

struct LazySegmentTree {
private:
    int n;
    vector<int> node, lazy;
    vector<bool> lazyFlag;
 
public:
    LazySegmentTree(vector<int> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, inf);
        lazyFlag.resize(2*n-1, false);
 
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
 
    void lazyEvaluate(int k, int l, int r) {
        if(lazyFlag[k]) {
            node[k] = lazy[k];
            if(r - l > 1) {
                lazy[k*2+1] = lazy[k*2+2] = lazy[k];
                lazyFlag[k*2+1] = lazyFlag[k*2+2] = true;
            }
            lazyFlag[k] = false;
        }
    }
 
    void update(int a, int b, int x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] = x;
            lazyFlag[k] = true;
            lazyEvaluate(k, l, r);
        }
        else {
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = min(node[2*k+1], node[2*k+2]);
        }
    }
 
    int find(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return inf;
        if(a <= l && r <= b) return node[k];
        int vl = find(a, b, 2*k+1, l, (l+r)/2);
        int vr = find(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,q; cin>>n>>q;
	vector<pair<int,P>> f(n);
	rep(i,0,n) cin>>f[i].second.first>>f[i].second.second>>f[i].first;
	vector<int> d(q);
	rep(i,0,q) cin>>d[i];
	sort(f.begin(),f.end(),greater<pair<int,P>>());
	LazySegmentTree seg(vector<int>(q,inf));
	rep(i,0,n){
		int s=f[i].second.first;
		int t=f[i].second.second;
		int x=f[i].first;
		int l=lower_bound(d.begin(),d.end(),s-x)-d.begin();
		int r=lower_bound(d.begin(),d.end(),t-x)-d.begin();
		seg.update(l,r,x);
	}
	rep(i,0,q){
		int ans=seg.find(i,i+1);
		if(ans==inf) printf("-1\n");
		else printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 11504
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstdlib>
#include<iomanip>

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

using namespace std;

typedef long long int ll;

const ll INF=(ll)1e18;

int main(){

  int N,K;
  cin >> N >> K;

  double ans = 0;

  FOR(i,1,N+1){
    int t = i;
    double s = 1.0/N;
    while(t < K){
      s *= 0.5;
      t = t << 1;
    }
    ans += s;
  }

  cout << setprecision(12) << ans << endl;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <typeinfo>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

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

  long ans = 1;

  for (long i = 1; i <= n;i++){
    ans *= i;
    ans %= 1000000007;
  }
  cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N;
    cin >> N;
    ll ai, bi;
    vector<ll> A, B;
    for(int i=0;i<N;i++){
        cin >> ai;
        A.push_back(ai);
    }
    for(int i=0;i<N;i++){
        cin >> bi;
        B.push_back(bi);
    }
    ll K = accumulate(B.begin(), B.end(), (ll)0) - accumulate(A.begin(), A.end(), (ll)0);
    ll k = 0;
    for(int i=0;i<N;i++){
        if(A[i]<B[i]){ k += (B[i]-A[i]+1)/2;}
    }
    if(K>=0 && K>=k) cout<<"Yes"<<endl;
    else             cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

const int MOD = INF+7;
ll dp[105][10];
int main(){
    int h,w,k;cin>>h>>w>>k;
    k--;
    dp[0][0] = 1;
    rep(i,h){
        for(int bit = 0;bit < (1<<w-1);bit++){
            vector<int>S = bitSearch(bit,w-1);
            const int len = S.size();
            bool flag = true;
            rep(l,len-1){
                if(S[l+1] == S[l]+1)flag = false;
            }
            if(!flag)continue;
            if(S.empty()){
                rep(jj,w){
                    dp[i+1][jj] = (dp[i+1][jj]+dp[i][jj])%MOD;
                    //dp[i+1][j] %= MOD;
                }
            }
            else {
                rep(j,w){
                    if(j == *lower_bound(ALL(S),j)){                
                        dp[i+1][j+1] = (dp[i+1][j+1]+dp[i][j])%MOD;
                        dp[i+1][j] = (dp[i+1][j]+dp[i][j+1])%MOD;
                        j++;
                        if(j >= w)continue;
                    }
                    else{
                        dp[i+1][j] = (dp[i+1][j]+dp[i][j])%MOD;
                        //dp[i+1][j] %= MOD;
                    }
                }
            }
        }
    }
    //rep(i,h+1){rep(j,w)cout<<dp[i][j]<<" ";cout<<endl;}
    cout<<dp[h][k]<<endl;;
}

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


int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  string ans = "No";
  if(abs(c-a)<=d || abs(b-a)<=d && abs(c-b)<=d) ans = "Yes";
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int x,y,z;
    scanf("%d %d %d",&x,&y,&z);
    int ans;
    if(x%(y+z)>=z)
    {
        ans=x/(y+z);
    }
    else
    {
        ans=x/(y+z);
        ans--;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const ll mod = 1000000000 + 7;
typedef pair<char, char> CP;

ll max(ll a, ll b){
	if (a>b) return a;
	else return b;
}

ll min(ll a, ll b){
	if (a<b) return a;
	else return b;
}

int main() {
	ll n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<CP> cp(q);
	REP(i, q){cin >> cp[i].first >> cp[i].second;}
	ll l = 0; ll r = n-1;
	REPR(i, q){
		if (cp[i].second == 'L'){
			if (cp[i].first == s[l]){
				l++;
			}
			if (cp[i].first == s[min(r+1, n-1)]){
				r = min(r+1, n-1);
			}
		} else {
			if (cp[i].first == s[r]){
				r--;
			}
			if (cp[i].first == s[max(l-1, 0)]){
				l = max(l-1, 0);
			}
		}
	}
	cout << n - l - (n-1-r) << endl;
}


Measured memory_bytes: 900
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int n, h, x, y;
    ll ans = 0;
    sc(n) sc(h)
    vector<P> vec;
    for (int i = 0; i < n; i++){
        sc(x) sc(y)
        vec.push_back(P(x, 0));
        vec.push_back(P(y, 1));
    }
    sort(vec.begin(), vec.end(), greater<P>());
    for (const auto &i : vec){
        if (i.second == 0){
            if (h % i.first == 0) ans += h / i.first;
            else ans += h / i.first + 1;
            break;
        }else{
            h -= i.first;
            ans += 1;
            if (h <= 0) break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
VI e[SIZE];
int f(int x,int lt,int v){
 int r=1;
 if(!v)return r;
 REP(i,SZ(e[x]))
  if(e[x][i]!=lt)r+=f(e[x][i],x,v-1);
 return r;
}
int main(){
 DRII(N,K);
 REPP(i,1,N){
  DRII(x,y);x--;y--;
  e[x].PB(y);
  e[y].PB(x);
 }  
int r=0;
 if(K&1){
   REP(i,N)REP(j,SZ(e[i]))r=max(r,f(i,e[i][j],K/2)+f(e[i][j],i,K/2));
}
else
 REP(i,N)r=max(r,f(i,i,K/2));
printf("%d\n",N-r);
    return 0;
}

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

int main()
{
    int N, sum = 0;
    cin >> N;
    vector<int> L(N);
    
    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
    }
    sort(L.begin(), L.end());

    for (int i = 0; i < N - 1; i++)
    {
        sum += L[i];
    }
    if (L[N - 1] < sum)
    {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
/// 2:27 AM 17/05/20
/// Author: t_bone_289 (An Immature Programmer.... I'm still developing !!)
#include<bits/stdc++.h>

using namespace std;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define VARIABLE_ERROR(x) cout << #x << " = " << x << endl;
#define CONTAINER_ERROR(v) cout << "{";for (auto &x:v) { cout << x << ','; }cout << "}" << endl;
#define PI 3.14159265358979323846
#define M 1000000007
#define INF 1e15
typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n, k;
    cin >> n >> k;
    vector<ll> v(n);
    for (auto &x:v) {
        cin >> x;
    }
    vector<vector<ll> > dp(n + 1, vector<ll>(k + 1, 0));
    vector<vector<ll> > sum(n + 1, vector<ll>(k + 1, 0));
    dp[0][0] = 1;
    sum[0][0] = 1;
    for (ll j = 1; j <= k; j++) {
        sum[0][j] = (sum[0][j] + sum[0][j - 1]) % M;
    }
    for (ll i = 1; i <= n; i++) {
        for (ll j = 0; j <= k; j++) {
            ll limit = v[i - 1];
            ll maxVal = min(limit, j);
            /// m = 0 to maxVal
            /// summation dp[i-1][j-0] + dp[i-1][j-1] ...... dp[i-1][j-maxVal]
            ll left = max(0ll, j - maxVal);
            ll summation = (sum[i - 1][j]) % M;
            if (left > 0) {
                summation = (summation - sum[i - 1][left - 1] + M) % M;
            }
            dp[i][j] = (dp[i][j] + summation) % M;
        }
        sum[i][0] = dp[i][0];
        for (ll j = 1; j <= k; j++) {
            sum[i][j] = (sum[i][j - 1] + dp[i][j]) % M;
        }
    }
    cout << dp[n][k];
    return 0;
}

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

using namespace std;
int x;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);
    cin>>x;
    if(x<=599) cout<<8;
    else if(x<=799) cout<<7;
    else if(x<=999) cout<<6;
    else if(x<=1199) cout<<5;
    else if(x<=1399) cout<<4;
    else if(x<=1599) cout<<3;
    else if(x<=1799) cout<<2;
    else cout<<1;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#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 all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll N;
  cin >> N;
  cout << (N+1)/2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;string s;cin>>n>>k>>s;
  if(s[k-1]=='A'){
    s=s.replace(k-1,1,"a");
  }else if(s[k-1]=='B'){
    s=s.replace(k-1,1,"b");
  }else if(s[k-1]=='C'){
    s=s.replace(k-1,1,"c");
  }
  cout<<s<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1010],b[1010];
int n;
void solve(){
	cin>>n;
	--n;
	for(int i=1;i<=n;++i){
		scanf("%d",b+i);
	}
	a[0]=a[1]=b[1];
	for(int i=2;i<=n;++i){
		if(a[i-1]>b[i]){
			a[i-1]=b[i];
		}
		a[i]=b[i];
	}
	int ans=0;
	for(int i=0;i<=n;++i){
		ans+=a[i];
		//cerr<<a[i]<<" ";
	}
	cout<<ans<<endl;
}
int main(){
	solve();
	return 0;
}

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

int main()
{
  int i,JOI,IOI;
  string s;
  while(cin>>s){
    i=JOI=IOI=0;
    while(i=s.find("JOI",i),i!=string::npos){JOI++;i++;}
    i=0;
    while(i=s.find("IOI",i),i!=string::npos){IOI++;i++;}
    cout<<JOI<<endl<<IOI<<endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <algorithm>
#include<iostream>
#include <cstring>
#define N 505
using namespace std;
typedef long long ll;
int c[505];
int s[505]; 
int f[505]; 
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d%d",&c[i],&s[i],&f[i]);
    for(int i=1;i<=n;i++){
        int ans=0;
        for(int j=i;j<n;j++){
            if(ans<s[j]) 
                ans=s[j];
            if(ans%f[j]!=0)
                ans=ans+f[j]-ans%f[j];
            ans+=c[j];
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 256
#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()
#define itn int
typedef long long ll;
typedef pair<int,int> p;


int main()
{
  // long double x, y;
  // cin >> x >> y;
  // long double tmp = log(y / x) / log(2);
  // int a = tmp;
  // cout << a + 1 << endl;
  ll x, y;
  cin >> x >> y;
  ll i = 1;
  int count = 0;
  while(y >= i * x) {
    count++;
    i *= 2;
  }
  cout << count << endl;

}

Measured memory_bytes: 256
def divisors(n)
  r = []
  1.upto(n) do |i|
    break unless i <= n / i
    next unless (n % i).zero?
    r << i
    r << n / i if i != n / i
  end
  r
end
def ok(n, k)
  return ok(n/k, k) if (n%k).zero?
  (n%k)==1
end
N=gets.to_i
ans=divisors(N-1).size-1
divisors(N).each do |k|
  next if k==1
  ans+=1 if ok(N,k)
end
p ans

Measured memory_bytes: 14312
int N;
long n, k;
long x[100000];
long dist[100000];
long result;

long cmp(const long *a, const long *b){
	return *b - *a;
}

int main(){
	long i;
	scanf("%d", &N);
	while(N--){
		scanf("%d%d", &n, &k);
		scanf("%d", &x[0]);
		for(i = 1; i < n; i++){
			scanf("%d", &x[i]);
			dist[i-1] = x[i] - x[i-1];
		}
		qsort(dist, n-1, sizeof(long), (long (*)(const void*, const void*))cmp);
		result = x[n-1] - x[0];
		if(n <= k){
			result = 0;
		}else{
			for(i = 0; i < k-1; i++){
				result -= dist[i];
			}
		}
		printf("%d\n", result);
	}
	return 0;
}

Measured memory_bytes: 1564
H,W=map(int,input().split(' '))
mine = [input() for i in range(H)]
def mine_chk(h,w):
    cnt = 0
    for i in range(max(0,h-1),min(h+2,H)):
        for j in range(max(0,w-1),min(W,w+2)):
            if mine[i][j] =="#":
                cnt += 1
    return cnt



for i in range(H):
    for j in range(W):
        if mine[i][j] == "#":
            print("#",end="")
        else:
            print(mine_chk(i,j),end="")
    print("")


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n;
    cin >> n;
    int ans = 1;
    rep(i, 3) ans *= n;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
typedef long long ll;
int main(){    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int x,y;
    cin>>x>>y;
    while(y>1){
        if(y%4==0&&y/4==x){
            cout<<"Yes";
            return 0;
        }
        y-=2;
        x--;
    }
    if(x==0&&y==0)cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <stdbool.h>

bool has_submited[30];

int main() {
    int i;

    for (i=0;i<28;i++) {
        int num;
        scanf("%d", &num);
        has_submited[num-1] = 1;
    }

    for (i=0;i<30;i++) {
        if (!has_submited[i]) {
            printf("%d\n", i+1);
        }
    }
}

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

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

  ll s = (w*h)/2;
  int ans = (2*x==w&&2*y==h) ? 1 : 0;
  printf("%.10Lf %d\n", s, ans);
}


Measured memory_bytes: 256
c = 0

while str = STDIN.gets

  break if str == "\n"

  ar = str.chomp.split(//)

  if ar.size == 1
    c += 1
  else
    mid = (ar.size / 2.0).floor
    c += 1 if ar[0..mid - 1] == ar[-mid..-1].reverse
  end

end

puts c

Measured memory_bytes: 8656
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<bitset>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 16;
char cn[cm], * ci = cn, ct;
inline int getint() {
	int A = 0;
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

//bitset使ったことほぼないなぁ
bitset<12811> dp1[90];

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


	fread(ci, 1, cm, stdin);
	int H, W;
	H = getint(), W = getint();
	char AB[80][80];
	rep(i, H) rep(j, W) {
		AB[i][j] = getint();
	}
	rep(i, H) rep(j, W) {
		AB[i][j] = abs(AB[i][j] - getint());
	}

	dp1[0][6405] = true;
	for (int hw = 0; hw <= H + W - 2; hw++) {
		for (int w = min(hw, W - 1); w >= max(0, hw - H + 1); w--) {
			int h = hw - w;
			dp1[w] = dp1[w] << AB[h][w] | dp1[w] >> AB[h][w];
			dp1[w + 1] |= dp1[w];
		}
	}


	rep(i, 81) {
		if (dp1[W - 1][6405 + i]) {
			printf("%d", i);
			return 0;
		}
	}

	Would you please return 0;
}

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

using namespace std;

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;}

const ll INF=1e9+7;

ll dp[50][500][500];

int main(){
    ll n,ma,mb;
    cin >> n >> ma >> mb;
    vector<ll> a(n),b(n),c(n);
    rep(i,50){
        rep(j,500){
            rep(k,500){
                dp[i][j][k]=INF;
            }
        }
    }
    rep(i,n){
        cin >> a[i] >> b[i] >> c[i];
    }
    dp[0][0][0]=0;
    rep(i,n){
        rep(j,500){
            rep(k,500){
                dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
                if(j-a[i]>=0 && k-b[i]>=0){
                    dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j-a[i]][k-b[i]]+c[i]);
                }
            }
        }
    }
    ll ans=INF;
    for(ll i=1;i<500;i++){
        for(ll j=1;j<500;j++){
            if(dp[n][i][j]==INF) continue;
            ll d=gcd(i,j);
            ll p=i/d;
            ll q=j/d;
            if(p==ma && q==mb){
                ans=min(ans,dp[n][i][j]);
            }
        }
    }
    if(ans==INF) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 101272
using System;
using System.Collections.Generic;
 
namespace ALDS1_3
{
    class Program
    {
        public struct Process
        {
            public readonly string n;
            public readonly int t;
            public Process(string n, int t)
            {
                this.n = n;
                this.t = t;
            }
        }
 
        static void Main()
        {
            var s = Console.ReadLine().Split();
            var a = int.Parse(s[1]);
            var b = new List<Process>();
            string w;

            while ((w = Console.ReadLine()) != null)
            {
                var c = w.Split();
                var d = c[0]; var e = int.Parse(c[1]);
                b.Add(new Process(d, e));
            }
 
            var f = 0;
 
            while (b.Count > 0)
            {
               var g = b[0];
               b.RemoveAt(0);
               var k = g.n;
               var v = g.t;
               f += v < a ? v : a;
               v -= a;
               if (v <= 0)
                   Console.WriteLine("{0} {1}", k, f);
               else
                   b.Add(new Process(k, v));
            }
        }
    }
}

Measured memory_bytes: 14768
N, W = map(int, input().split())
V = []
for i in range(N):
    V.append(list(map(int, input().split())))
    
DP = [[0 for _ in range(W+1)] for _ in range(N+1)]

for i in range(N):
    for j in range(W+1):
        if(j >= V[i][1]):
            DP[i+1][j] = max(DP[i][j], DP[i][j-V[i][1]]+V[i][0])
        else:
            DP[i+1][j] = DP[i][j]
print(DP[N][W])


Measured memory_bytes: 25952
#include <bits/stdc++.h>
#define P 1000000007
using namespace std;
typedef long long lnt;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int n; lnt m;
struct Matrix {
	lnt v[50][50];
	Matrix () {memset(v, 0, sizeof v);}
	inline Matrix operator * (const Matrix &x) const {
		Matrix ret;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				for (int k = 0; k < n; k++)
					(ret.v[i][j] += v[i][k]*x.v[k][j]%P) %= P;
		return ret;
	}
} F, G;
Matrix Pow(Matrix mat, lnt k) {
	Matrix ret;
	for (int i = 0; i < n; i++)
		ret.v[i][i] = 1;
	for (; k; k >>= 1, mat = mat*mat)
		if (k&1) ret = ret*mat;
	return ret;
}
int main() {
	read(n), read(m);
	for (int i = 0; i < n; i++)
		F.v[i][0] = 1;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			read(G.v[i][j]);
	F = Pow(G, m)*F; lnt ans = 0;
	for (int i = 0; i < n; i++)
		(ans += F.v[i][0]) %= P;
	return printf("%lld\n", ans), 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	if (s[1] == 'B')
	{
		s[1] = 'R';
	}
	else
	{
		s[1] = 'B';
	}

	println(s);
}

Measured memory_bytes: 3600
#!/usr/bin/python3
# -*- coding: utf-8 -*-


"""
https://beta.atcoder.jp/contests/abc057/tasks/abc57_1
"""

import sys
import math
from inspect import currentframe

def debug(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=sys.stderr)

A, B = map(int, input().split())
print((A + B) % 24)






Measured memory_bytes: 4972
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  string s;
  cin>>s;
  string t;
  bool f=0;
  for(int i=0;i<(int)s.size();i++){
    f|=s[i]=='A';
    if(f&&s[i]=='Z'){
      f=0;
      t+="AZ";
    }
  }
  if(t.empty()) cout<<-1<<endl;
  else cout<<t<<endl;
  return 0;
}

Measured memory_bytes: 3208
def main():
    high, width = map(int, input().split())
    num = int(input())
    data = list(map(int, input().split()))
    lans = [0 for i in range(high * width)]
    ind = 0
    for i in range(num):
        for j in range(data[i]):
            lans[ind] = i + 1
            ind += 1

    for i in range(high):
        now_data = lans[i * width: i * width + width]
        if i % 2 == 1:
            now_data = now_data[::-1]
        now_data = list(map(str, now_data))
        print(' '.join(now_data))

if __name__ == '__main__':
    main()

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    string s;
    cin>>s;
    if(s.size()%2)
        cout<<"No",exit(0);
    for(int i=0;i<s.size();i+=2)
        if(s[i]!='h')
            cout<<"No",exit(0);
    for(int i=1;i<s.size();i+=2)
        if(s[i]!='i')
            cout<<"No",exit(0);
    cout<<"Yes";
}


Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const int MAX_N=2001;

int gcd(int a,int b){
  if(!b)  return a;
  else return gcd(b,a%b);
}

int main(){
  int N;
  ll T,ans=0;
  cin >> N >> T ;
  ll t[N];
  rep(i,N)  cin >> t[i] ;
  rep(i,N-1){
    if(t[i+1]<t[i]+T) ans+=t[i+1]-t[i];
    else ans+=T;
  }
  ans+=T;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
if __name__ == '__main__':
    MODULO = 10**9 + 7
    n = int(input())
    A = list(map(int, input().split()))
    total = 0
    sq = 0
    for i in range(n):
        total = (total + A[i]) #% MODULO
        sq = (pow(A[i], 2) + sq) #% MODULO
    total = ((pow(total, 2) - sq) // 2) % MODULO
    print(total )



Measured memory_bytes: 94220
#include <bits/stdc++.h>
 
using namespace std;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = 4*atan(1);
typedef long long ll;
typedef pair<int,int> pii;
int n, k;
void solve() {
	cin >> n >> k;
	ll l, r;
	l = r = 1LL*n*(n+1)/2;
	ll sum = 1;
	for (int i = n ; i >= k; i--) {
		l -= i;
		r -= n-i;
		sum = (sum+(r-l+1))%MOD;
	}
	cout << sum << endl;
}
int main() {
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	// int t;
	// cin >> t;
	// for (int i = 1; i <= t; i++) { 
		// cout << "Case #" << i << ": ";
		solve();
	// }
}

Measured memory_bytes: 3636