akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k,a[109],b[109],dp[109][100009];
ll best(ll d,ll sum)
{
    if(d==n||sum<0){
        if(sum)
        return 1e15;
        return 0;
    }
    ll &r=dp[d][sum];
    if(r!=-1) return r;
    return r=min(best(d+1,sum),best(d+1,sum-b[d])+a[d]);
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>k;
for(ll i=0;i<n;i++)
    cin>>a[i]>>b[i];
memset(dp,-1,sizeof dp);
for(ll i=1e5;i>=0;i--)
    if(best(0,i)<=k){
        cout<<i;
        break;
    }
return 0;
}


Measured memory_bytes: 88820
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <iomanip>

using namespace std;

#define FOR(i,n) for(int i = 0; i < n; i++)
#define FORa(i,a,b) for(int i = a; i < b; i++)
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define SORT(a,n) sort(begin(a), begin(a) + n)
#define VSORT(v) sort(v.begin(), v.end())
#define MAX 1000000
#define ll long long
#define LOW(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define UP(s) transform(s.begin(),s.end(),s.begin(),::toupper)

const double PI = acos(-1.0);

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

int main() {
	double a,b,h,m;		
	cin >> a >> b >> h >> m;
	
	double degM = m*6;
	double degH = h*30 + degM/12;
	double deg = (degM - degH) * PI/180; //converting degrees to radians 
	double ans = sqrt(a*a + b*b - 2*a*b*cos(deg));
	
	cout << fixed << setprecision(10) << ans << endl;
	
	return 0;
}

















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

int main() {
  string S;
  cin >> S;
  int ans = 0;
  for (int i = 0; i < 4; i++) {
    if (S[i] == '+') ans++;
    else ans--;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3600
n = gets.strip.to_i

dp = Array.new(n+1 , n)
dp[0]=0

prices = ([1] + (1..7).map{|i|[6**i,9**i]}.flatten.keep_if{|e|e<100_000}).sort

(1..n).each do |i|
  prices.each do|price|
    dp[i] = dp[i-price]+1 if ((i - price)>=0)&&(dp[i-price]+1 < dp[i])
  end
end

puts dp[-1]


Measured memory_bytes: 2556
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#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++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

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

    int min_c = 10000;
    rep(i, N) {
        int c, t;
        cin >> c >> t;
        if(t <= T && c < min_c) {
            min_c = c;
        }
    }

    if(min_c == 10000) cout << "TLE" << endl;
    else cout << min_c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int K;
  cin >> K;
  vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << v[K-1] << endl;
}

Measured memory_bytes: 256
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#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(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  string s;
  cin >> s;

  map<char,int> mp;
  REP(i,4) mp[s[i]]++;

  if(mp.size() == 2 && mp.begin()->sc == 2) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int mod = 998244353;

int expo(int num, int p) {
    if(num == 0) {
        if(p == 0) return 1;
        return 0;
    }
    num = num % mod;
    int ret = 1;
    while(p) {
        if(p & 1) ret = (ret * num) % mod;
        num = (num * num) % mod;
        p /= 2;
    }
    return ret;
}

signed main() {
    IOS;
    int fact[200005], inv[200005];
    fact[0] = 1;
    for(int i = 1; i < 200005; ++i) fact[i] = (fact[i - 1] * i) % mod;
    for(int i = 0; i < 200005; ++i) inv[i] = expo(fact[i], mod - 2);
    int n, m, k;
    cin >> n >> m >> k;
    int ans = 0;
    // if(m == 1) {
    //     if(k == n - 1) cout << 1;
    //     else cout << 0;
    //     return 0;
    // }
    for(int i = 0; i <= k; ++i) {
        int cur = (m * expo(m - 1, n - i - 1)) % mod;
        cur = (cur * fact[n - 1]) % mod;
        cur = (cur * inv[i]) % mod;
        cur = (cur * inv[n - i - 1]) % mod;
        ans = (ans + cur) % mod;
    }
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 6764
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <random>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
#define bicnt(x)	__buildin__popcount(x)
#define debug(x)	cout<<"debug: "<<x<<endl
#define DEBUG 0

const ll inf = (ll)1e8;
const ll mod = (ll)1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

int main() {
	int x, k;	cin >> x >> k;
	vint r(k);
	rep(i, k)	cin >> r[i];
	int q;	cin >> q;
	vector<pii> query(q);
	rep(i, q)	cin >> query[i].fst >> query[i].scn;
	int left = 0, right = x;
	int val = 0, val2 = x;
	r.insert(r.begin(), 0);
	r.push_back(2e9);
	k += 2;
	int s = 0;
	srep(i, 1, k) {
		while (s < q&&query[s].fst < r[i]) {
			int amount = (left >= query[s].scn ? val : (right <= query[s].scn ? val2 : val + (query[s].scn - left)));
			if (i & 1) {
				cout << max(0, amount - (query[s].fst - r[i - 1])) << endl;
			}
			else {
				cout << min(x, amount + (query[s].fst - r[i - 1])) << endl;
			}
			s++;
		}
		if (i & 1) {
			val -= r[i] - r[i - 1];
			if (val < 0) {
				left -= val;	val = 0;
			}
			val2 -= r[i] - r[i - 1];
			if (val2 < 0) {
				right = 0;	val2 = 0;
			}
		}
		else {
			val2 += r[i] - r[i - 1];
			if (val2 > x) {
				right -= val2 - x;	val2 = x;
			}
			val += r[i] - r[i - 1];
			if (val > x) {
				left = x, val = x;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2424
/* vishal shrivastava
     185023
     nit hamirpur
   */
  #include <bits/stdc++.h>
  using namespace std;
  #define minpq priority_queue <int, vector<int>, greater<int> >;
  #define maxpq  priority_queue <int>;
  #define F first
  #define S second
  #define mp make_pair
  #define pb push_back
  #define f(i,x,n) for(int i=x;i<n;i++)
  #define all(c) c.begin(),c.end()
  #define ll long long
  #define pll pair<ll,ll>
  #define pii pair<int,int>
  const int mod = 1e9+7, N = 1e5 + 10;
  int solve()
  {
     ll a,b;
     cin>>a>>b;
     cout<<max(a*b,max(a+b,a-b));

  }

  int32_t main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int test=1;
    //cin>>test;
    while(test--)
    {
      solve();
    }
  }


Measured memory_bytes: 764
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<cmath>
#include<cstdio>
#include<cassert>
using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double INF = 0x3f3f3f3f;
const double INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
const double mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

vector<pii> g[100010];
vi C;

int dfs(int v, int p, int pc, int k){
    k = max(k, (int)g[v].size());
    int vc = 0;
    rep(i,g[v].size()){
        int u = g[v][i].fi;
        if(u == p) continue;
        vc = (vc + 1) % k;
        if(vc == pc) vc = (vc + 1) % k;
        C[g[v][i].se] = vc + 1;
        k = max(k, dfs(u, v, vc, k));
    }
    return k;
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");

    int n;
    cin >> n;
    C = vi(n-1);
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(pii(b,i));
        g[b].push_back(pii(a,i));
    }
    int k = dfs(0, -1, -1, 0);
    cout << k << endl;
    rep(i,n-1) cout << C[i] << endl;
    return 0;
}


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

int main() {

  int A,B,C,tmp;
  cin >> A>>B>>C;
  if(A>=B){
    cout << max(A*10+B+C,C*10+A+B)<< endl;
  }
  else{
  	cout << max(B*10+A+C,C*10+A+B);
  } 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int(i) = 0; (i) < (n); (i)++)
int main(){
  int64_t N;
  int K;
  string S, T;
  cin >> S >> T;
  K = S.size();
  string go = "Yes";
  rep(i,K){
    if (S.at(i) != T.at(i)){
      go = "No";
      break;
    }
  }
  cout << go << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;cin>>s;
    int count1 = 0;
    int count2 = 0;
    int x =  1;

    rep(i,s.size())
    {
        if(x != s[i]-'0')
        count1++;
        x = (x+1)%2;
    }

    x = 0;
    rep(i,s.size())
    {
        if(x != s[i]-'0')
        count2++;
        x = (x+1)%2;
    }

    cout<<min(count1,count2)<<endl;
    return 0;
}

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

#define pb push_back
#define ff first
#define ss second

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

int a, b, c;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> a >> b >> c;
	int cnt = 0;
	cnt += (a == b);
	cnt += (a == c);
	cnt += (b == c);
	if (cnt == 1)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
c = list(input())
schw = 0
schr = n-1
ans = 0
while schw < schr:
    while c[schw] != 'W' and schw < n-1:
        schw += 1
    while c[schr] != 'R' and schr > 0:
        schr -= 1
    ans += 1
    c[schw] = 'R'
    c[schr] = 'W'
print(ans - 1)

Measured memory_bytes: 77452
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<numeric>
#include<set>
#include<math.h>
using namespace std;

int N, M;
vector<int> k; // 個数ベクトル
vector<vector<int> > sw; // スイッチベクトル
vector<int> light; // 電球ベクトル
vector<int> p; // 点灯条件ベクトル

int main(){
    cin >> N >> M;
    vector<int> init;
    for(int i = 0; i < N; i++) sw.push_back(init);

    int tmpk, tmps;
    for(int i = 0; i < M; i++){
        cin >> tmpk;
        for(int j = 0; j < tmpk; j++){
            cin >> tmps;
            sw[tmps-1].push_back(i);
        }
    }

    int tmp;
    for(int i = 0; i < M; i++){
        cin >> tmp;
        light.push_back(0);
        p.push_back(tmp);
    }

    int all = (int)pow(2, N);
    int zoro;
    bool pass;
    int count = 0;

    for(int i = 0; i < all; i++){
        for(int j = N - 1; j >= 0; j--){
            zoro = (i % (int)pow(2, j+1)) / (int)pow(2, j);
            if(zoro == 1){
                for(int k = 0; k < sw[j].size(); k++){
                    light[sw[j][k]] += 1; 
                }
            }
        }

        pass = true;

        for(int j = 0; j < M; j++){
            if(light[j] % 2 != p[j]){
                pass = false;
            }
            light[j] = 0;
        }

        if(pass) count++;
    }

    cout << count << "\n";

    return 0;
}

Measured memory_bytes: 384
s = input()
a = int(s[:2])
b = int(s[2:])
if a > 0 and a < 13:
    if b > 0 and b < 13:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if b > 0 and b < 13:
        print('YYMM')
    else:
        print('NA')



Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

//[b, e)
void solve(vll& A, vll& acc, int b, int e, ll& sum1, ll& sum2) {
  ll targetSum2 = acc[e] - acc[b];
  ll ub = e;
  ll lb = b;
  while(ub - lb > 1) {
    ll mid = (ub + lb) / 2;
    ll msum = acc[e] - acc[mid];
    if(msum * 2 >= targetSum2) {
      //見たのがより上
      lb = mid;
    } else {
      ub = mid;
    }
  }
  
  //以上の時
  if(abs((acc[e] - acc[ub]) - (acc[ub] - acc[b])) < abs((acc[e] - acc[lb]) - (acc[lb] - acc[b]))) {
    sum1 = acc[ub] - acc[b];
    sum2 = acc[e] - acc[ub];
  } else {
    sum1 = acc[lb] - acc[b];
    sum2 = acc[e] - acc[lb];
  }
  
  if(sum1 > sum2) swap(sum1, sum2);
}

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  
  vll A(N);
  vll acc(N+1);
  rep(i, N) {
    cin >> A[i];
    acc[i+1] = acc[i] + A[i];
  }
  
  ll diffmin = LLINF;
  //まず2分
  //2個以上存在するのを調べる
  for(int i=2; i<=N-2; i++) {
    ll minsum1, maxsum1;
    solve(A, acc, 0, i, minsum1, maxsum1);
    ll minsum2, maxsum2;
    solve(A, acc, i, N, minsum2, maxsum2);
    chmin(diffmin, max(maxsum1, maxsum2) - min(minsum1, minsum2));
  }
  
  fin(diffmin);
}

Measured memory_bytes: 3328
n = int(input())
s = { "AC" : 0, "WA" : 0, "TLE" : 0, "RE" : 0 }
for i in range(n):
    s_in = input()
    s[s_in] += 1
print("AC x " + str(s["AC"]))
print("WA x " + str(s["WA"]))
print("TLE x " + str(s["TLE"]))
print("RE x " + str(s["RE"]))

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
ll a,b;
int main() {
	int N;
	cin>>N;
	vector<P> ab;
	rep(i,N){
		cin>>a>>b;
		a %= b;
		ab.push_back({a,b});
	}
	printpair(ab);
	ll ans = 0;
	for (int i = N-1; i >= 0; --i){
		a = ab[i].first;
		b = ab[i].second;
		a += ans;
		a %= b;
		if(a == 0){
			continue;
		}
		ans += b - a;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1400
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
const int mod = 1000000007;
int num[100005];
int poss[100005];
long long PowerMod(long long a, long long b, long long c)
{
long long ans = 1;
a = a % c;
while(b>0)
{
if(b % 2 == 1)
ans = (ans * a) % c;
b = b/2;
a = (a * a) % c;
}
return ans;
}
int main()
{
    long long  n;
    memset(poss,0,sizeof(poss));
    cin>>n;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&num[i]);
        poss[num[i]]++;
    }
    if(n%2==0)
    {
        for(int i=1;i<n;i+=2)
        {
            if(poss[i]!=2)
            {
                printf("0\n"); return 0;
            }
        }
        long long  k = n/2;
        cout<<PowerMod(2ll,k,mod)<<endl;
    }
    else
    {
        if(poss[0]!=1) {printf("0\n");return 0; }
        for(int i=2;i<n;i+=2)
        {

            if(poss[i]!=2)
            {
                printf("0\n"); return 0;
            }
        }
            long long  k = n/2;
            cout<<PowerMod(2ll,k,mod)<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
using System;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] WH = Console.ReadLine().Split(' ');

            int[] H = new int[N];
            for(int i=0;i<N;i++)
            {
                H[i] = int.Parse(WH[i]);
            }

            bool flg = false;
            int cnt = 0;
            int maxcnt = 0;
            for(int i = 0;i<N-1;i++)
            {
                if(H[i] >= H[i+1])
                {
                    if(flg == false) { flg = true; cnt = 0; }
                    cnt++;
                }
                else
                {
                    flg = false;
                }
                if(maxcnt < cnt) { maxcnt = cnt; }
            }
            Console.WriteLine(maxcnt);
        }
    }
}


Measured memory_bytes: 25052
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    string S;
    cin>>S;
    if(S.at(0)==S.at(1)){
        if(S.at(2)!=S.at(1)){
            if(S.at(3)==S.at(2)){cout<<"Yes"<<endl;return 0;}
        }
    }
    swap(S.at(1),S.at(2));
    if(S.at(0)==S.at(1)){
        if(S.at(2)!=S.at(1)){
            if(S.at(3)==S.at(2)){cout<<"Yes"<<endl;return 0;}
        }
    }
    swap(S.at(1),S.at(3));
    if(S.at(0)==S.at(1)){
        if(S.at(2)!=S.at(1)){
            if(S.at(3)==S.at(2)){cout<<"Yes"<<endl;return 0;}
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define Mp make_pair
#define pb push_back

using ll = long long;
using db = double;
using pii = pair<int, int>;
using vi = vector<int>;
mt19937 mrand(time(0));
ll get(ll r) { return ((ll)mrand() * mrand() % r + r) % r; }
ll get(ll l, ll r) { return get(r - l + 1) + l; }

signed main() {
    ll d, t, s; cin >> d >> t >> s;
    puts((d + s - 1) / s <= t ? "Yes" : "No");
    fprintf(stderr, "time=%.4f\n", (db)clock()/CLOCKS_PER_SEC);
    return 0;
    /* 取模直接除，爆零两行泪
     * 不开ll见祖宗
     */
}

Measured memory_bytes: 3752
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	while (n--)
	{
		int o;
		cin >> o;
		x = max(x, o);
	}
	while (m--)
	{
		int o;
		cin >> o;
		y = min(y, o);
	}
	if (x < y) puts("No War");
	else puts("War");
	return 0;
}


Measured memory_bytes: 256
n = int(input())
ans_list = [0 for i in range(10**6 + 1)]
for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      a = x**2 + y **2 + z**2 + x*y + z*y + x*z
      ans_list[a] += 1
      
for i in range(1,n+1):
  print(ans_list[i])

Measured memory_bytes: 17012
let [|N; K|] = stdin.ReadLine().Split(' ') |> Array.map int
let n = N - 1
let [|R;S;P|] = stdin.ReadLine().Split(' ') |> Array.map int
let T = stdin.ReadLine().ToCharArray()
let mutable (b:bool[]) = [|for i in 0..N-1 -> false|]

let point a = 
    if a = 'r' then
            P
        else if a = 's' then
        R
        else
        S

let rec sum a = 
    if a = n 
    then point T.[a]
    else
        point T.[a] + sum (a+1)

let mutable s = sum 0
for i in K .. n do
    if T.[i - K] = T.[i] && b.[i - K] = false
        then 
            b.[i] <- true
            s <- s - point T.[i]

s |> printfn "%d"

Measured memory_bytes: 34084
from itertools import combinations
N, K = (list)(map(int, input().split()))
pos_x = []
pos_y = []

for _ in range(N):
    a, b = map(int, input().split())
    pos_x.append(a)
    pos_y.append(b)


def count_point(x, y):
    ret = 0
    x_min = min(x)
    x_max = max(x)
    y_min = min(y)
    y_max = max(y)
    for i in range(N):
        if x_min <= pos_x[i] <= x_max and y_min <= pos_y[i] <= y_max:
            ret += 1
    return ret


def calc_area(x, y):
    ret = (x[1]-x[0])*(y[1]-y[0])
    return (abs)(ret)


set_x = set(pos_x)
set_y = set(pos_y)


area = float('inf')
for cand_x in combinations(set_x, 2):
    for cand_y in combinations(set_y, 2):
        if count_point(cand_x, cand_y) >= K:
            area = min(area, calc_area(cand_x, cand_y))
print(area)


Measured memory_bytes: 53084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a,b;
int main(){
	cin>>n>>a>>b;
	if(a == 1){
		if(b != n) puts("-1");
		else{
			for(int i=n;i>=1;i--) cout<<i<<" ";
			cout<<endl;
			return 0;
		}
	}
	for(int aa=2;aa<=a;aa++){
		int x = n+1-b-aa;
		if(x%(a-1) != 0) continue;
		x /= (a-1);
		if(1LL*a*x+aa > n || x<0) continue;
		if(aa!=a && x==0) continue;
		vector<int>ans;
		for(int i=1;i<=x;i++){
			vector<int>vi;
			for(int j=0;j<a;j++){
				vi.pb(n--);
			}
			reverse(vi.begin(),vi.end());
			rep(i,vi.size()) ans.pb(vi[i]);
		}
		{
			vector<int>vi;
			for(int j=0;j<aa;j++){
				vi.pb(n--);
			}
			reverse(vi.begin(),vi.end());
			rep(i,vi.size()) ans.pb(vi[i]);
		}
		while(n>=1){
			ans.pb(n--);
		}
		rep(i,ans.size()) printf("%d ",ans[i]);
		puts("");
		return 0;
	}
	puts("-1");
}

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

int main() {
int ans=0,n; cin>>n;
  int x[n],v[n];
  for(int i=0;i<n;i++)
  {
    cin>>x[i];
  }
    for(int i=0;i<n;i++)
  {
    cin>>v[i];
  }
    for(int i=0;i<n;i++)
  {
    if(x[i]-v[i]>0)
    {
      ans+=x[i]-v[i];
    }
  }
      cout<<ans<<endl;
}
  
    
    
      

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

struct Task {
	int64_t a;
	int64_t b;
};

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

	int n; cin >> n;

	vector<Task> tasks(n);
	for (auto& task : tasks) {
		cin >> task.a >> task.b;
	}

	sort(tasks.begin(), tasks.end(), [](const Task& lhs, const Task& rhs) {
		return lhs.b < rhs.b;
		});

	int64_t sum = 0;
	for (auto& task : tasks) {
		sum += task.a;
		if (task.b < sum) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;


	return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

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

long long factorial(long long i){ // 階乗
  if(i > 0)
    return i * factorial(i-1);
  else
    return 1;
}

// a^n mod
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n>0) {
    if(n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

// a^(-1) mod
long long modinv(long long a, long long mod) {
  return modpow(a, mod-2, mod);
}

int main() {
  long long N, A, B, C;
  const long long mod = 1000000007;
  cin >> N >> A >> B >> C;

  // N!(mod )をあらかじめ計算しておく
  vector<long long> factmod;
  factmod.push_back(1); // 0! = 1 と定義
  for(int i=1; i<2*N+10; i++) {
    long long tmp = (factmod[i-1]*i) %mod;
    if (tmp<0) tmp+=mod;
    factmod.push_back(tmp);
  }

  // rep内でよく使う数をあらかじめ計算
  long long invAplusB = modinv(A+B, mod);
  long long invFactorialNm1 = modinv(factmod[N-1], mod);
  long long invHandmC = modinv(100-C, mod);
  
  long long mothA = modpow(A, N, mod)%mod * invFactorialNm1%mod * 100 %mod * invHandmC %mod;
  long long mothB = modpow(B, N, mod)%mod * invFactorialNm1%mod * 100 %mod * invHandmC %mod;
  
  long long res = 0;
  
  rep(i, N) {   // A: N, B:i Aで勝つ
    //res += (N+i) * factorial(N-1+i) * pow(A, N) * pow(B, i)/ pow(A+B, N+i) / factorial(N-1) /factorial(i) * 100.0 /  (100.0-C);
    res += (N+i) * factmod[N-1+i]%mod  * modpow(B, i, mod)%mod * modpow(invAplusB, N+i, mod)%mod  * modinv(factmod[i], mod)%mod * mothA%mod;
    res = res % mod;
  }
  rep(i, N) {   //A: i, B: Nで B勝つ
    //res += (N+i) * factorial(N-1+i) * pow(B, N) * pow(A, i)/ pow(A+B, N+i) / factorial(N-1) /factorial(i) * 100.0 /  (100.0-C);
    res += (N+i) * factmod[N-1+i]%mod * modpow(A, i, mod)%mod * modpow(invAplusB, N+i, mod)%mod * modinv(factmod[i], mod)%mod * mothB % mod;
    res = res % mod;
  }

  if(res<0) res += mod;
  
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 2420
from collections import*
class POTENTIAL_UNION_FIND(object):
    def __init__(self, n):
        self.parent = [-1 for i in range(n)]#非負なら親ノード，負ならグループの要素数
        self.diff_p = [0 for i in range(n)]#親ノードを基準としたポテンシャル
 
    def root(self, x): #root(x): xの根ノードを返す
        if self.parent[x] < 0:
            return x
        else:
            rx = self.root(self.parent[x]) #xをxの根rxに直接つなぎたい
            self.diff_p[x] += self.diff_p[self.parent[x]] #そのために，diff(rx,x)を計算
            self.parent[x] = rx #xをrxに直接つなげる
            return rx
 
    def size(self,x): #size(x): xのいるグループの要素数を返す
        return -self.parent[self.root(x)]

    def merge(self, x, y, dxy): #ポテンシャル差の条件p(y)-p(x)=dxyでxとyのグループをまとめる
        rx = self.root(x) #rxを新たにxと名づける
        ry = self.root(y) #ryを新たにyと名づける
        dxy += self.diff_p[x] - self.diff_p[y] #dxyをdiff(rx,ry)で置き換え
        x,y=rx,ry
        if x == y:
            return False
        if self.parent[x] > self.parent[y]: #xの要素数がyの要素数より「小さい」とき入れ替える
            x,y,dxy=y,x,-dxy
        self.parent[x] += self.parent[y] #xの要素数を更新
        self.parent[y] = x #yをxにつなぐ
        self.diff_p[y] = dxy #yの相対ポテンシャルを更新
        return True
 
    def issame(self, x, y): #issame(x,y): xとyが同じグループにあるならTrue
        return self.root(x) == self.root(y)
        
    def diff(self,x,y): #diff(x,y): xを基準としたyのポテンシャルを返す 
        if self.root(x) == self.root(y): #この時点でxの親はroot(x)
            return self.diff_p[y] - self.diff_p[x]
        else:
            return None


n,m=map(int,input().split())
u=POTENTIAL_UNION_FIND(n)
d=defaultdict(int)
for i in range(m):
    a,b,c=map(int,input().split())
    d[(a-1,b-1)]=c
    u.merge(a-1,b-1,c)
for k,v in d.items():
    if v!=u.diff(*k):
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 54472
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define inf = 1e9 + 5;

template <typename T,
          typename = typename enable_if<is_arithmetic<T>::value, T>::type>
void pvec(vector<T> &t) {
  cout << "[";
  for (T &i : t) {
    cout << i << " ";
  }
  cout << "]\n";
}

template <typename T,
          typename = typename enable_if<is_arithmetic<T>::value, T>::type>
void pvec2(vector<vector<T>> &t) {
  cout << "[\n";
  for (auto &i : t) {
    pvec(i);
  }
  cout << "]\n";
}

void solve(long long N, vector<vector<ll>> v) {
  auto dp = vector<vector<ll>>(N, vector<ll>(3, 0));
  for (ll i = 0; i < N; i++) {
    for (auto j : {0, 1, 2}) {
      if (i == 0)
        dp[i][j] = v[i][j];
      else {
        for (auto k : {0, 1, 2}) {
          if (k == j)
            continue;
          dp[i][j] = max(dp[i][j], dp[i - 1][k]);
        }
        dp[i][j] += v[i][j];
      }
    }
  }
  cout << *max_element(dp.back().begin(), dp.back().end()) << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  auto v = vector<vector<ll>>(N, vector<ll>(3, 0));
  for (int i = 0; i < N; i++) {
    scanf("%lld", &v[i][0]);
    scanf("%lld", &v[i][1]);
    scanf("%lld", &v[i][2]);
  }
  solve(N, std::move(v));
  return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <vector>

#define avoidminus(a) ((a) < 0 ? 0 : (a))

using namespace std;

const int MOD = 2019;
vector<int> power10;

void power10init(void){
    int a=1;
    for(int i=0; i<200000; i++){
        power10.push_back(a);
        a *= 10;
        a %= MOD;
    }
    return;
}

int main(void){
    string S;
    cin >> S;
    vector<int> MODcount(2019, 0);

    power10init();
    int curmod = 0;

    MODcount[0]++;

    for(int i=0; i<S.size(); i++){
        curmod += power10[S.size()-i-1]*(S[i]-'0')%MOD;
        curmod %= MOD;
        MODcount[curmod]++;
    }

    long long res = 0LL;
    for(int i=0; i<2019; i++){
        int resbuf= avoidminus(MODcount[i]-1);
        res += (long long)resbuf*(resbuf+1)/2;
    }

    cout << res << endl;

    return 0;
}

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

int main(){
      int n;cin >> n;
      string s;cin >> s;
      if(n & 1)return cout << "No", 0;
      for(int i = 0;i < n / 2;i++){
            if(s[i] != s[n / 2 + i])return cout << "No", 0;
      }
      cout << "Yes";
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>

using namespace std;

#define SPACE 0
#define BOMB 1
#define EXP -1

void disp_map (vector <vector <int> > m )
{
	int size = m.size();
	int len  = m[0].size();
	int i,j;

	for (i = 3; i < size - 3; ++i){
		for (j = 3; j < len - 3; ++j){
//			cout << setw(2) << m[i][j] << ' ';
			cout << m[i][j];
		} // end for
		cout << endl;
	} // end for
//	cout << endl;
}
void explosion (vector <vector <int> >& m, int by, int bx )
{
	const int dir[][2] = { {-1, 0 }, { 0, 1 }, { 1, 0 }, { 0, -1 } }; // up right down left
	int i,k;

	m[by][bx] = EXP;

	for (k = 0; k < 4; ++k){
		for (i = 1; i <= 3; ++i){
			if (m[by + i*dir[k][0]][bx + i*dir[k][1]] == BOMB){
				explosion (m, by + i*dir[k][0], bx + i*dir[k][1] );
			} // end if
			m[by + i*dir[k][0]][bx + i*dir[k][1]] = EXP;
		} // end for
	} // end for 
/*
		if (m[by-i][bx] == 1){
			explosion (m, by - i, bx );
		} // end if
		m[by-i][bx] = -1;
		if (m[by+i][bx] == 1){
			explosion (m, by + i, bx );
		} // end if
		m[by+i][bx] = -1;
		if (m[by][bx-i] == 1){
			explosion (m, by, bx - i );
		} // end if
		m[by][bx-i] = -1;
		if (m[by][bx+i] == 1){
			explosion (m, by, bx + i );
		} // end if
		m[by][bx+i] = -1;
*/

}
	
void remain_bomb (vector <vector <int> >& m )
{
	int size = m.size();
	int len  = m[0].size();
	int i,j;

	for (i = 0; i < size; ++i){
		for (j = 0; j < len; ++j){
			if (m[i][j] == EXP){
				m[i][j] = SPACE;
			} // end if
		} // end for
	} // end for
}
		 
int main()
{
//	cut here before submit 
//	freopen("testcase.bomb", "r", stdin);
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;
	int k;
	
	for (k = 0; k < n; ++k){
		getline (cin, str );

		vector <vector <int> > M (8 + 6, vector <int> (8 + 6, SPACE ) );
		int i,j;
		for (i = 0; i < 8; ++i){
			getline (cin, str );
			for (j = 0; j < 8; ++j){
				M[i+3][j+3] = str[j] - '0';
			} // end for
		} // end for
		getline (cin, str );
		int bx, by;
		stringstream ssx (str );
		ssx >> bx;
		getline (cin, str );
		stringstream ssy (str );
		ssy >> by;
		
//		disp_map (M );
//		cout << '(' << bx << ',' << by <<')' << endl;
		explosion (M, by + 3 - 1, bx + 3 - 1 );
//		disp_map (M );

		remain_bomb (M );
		cout << "Data " << (k+1) << ':' << endl;
		disp_map (M );

	} // end loop

//	cout << res << endl;	
		
	return 0;
}

Measured memory_bytes: 0
n=int(input())
k=2
while n>=k*(k-1)/2:
    if n==k*(k-1)/2:
        print('Yes')
        print(k)
        a=list([] for i in range(k))
        t=1
        for i in range(0,k):
            for j in range(1,k-i):
                a[i].append(t)
                a[i+j].append(t)
                t+=1
        for i in range(k):
            print(str(k-1)+" "+" ".join(map(str,a[i])))
        exit()
    else:
        k+=1
print('No')

Measured memory_bytes: 9052
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <map>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i;
	string s;
	map<string, int> mp;
	cin >> num;
	rep(i, num) {
		cin >> s;
		mp[s];
	}
	cout << mp.size() << "\n";
	return 0;
}

Measured memory_bytes: 19176
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

class UnionFind {
public:
    vector<int> parent;  //親ノード
    vector<int> Siz;  //集合の大きさ

    // コンストラクタ
    UnionFind(int n): parent(n), Siz(n, 1) {
        rep(i, n) {
            parent[i] = i;
        }
    }

    // n要素で初期化
    void init(int n) {
        parent.resize(n);
        Siz.assign(n, 1);
        rep(i, n) {
            parent[i] = i;
        }
    }

    // xの属する集合の根を求める
    int root(int x) {
        if(parent[x] == x) {
            return x;
        }
        else {
            return parent[x] = root(parent[x]);
        }
    }

    // xとyの属する集合を併合
    void unite(int x, int y) {

        x = root(x);
        y = root(y);
        if(x == y) {
            return;
        }

        if(Siz[x] < Siz[y]) {
            swap(x, y);
        }

        Siz[x] += Siz[y];
        parent[y] = x;
    }

    // xとyが同じ集合に属するかどうか
    bool same(int x, int y) {
        return root(x) == root(y);
    }

    // xの属する集合の要素数を求める
    int size(int x) {
        return Siz[root(x)];
    }
};

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

    vector<int> a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    UnionFind Uni(n);

    int ans = 0;
    rep(i, m) {
        Uni.init(n);
        rep(j, m) {
            if(j == i) {
                continue;
            }
            Uni.unite(a[j], b[j]);
        }
        if(Uni.size(0) < n) {
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define speedX ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout<< name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_time() cout << "\n\nTime of execution: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define trace(...)
#define end_time()
#endif


#define int long long 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
inline bool equals(ld a, ld b) {return fabs(a - b) < 1e-9;}
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define mod 1000000007

int gcd(int a,int b)
{ while((a)!=0 && (b)!=0){ if((a)>(b)) (a)%=(b); else (b)%=(a);} return ((a)==0 ?(b):(a));}
void solve(){
	int a,b;
	cin>>a>>b;
	int ans = (a*b)/gcd(a,b);
	cout<<ans<<"\n";
}
signed main(){
	speedX;
	#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	end_time();
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    static int[] bits;
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        bits=new int[5];
        int a=sc.nextInt();
        int b=sc.nextInt();
        int tmp;
        int ans=0;
        for(int i=0;i<n;i++){
            update(0);
            tmp=0;
            for(int j=0;j<5;j++){
                tmp+=bits[j];
            }
            if(a<=tmp&&b>=tmp){
                ans+=i+1;
            }
        }
        System.out.println(ans);
 
    }
    static void update(int pointer){
        
        if(bits[pointer]==9){
            bits[pointer]=0;
            update(pointer+1);
            
        }else{
            bits[pointer]++;
        }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;
bool flg = false;

void query(ll n, string s){
	if(n == s.length()) flg = true;
	string t;
	t = s.substr(n, 5);
	if(t == "dream") query(n+5, s);
	if(t == "erase") query(n+5, s);
	t = s.substr(n, 6);
	if(t == "eraser") query(n+6, s);
	t = s.substr(n, 7);
	if(t == "dreamer") query(n+7, s);
}

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

	query(0, s);
	if(flg) puts("YES");
	else puts("NO");

	return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=2e5+5;
vector<ll> dp(N);
int main(){
    int n;
    cin>>n;
    int base=1;
    while(base<=n){
        base<<=1;
    }
    vector<ll> tree(2*base);
    int h[n],a[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        int x=h[i]+base;
        ll best=0;
        while(x>1){
            if(x%2==1){
                best=max(best,tree[x-1]);
            }
            x>>=1;
        }
        dp[h[i]]=best+a[i];
        for(int j=base+h[i];j>=1;j>>=1){
            tree[j]=max(tree[j],dp[h[i]]);
        }

    }
    cout<<*max_element(dp.begin(),dp.end())<<endl;

}

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

#define INF 1e9
using namespace std;
using ll = long long;

int main() {

    ll n, d, x; cin >> n >> d >> x;

    ll ans = x;
    for (ll i = 0; i < n; ++i) {
        ll a;
        cin >> a;

        for (int j = 1; j <= d; j+=a) {
            ++ans;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
 
int main(){
  int i,r,n,min,max=-(pow(10,9));
 
  scanf("%d",&n);
  //r=(int *)malloc(sizeof(int)*n);
 
  scanf("%d",&min);
  max=max-min;
  for(i=1;i<n;i++){
    scanf("%d",&r);
    if(max<r-min) max=r-min;
    if(min>r){
      min=r;
      // printf("min:%d\n",min);
    }
  }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int x,sum=0,ans;
    for(int i=1;i<=m;i++)
    {
        cin>>x;
        sum+=x;
    }
    ans=n-sum;
    if(ans>=0)
        cout<<ans<<endl;
    else
        cout<<"-1"<<endl;

}


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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for(int i = 0; i<N;i++){
    cin >> S.at(i);
  }
  int M;
  cin >> M;
  vector<string> T(M);
  for(int i = 0; i<M;i++){
    cin >> T.at(i);
  }
 
  int ans = 0;
  for(int i = 0;i<N;i++){
    int c = 0;
    for(int j = 0;j<N;j++){
      if(S.at(i) == S.at(j)) c++;
    }
    for(int j =0;j<M;j++){
      if(S.at(i) == T.at(j)) c--;
    }
    ans = max(ans,c);
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const long long INF = 1LL << 60;

char a;

int main()
{
  cin >> a;
  if(isupper(a)) cout << "A" << endl;
  else cout << "a" << endl;
}

Measured memory_bytes: 3612