akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

struct block {
    ll w, s, v;

    block() : w(0), s(0), v(0) {}

    bool operator<(const block& other) const {
        return w + s > other.w + other.s;
    }
};

const int MAXN = 1000, MAXS = 10000;

int N;
ll dp[MAXN][MAXS + 1];
vector<block> b;

ll tower(int i, int j) {
    if (i == N || j == 0)
        return 0;
    if (dp[i][j] == -1) {
        dp[i][j] = tower(i + 1, j);
        if (b[i].w <= j)
            dp[i][j] = max(dp[i][j], b[i].v + tower(i + 1, min(b[i].s, j - b[i].w)));
    }
    return dp[i][j];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N;
    b.resize(N);
    for (int i = 0; i < N; i++)
        cin >> b[i].w >> b[i].s >> b[i].v;
    sort(b.begin(), b.end());
    memset(dp, -1, sizeof dp);
    ll result = 0;
    for (int i = 0; i < N; i++)
        result = max(result, b[i].v + tower(i + 1, b[i].s));
    cout << result << endl;
}


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

typedef long long ll;
#define OO 1e9
using namespace std;
vector<vector<int>> adj;
vector<int> top;
vector<int> indegree;
vector<bool> done;
void topsort(int u){
  if(done[u])return;
  done[u] = 1;
  top.push_back(u);
  for(auto el : adj[u]){
    indegree[el]--;
    if(indegree[el] == 0)
      topsort(el);
  }
}

int main(){
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n, m;
  cin >> n >> m;
  adj.resize(n);
  indegree.resize(n);
  done.resize(n);
  for(int i = 0;i < m;i++){
    int u, v;
    scanf("%d %d", &u, &v);
    u--, v--;
    indegree[v]++;
    adj[u].push_back(v);
  }

  for(int i = 0;i < n;i++)
    if(indegree[i] == 0)
      topsort(i);
  vector<int> dp(n);
  int res = 0;
  for(int i = n - 1;i >= 0;i--){
    dp[top[i]] = 0;
    for(auto el : adj[top[i]])
      dp[top[i]] = max(dp[top[i]], dp[el] + 1);
    res = max(res, dp[top[i]]);
  }

  cout << res;

}


Measured memory_bytes: 11768
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node{int p,l,r;};
Node T[MAX];
int D[MAX];

void print(int i){
	cout << "node " << i << ": parent = ";
	cout << T[i].p << ", depth = " << D[i] << ", ";
	if(T[i].p==NIL)cout << "root";
	else if(T[i].l==NIL)cout << "leaf";
	else cout << "internal node";

	cout << ", [";

	int c=T[i].l;
	for(int i=0;c!=NIL;i++,c = T[c].r){
		cout << (i?", ":"") << c;
	}
	cout << "]" << endl;
}

void rec(int u,int d){
	D[u] = d;
	if(T[u].r != NIL)rec(T[u].r,d);
	if(T[u].l != NIL)rec(T[u].l,d+1);
}

int main(){
	int n,i,k,r,a=NIL,b=NIL;
	cin >> n;
	for(int j=0;j<n;j++)T[j].p=T[j].l=T[j].r=NIL;
	for(int s=0;s<n;s++){
		cin >> i >> k;
		for(int j=0;j<k;j++){
			b = a;
			cin >> a;
			if(j==0)T[i].l = a;
			else T[b].r = a;
			T[a].p = i;
		}
	}
	for(int j=0;j<n;j++){
		if(T[j].p == NIL) r=j;
	}

	rec(r,0);
	for(int j=0;j<n;j++)print(j);

	return 0;
}



Measured memory_bytes: 7660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector < long long > vll;
typedef pair < long long, long long > pll;
typedef pair < int, int > pii;
typedef vector < int > vi;
#define deb(x) cout << #x << " : " << x << endl
#define deb2(x , y) cout << #x << " : " << x << " , "<< #y << " : " << y << endl
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,a,n) for(int i = a; i < n; i++)
#define rsz(x,n) x.clear(); x.resize(n)
#define rrsz(x,a,n) x.clear(); x.resize(n,a)
#define wt while(true)
#define all(x) x.begin(),x.end()
#define pb push_back
#define csl ios_base::sync_with_stdio(false); cin.tie(NULL)
#define s(n) cin >> n
#define ls(x) ((2*(x)) + 1)
#define rs(x) ((ls(x)) + 1)
#define md(a,b) ((b)+((a) - (b))/2)
#define INF (1e9 + 7)
#define endl '\n'

void solve() {
	int n,k;
	cin>>n>>k;
	vll h(n),arr(n,INF);
	rep(i,n){
		cin>>h[i];
	}
  	arr[0]=0;
	rep(i,n){
		for(int j=1;j<=k&&(i-j)>=0;j++){
          arr[i]=min(arr[i],arr[i-j]+abs(h[i]-h[i-j]));
        }
	}
	cout<<arr[n-1];
}

int main() {
	csl;
	int testcase=1;
//	cin >> testcase;
	for (int i = 0; i < testcase; i++) {
		solve();
	}
	return 0;
}



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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
		set<int > A;
	int X, N;
	cin >> X >> N;
	fx(N) {
		int a;
		cin >> a;
		A.insert(a);
	}
	int ans = X, min = INT_MAX;
	fyg(200,-200) {
		if (A.count(y)) {
			continue;
		}
		if (abs(y-X)<min) {
			min = abs(y - X);
			ans = y;
		}
	}
	ce(ans)
    return 0;
}



Measured memory_bytes: 3632
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, p = map(int, input().split())
    mate = a * 3 + p
    print(mate // 2)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main(){
	int n = read();
	ld sum = 0;
	for (int i = 0; i < n; i++) {
		ld k;
		cin >> k;
		string s;
		cin >> s;
		if (s == "JPY") {
			sum += k;
		}
		else {
			sum += k * 380000;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  ll N,D;
  cin >> N >> D;
  ll ans = 0;
  rep(i, N){
    ll x,y;
    cin >> x >> y;
    if (x*x + y*y <= D*D) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  long long int x;
  cin>>x;
  long long int a[10000];
  a[0]=100;
  for(int i=1;i<=9999;i++){
  	a[i]=a[i-1]*1.01;
  	if(a[i]>=x){
  		cout<<i;
  		return 0;
  	}
  }
  

}

Measured memory_bytes: 3680
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,a[100000],minus_count = 0;
    int i,j;

    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
        if(a[i] < 0)minus_count++;
    }
    
    long long ans = 0,min = 2000000000;
    for (i = 0; i < n; i++)
    {
        ans += abs(a[i]);
        if(min > abs(a[i]))min = abs(a[i]);
    }
    
    if(minus_count % 2 == 0)
    {
        printf("%lld",ans);
    }
    else
    {
        printf("%lld",ans - min * 2);
    }
    
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a[]={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};
  int k;
  cin>>k;
  k=k-1;
  cout<<a[k]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for(int i = 0; i < h; i++){
      cin >> s[i];
  }
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(s[i][j] == '#'){
        if(i > 0 && s[i - 1][j] == '#')continue;
        if(i < h - 1 && s[i + 1][j] == '#')continue;
        if(j > 0 && s[i][j - 1] == '#')continue;
        if(j < w - 1 && s[i][j + 1] == '#')continue;
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<int> a(n), s, t;
	rep(i,n){
		cin >> a[i];
		if(a[i] < 0) t.push_back(a[i]);
		else s.push_back(a[i]);
	}
	int S = s.size();
	int T = t.size();
	bool ok = false;
	if(S > 0){
		if(n == k) ok = (T%2 == 0);
		else ok = true;
	}
	else{
		ok = (k%2 == 0);
	}
	mint ans = 1;
	if(!ok){
		sort(a.begin(), a.end(), [](int x, int y){
			return abs(x) < abs(y);
		});
		rep(i,k) ans *= a[i];
	}
	else{
		sort(s.begin(), s.end());
		sort(t.rbegin(), t.rend());
		if(k%2 == 1){
			ans *= s.back();
			s.pop_back();
		}
		vector<ll> p;
		while(s.size() >= 2){
			ll x = s.back();
			s.pop_back();
			x *= s.back();
			s.pop_back();
			p.push_back(x);
		}
		while(t.size() >= 2){
			ll x = t.back();
			t.pop_back();
			x *= t.back();
			t.pop_back();
			p.push_back(x);
		}
		sort(p.rbegin(), p.rend());
		rep(i,k/2) ans *= p[i];
	}
	cout << ans.x << endl;
	return 0;
}

Measured memory_bytes: 6392
#include<iostream>

using namespace std;

int main()
{
	int a, acont = 0;
	int b, bcont = 0;
	
	for(int i = 0; i < 4; i++){
		cin >> a;
		acont += a;
	}
	for(int i = 0; i < 4; i++){
		cin >> b;
		bcont += b;
	}
	cout << ((a > b) ? acont : bcont) << endl;
}
	

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int n, ans;
vector<int> adj[1005];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    cin>>n;
    f(i, n) {
        f(j, n - 1){
            int tt;
            cin>>tt;
            adj[i].pb(tt - 1);
        }
        r(adj[i]);
    }
    int curr_day = 1;
    while(1) {
        vector<bool> taken(n, false);
        bool none = true;
        int cnt = 0;
        f(i, n) {
            if(adj[i].empty()) {
                cnt++;
                continue;
            }
            if(taken[i]) continue;
            //cout<<i<<' '<<adj[i].back()<<' '<<adj[adj[i].back()].back()<<endl;
            if(adj[adj[i].back()].back() == i && !taken[adj[i].back()]) {
                taken[i] = taken[adj[i].back()] = true;
                adj[adj[i].back()].pop_back();
                adj[i].pop_back();
                none = false;
            }
        }
        if(cnt == n) {
            cout<<curr_day - 1;
            return 0;
        }
        if(none) {
            cout<<"-1";
           return 0;
        }
        curr_day++;
    }
    return 0;
}

Measured memory_bytes: 6400
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

namespace Solver {
    int N;
    vector<int> n, d;
    inline bool Read() {
        cin >> N;
        if (N == 0) return false;

        n.resize(N);
        d.resize(N);
        for (int i = 1; i < N; i++) {
            cin >> n[i] >> d[i];
        }

        return true;
    }

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

    inline void Work() {
        vector<int> posX(N), posY(N);
        posX[0] = posY[0] = 0;

        int minX = 0, minY = 0, maxX = 0, maxY = 0;
        for (int i = 1; i < N; i++) {
            posX[i] = posX[n[i]] + dx[d[i]];
            posY[i] = posY[n[i]] + dy[d[i]];

            minX = min(posX[i], minX);
            minY = min(posY[i], minY);
            maxX = max(posX[i], maxX);
            maxY = max(posY[i], maxY);
        }

        cout << (maxX - minX + 1) << " " << (maxY - minY + 1) << std::endl;
    }

    inline void Solve() {
        while(Read()) Work();
    }
}

int main() {
    Solver::Solve();
}

Measured memory_bytes: 1224
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll dp[110][110][110];

int main() {
  rep(i,0,110)rep(j,0,110)rep(k,0,110)dp[i][j][k] = 10000000;
  ll a,b,c;
  cin>>a>>b>>c;
  dp[a][b][c] = 0;
  rep(i,0,110){
    rep(j,0,110){
      rep(k,0,110){
        if(i-1>=0&&j-1>=0)dp[i][j][k] = min(dp[i][j][k],dp[i-1][j-1][k]+1);
        if(i-1>=0&&k-1>=0)dp[i][j][k] = min(dp[i][j][k],dp[i-1][j][k-1]+1);
        if(j-1>=0&&k-1>=0)dp[i][j][k] = min(dp[i][j][k],dp[i][j-1][k-1]+1);
        if(i-2>=0)dp[i][j][k] = min(dp[i][j][k],dp[i-2][j][k]+1);
        if(j-2>=0)dp[i][j][k] = min(dp[i][j][k],dp[i][j-2][k]+1);
        if(k-2>=0)dp[i][j][k] = min(dp[i][j][k],dp[i][j][k-2]+1);
      }
    }
  }
  ll mn = 10000000;
  rep(i,0,110){
    mn = min(mn,dp[i][i][i]);
  }
  cout << mn << endl;
  return 0;
}

Measured memory_bytes: 10624
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int n,ans=1;
	cin>>n;
	vector<int>a(n);
	rep(i,n)cin>>a[i];
	rep(i,n)if(a[i]%2==0&&a[i]%3&&a[i]%5)ans=0;
	if(ans)cout<<"APPROVED";
	else cout<<"DENIED";
	return 0;
}

Measured memory_bytes: 256
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, a, b, c, d = inintm()
s = input()

if c < d:
    if "##" not in s[a-1:d-1]:
        print("Yes")
    else:
        print("No")
else:
    if ("..." in s[b-2:d+1]) and ("##" not in s[a-1:c-1]):
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 9376
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s=scan.nextLine();
		String t="";
		t+=s.charAt(5);
		t+=s.charAt(6);
		int a=Integer.parseInt(t);
		//System.out.println(a);
		if(a<=04) System.out.println("Heisei");
		else System.out.println("TBD");
	}

}


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

using namespace std;

int main()
{
  int n, m;
  cin >> n >> m;
  
  map<int, int> map;
  for(int i=0; i<n; i++){
    int a, b;
    cin >> a >> b;
    map[a] += b;
  }
  //for(auto i : map)
  //  cout << i.first << " " << i.second << endl;
  
  int count = 0;
  long long price = 0;
  for(auto i : map){
    long long num = i.second;
    if(count + num <= m){
      price += (long long)i.first * num;
      count += num;
      //printf("%d x %lld  -> %lld %d\n", i.first, num, price, count);
    }
    else{
      num = m - count;
      price += (long long)i.first * num;
      //printf("%d x %lld  -> %lld %d\n", i.first, num, price, count);
      break;
    }
  }
  cout << price << endl; 
    
  return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define f(a,b,i) for(ll i=a;i<b;i++)
#define rf(a,b,i) for(ll i=a;i>b;i--)
ll dp[100005]={0};
ll h[100005]={0};
ll tik(ll a)
{
    if(a<0)
    return 0 ;
    return a;
}
ll fun(ll a,ll k){
    ll res=1e15;
    f(1,k+1,i)
    if(a-i>0)
    res=min(res,dp[a-i] + abs(h[a-i]-h[a]));
    return res;
}
int main()
{
    ll n,k;
    cin>>n>>k;
    f(1,n+1,i)
    cin>>h[i];
    dp[1]=0;
    dp[0]=1e10;
    f(2,n+1,i)
    dp[i]=fun(i,k);
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 5184
// ConsoleApplication7.cpp : ??????????????? ??¢????????±????????§????????¨????????? ?????????????????????????????????
//

#include <stdio.h>

int main(int argc, char* argv[])
{
	double r;
	double syu, men;
	const double pi = 3.141592653589793;
	char temp[100];

	fgets(temp, sizeof(temp), stdin);
	sscanf(temp, "%lf", &r);

	syu = 2 * pi * r;
	men = pi * r * r;
	
	printf("%0.6f %.6f\n", men, syu);
	
	return 0;
}

Measured memory_bytes: 2672
#include <bits/stdc++.h>
using namespace std;
int main() {
  int  X,A,B;
  cin >> X >> A >> B;
  if (A >= B){
    cout << "delicious" << endl;
  }
  else if (A+X >= B){
    cout << "safe" << endl;
  }
  else {
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 3604
#include <iostream>
#include <math.h>
using namespace std;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main(void) {
  int X; cin >> X;
  int ans = 0;
  if(IsPrime(X)) {
      cout << X << endl;
      return 0;
  }
  while(!IsPrime(X++)) ans = X;
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 210000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
// long long C(int a,int b){
// 	if(a<b||b<0)return 0;
// 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
// }
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ

int main(){
	int a,b,c,d;scanf("%d%d%d%d",&a,&b,&c,&d);
	printf("%d\n",(a-c)*(b-d));
}

Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

//0020
int main(){
	string str;

	getline(cin, str);
	for(int i=0; i<str.size(); ++i){
		if(str[i]=='\0')break;

		if(isalpha(str[i])){
			str[i] = toupper(str[i]);
		}
	}
	cout << str << endl;
}

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

int main(void){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int x=i;
        if(x%3==0){
            cout<<" "<<i;
            continue;
        }
        while(x!=0){
            if(x%10==3){
                cout<<" "<<i;
                break;
            }
            x/=10;
        }
    }
    cout<<endl;
}



Measured memory_bytes: 3100
S = input()
T = input()

ans = len(T)

for i in range(len(S)-len(T)+1):
    tmp = ans
    tmp = 0
    for j in range(len(T)):
        if S[i+j] != T[j]:
            tmp += 1
    if tmp < ans:
        ans = tmp
    if ans == 0:
        break
print(ans)


Measured memory_bytes: 73076
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <unordered_set>

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define vii vector<int>
#define vip vector<pair<int,int> >
#define pb push_back


int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //#ifndef ONLINE_JUDGE
    //   freopen("out.txt", "r", stdin);
    //   freopen("output.txt", "w",stdout);
    //#endif

    //int tc;
    //cin>>tc;
    //while(tc--)
    //{

        int n,m;bool f=1;
        cin>>n>>m;
        vii no(n,-1);
        vii s(m),c(m);
        for(int i=0;i<m;++i) {cin>>s[i]>>c[i];--s[i];}

        for(int i=0;i<m;++i)
        {
            if(no[s[i]]==-1||no[s[i]]==c[i])
            no[s[i]]=c[i];
            else
                {f=0;break;}
        }
        if(no[0]==0&&n!=1) f=0;
        if(f){
        for(int i=0;i<n;++i)
        {
            if(no[i]==-1)
                no[i]=0;

        }}
        if(no[0]==0&&n!=1) no[0]=1;


        if(f)
            for(int i:no)
            cout<<i;
        else
            cout<<-1;



    //}


    return 0;
}


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

class Cube{
public:
    int f[6];
    Cube(){}
    void roll_z(){roll(1,2,4,3);} 
    void roll_y(){roll(0,2,5,3);} //to W
    void roll_x(){roll(0,1,5,4);} //to N
    void roll(int i,int j,int k,int l){
        int tmp=f[i]; f[i]=f[j]; f[j]=f[k]; f[k]=f[l]; f[l]=tmp;
    }
    void move(char ch){
        if(ch=='E') for(int i=0;i<3;i++)roll_y();
        if(ch=='W') roll_y();
        if(ch=='N') roll_x();
        if(ch=='S') for(int i=0;i<3;i++) roll_x();
    }
};

//???????????????????????????????????????????????????????????????????????¢??°
bool eq(Cube c1,Cube c2){
    for(int i=0;i<6;i++)
        if(c1.f[i]!=c2.f[i])return false;
    return true;
}

bool equal(Cube c1,Cube c2){
    for(int i=0;i<6;i++){
        for(int j=0;j<4;j++){
            if(eq(c1,c2))return true;
            c1.roll_z();
        }
        if(i%2==0)c1.roll_y();
        else c1.roll_x();
    }
    return false;
}

int main(void){
    Cube c1,c2;
        
    for(int i=0;i<6;i++)cin>>c1.f[i];
    for(int i=0;i<6;i++)cin>>c2.f[i];
    
    if(equal(c1,c2))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> A(6);
  for (int i = 0; i < 6; i++) {
    cin >> A.at(i);
  }
  map<int, int> cnt;
  for (int x : A) {
    if (cnt.count(x)) {
      cnt.at(x)++;
    } else {
      cnt[x] = 1;
    }
  }

  bool ans = true;
  for (auto p : cnt) {
    auto value = p.second;
    if (value == 0 or value == 3) {
      ans = false;
    }
  }
  if (ans) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  int ans = -1;
  for(int i=0; i<10; i++){
    int n = b * 10 + i;
    if((n * 8 / 100) == a) {
      ans = n;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/* Filename: ARC061C.java
 * Author: Mushiyo
 */

import java.util.Scanner;

public class Main{

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

		while (input.hasNext()) {
			String S = input.next();
			
			System.out.println(sum(S, 0, 0, 1));
		}
	}
	
	private static long sum(String S, long currentSum, int prevPlus, int pos){
		if(pos == S.length()){
			return currentSum + Long.parseLong(S.substring(prevPlus, pos));
		}
		
		return sum(S, currentSum + Long.parseLong(S.substring(prevPlus, pos)), pos, pos + 1)
				+ sum(S, currentSum, prevPlus, pos + 1);
	}
}


Measured memory_bytes: 8660
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
int count=0;
for(int i=1000;i>0;i--)
{
if(a%i==0&&b%i==0){count++;}
if(count==c){printf("%d\n",i); break;}
}
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
using namespace std;
typedef long long LL;
LL n;
int main(){
    cin>>n;
    for(int i=sqrt(n);i;i--){
        if(n%i==0){
            LL j=n/i;
            cout<<j+i-2;
            return 0;
        }
    }
}

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

using namespace std;
using ll = long long;


int main()
{
    int q;
    cin >> q;
    vector<int> ans;

    while(q--) {

        string s, t;
        cin >> s >> t;
        int n = s.size(), m = t.size();
        vector<vector<int>> dp(n + 1, vector<int>(m + 1)); //dp[i][j] := sのi文字目, tのj文字目まで見た時の最長
        
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {

                if(s[i] == t[j]) {
                    dp[i + 1][j + 1] = max({dp[i + 1][j], dp[i][j + 1], dp[i][j] + 1});
                }else{
                    dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
                }
            }
        }
        ans.push_back(dp[n][m]);
    }
    for(auto i : ans) {
        cout << i << endl;
    }

}


Measured memory_bytes: 6724
#if 0
N間違い
#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int N, M;
int C[25];
int cnt[25][50010];

int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) cin >> C[i];
  sort(C, C+M);
  for (int i = 0; i < M; i++) {
    for (int c = 0; c <= N; c++) {
      if (i == 0)
        cnt[i][c] = c;
      else if (c == 0)
        cnt[i][c] = 0;
      else if (c-C[i] < 0)
        cnt[i][c] = cnt[i-1][c];
      else {
        cnt[i][c] = min(1 + cnt[i][c-C[i]], cnt[i-1][c]);
      }
    }
  }
  cout << cnt[M-1][N] << endl;
}



Measured memory_bytes: 7072
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cmath>
#include <vector>
using namespace std;

int main()
{
    int n,d,x,sum=0;
    cin>>n>>d>>x;
    int a[n+1];
    for (int i=1; i<=n; i++) cin>>a[i];
    sum+=x;
    for (int i=1; i<=n; i++)
    {
        for (int j=1; j<=d; j+=a[i]) sum++;
    }
    cout<<sum<<'\n';
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc107_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();
            int x = input[0];
            int y = input[1];

            string[,] arr = new string[x, y];

            //データを入力
            for(int i=0; i<x; i++){
                string str = Console.ReadLine();
                for(int j=0; j<y; j++){
                    arr[i,j] = str[j].ToString();
                }
            }

            var row = new List<int>();    // #が一つでも入っている列
            var colomn = new List<int>(); // #が一つでも入っている行

            //横に'#'が含まれているか
            for(int i=0; i<x; i++){
                for(int j=0; j<y; j++){
                    if(arr[i,j] == '#'.ToString()){
                        colomn.Add(i);
                        break;
                    }
                }
            }

            //縦に'#'が含まれているか
            for(int i=0; i<y; i++){
                for(int j=0; j<x; j++){
                    if(arr[j,i] == '#'.ToString()){
                        row.Add(i);
                        break;
                    }
                }
            }

            for (int i = 0; i < x; i++){
                for (int j = 0; j < y; j++){
                    if(row.Contains(j) && colomn.Contains(i)){
                        Write(arr[i,j]);
                    }
                }
                if(colomn.Contains(i)) WriteLine();
            }
        }
    }
}

Measured memory_bytes: 13280
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;//namespace

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
#define YES(n) cout << (n ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << (n ? "Yes" : "No"  ) << endl;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define CIN(x) int x;cin>>x;

#define VECCIN(x) for(auto&youso_: x )cin>>youso_;
#define VECCOUT(x) for(auto&youso_: x )cout<<youso_<<" ";cout<<endl;

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define P pair<int,int>

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    vector<int> n(3);
    VECCIN(n);
    YES((count(ALL(n),5)==2&&count(ALL(n),7)==1));
    
    

    return 0;
}


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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int n,m;
  const int max_n = 100000;
  cin >> n >> m;
  atcoder::dsu d(n);
  for(int i = 0; i < m; i++){
    int a,b;
    cin >> a >> b;
    a--, b--;
    d.merge(a, b);
  }

  int seen[max_n + 1] = {};
  int cnt = 0;
  for(int i = 0; i < n; i++){
    if(seen[d.leader(i)] == 0){
      seen[d.leader(i)] = 1;
      cnt ++;
    }
  }
  cout << cnt - 1 << endl;

  return 0;
}

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

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> pena(N,0);
    vector<ll> ok(N,0);
    ll res1=0;
    ll res2=0;
    for (int i = 0; i < M; i++)
    {
        ll p;
        string status;
        cin >> p >> status;
        --p;
        if(status=="AC"){
            if(!ok[p]){
                ++res1;
                res2+=pena[p];
                ok[p]=true;
            }
        }
        else pena[p]++;
    }
    cout<<res1<<" "<<res2;
    return 0;
}

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

long long int lcm(long long int x, long long int y)
{
    if (x == 0)
        return y;
    if (y == 0)
        return x;
    long long int r = 0, a, b;
    a = (x > y) ? x : y; // a is greater number
    b = (x < y) ? x : y; // b is smaller number
    r = b;
    while (a % b != 0)
    {
        r = a % b;
        a = b;
        b = r;
    }
    return (x * y) / r;
}
int dp[100001] = {0};
int ans1(int arr[], int n, int K)
{
    // int dp[n+1]={0};

    dp[1] = 0;
    dp[2] = abs(arr[1] - arr[0]);
    // dp[1]=min(abs(arr[2]-arr[1])+dp[1],abs(arr[2]-arr[0]));
    for (int i = 3; i < n + 1; i++)
    {
        int k = INT_MAX;
        for (int j = i-K; i > j ; j++)
        {
            if (j>0)
                k = min(k, dp[j] + abs(arr[i - 1] - arr[j - 1]));
        }
        dp[i] = k;
    }
    
    
    return dp[n];
}
int main()
{
    int n, K;
    cin >> n >> K;
    int arr[n];
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    cout << ans1(arr, n, K);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int N; cin >> N; bool OK = false;
  repi(j,0,N/4) repi(k,0,N/7) if(4*j+7*k==N) OK = true;
  cout << (OK ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
    s = int(input())
    a.append(s)
a.sort()
i = 0
cnt = 0
while i < n:
    j = i+1
    chk = 1
    if j >= n:
        cnt += 1 
        break
    while a[i] == a[j]:
        chk += 1
        j += 1
        if j >= n:
            break
    if chk%2 == 1:
        cnt += 1 
    i = j
print(cnt)

Measured memory_bytes: 50696
// https://atcoder.jp/contests/abc109/tasks/abc109_c

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

//------------------------------------------------------------------------------
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

//------------------------------------------------------------------------------
const int N_MAX = 1e5;
const int X_MAX = 1e9;
const int X_I_MAX = 1e9;

int N, X;
int x[N_MAX + 1];

void solve() {
  x[N] = X;
  sort(x, x + N + 1);
  FOR(i, 1, N) x[i] -= x[0];
  int D = x[1];
  FOR(i, 2, N) D = gcd(D, x[i]);
  printf("%d\n", D);
}

void input() {
  scanf("%d%d", &N, &X);
  REP(i, N) scanf("%d", x + i);
}

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


Measured memory_bytes: 640
s = int(input())

def func(n):
    if n % 2 == 0:
        return n / 2
    else:
        return 3 * n + 1

a = {}
a[1] = s

i = 2
while True:
    tmp = func(a[i-1])
    if tmp in a.values():
        print(i)
        break
    else:
        a[i] = tmp
        i += 1

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list>
#include <unordered_set>

#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define _GLIBCXX_DEBUG
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 long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
typedef pair<double, long long> pair_t;
bool PSecComp(const pair_t& a, const pair_t& b) {
	if (a.second == b.second)return  a.first > b.first;
	else {
		return a.second > b.second;
	}
}

int main() {
	ll n, m;
	cin >> n >> m;
	vector<ll>a(m),steps(n*100,0);
	rep(i, m)cin >> a[i];
	rep(i, m)steps[a[i]] = 1;
	vector<ll>dp(pow(10, 6),0);
	dp[n] = 1;
	for (ll i = n-1; i >= 0; i--) {
		if (steps[i] == 1)continue;
		else dp[i] = dp[i + 1]%MOD + dp[i + 2]%MOD;
	}
	cout << dp[0]%MOD << endl;
}


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

/*
ll gcds(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=a%b;
    if(r==0){
        return b;
    }
    while(r>0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
 
 
ll lcms(ll a,ll b){
    ll mmr=gcds(a,b);
    a=a/mmr;
    b=b/mmr;
    return a*b*mmr;
}
*/
int main(){
    ll N,K;
    cin>>N>>K;
    ll ans = 0;
    for(ll i=K;i<=N+1;i++){
        //ll tmp = (K-1)*K/2;
        //ll Tmp = (2*N-K+3)*K/2;
        ll Ans = (N+1-i)*i+1;
        ans += Ans;
    }
    ans = ans%1000000007;
    cout<<ans<<endl;
}

Measured memory_bytes: 3644
w = int(input())
n = int(input())
l = list(range(1, w + 1))
for i in range(n):
    a, b = map(int, input().split(','))
    a -= 1
    b -= 1
    l[a], l[b] = l[b], l[a]

for i in range(w):
    print(l[i])

Measured memory_bytes: 7556
n = int(input())

def count5(j):
    if j % 5 != 0:
        return 0
    return count5(j // 5) + 1

if n % 2 == 0:
    i = 2
    v = 1
else:
    print(0)
    exit()

c5 = 0
j = 0

m = n // 2

v5 = 5
while v5 <= m:
    c5 += (m // v5)
    v5 *= 5

print(c5)




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

#define LL long long
#define VI vector<int>
#define VB vector<bool>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";

template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> void print(T x) { std::cout << x << std::endl; }
// 4近傍（右, 下, 左, 上）
const std::vector<int> dy = { 0, -1, 0, 1 };
const std::vector<int> dx = { 1, 0, -1, 0 };

using namespace std;

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


    vector<int> dp(40, 0);
    dp[0] = 1;
    FOR(i, 0, 31) {
        dp[i + 1] += dp[i];
        dp[i + 2] += dp[i];
        dp[i + 3] += dp[i];
    }

    while (true ){
        int n;
        cin >> n;
        if (n == 0) { break; }
        print(ceil(dp[n], 3650));
    }

}




Measured memory_bytes: 3112
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/

/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    int N, D, X;
    int A[110];

    cin>>N>>D>>X;
    REP(i,0,N){
        cin>>A[i];
    }

    int ans = X;
    REP(i,0,N){
        for(int j=1;;j++){
            int t = (j-1)*A[i] + 1;
            if(t > D){
                break;
            }
            X++;
        }
    }

    cout<<X<<endl;

    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
int main(){
int n,i;
scanf("%d",&n);
if(1<=n&&n<=9)
{i=n;}
else if(10<=n&&n<=99)
{i=9;}
else if(100<=n&&n<=999)
{i=9;
i+=n-99;}
else if(1000<=n&&n<=9999)
{i=909;}
else if(10000<=n&&n<=99999)
{i=909;
i+=n-9999;}
else if(n==100000)
{i=90909;}
printf("%d",i);
}

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

int main(){
  int n; cin >> n;
  string s; cin >> s;
  int cnt = 0;
  for(int i = 0; i < n - 2; i++){
    if(s.at(i) == 'A' and s.at(i + 1) == 'B' and s.at(i + 2) == 'C') cnt++;
  }
  cout << cnt;
}

Measured memory_bytes: 3596
import java.util.ArrayList;
import java.util.*;
  public class Main
{
	public static void main (String[] args)
	 {
		Scanner sc=new Scanner(System.in); 
		long a=sc.nextInt();
		long b=sc.nextInt();
		long c=sc.nextInt();
		long k=sc.nextInt();
		long sum=0;
		if(a>k)
			System.out.println(k);
		else
		{
			k-=a;
			sum=a;
			if(b>=k)
				System.out.println(sum);
			else
			{
				k-=b;
				sum-=k;
				System.out.println(sum);
			}
		}
	}
}

Measured memory_bytes: 35744
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n,ar[N]; ll dp[N][4];
ll findans(ll i,ll f1){
	if(i>n){
		if(f1<=1) return 0;
		else return -1e18;
	}
	if(dp[i][f1]!=-1){
		return dp[i][f1];
	}

	if(f1>0){
		ll a,b;
		a=findans(i+1,f1-1);
		b=findans(i+2,f1)+ar[i];
		return dp[i][f1]=max(a,b);
	}
	else return dp[i][f1]=findans(i+2,f1)+ar[i];
}
int main(){
	
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	
	memset(dp,-1,sizeof(dp));
	if(n%2==0){
		ll an=max(findans(1,1),findans(2,0));
		cout<<an;
	}
	else {
		
		ll an=max(findans(1,2),findans(2,1));
		cout<<an;
	}
	return 0;
}

Measured memory_bytes: 105236
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
  int a,b,d;
 string c[10];
      
  cin >> a>>b;
   
  if(a%b !=0){
    cout << a<< endl;
  }
  
  else{
    cout << "-1" << endl;
  }
}

Measured memory_bytes: 256
def solve():

    N, M = map(int, input().split())

    s = [-1 for i in range(M)]
    c = [-1 for i in range(M)]
    for i in range(M):
        s[i], c[i] = map(int, input().split())

    for i in range(M):
        for j in range(i+1, M):
            if s[i] == s[j] and c[i] != c[j]:
                print('-1')
                return

    for i in range(M):
        if N > 1 and s[i] == 1 and c[i] == 0:
            print('-1')
            return

    ans = ['0' for i in range(N)]
    if N > 1:
        ans[0] = '1'
    for i in range(M):
        ans[s[i]-1] = str(c[i])
    print(''.join(ans))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

vector<pair<i64, int>> factorize(i64 x)
{
    vector<pair<i64, int>> res;
    for (i64 f = 2; f * f <= x; f++)
    {
        if (x % f)
        {
            continue;
        }
        int cnt = 0;
        while (x % f == 0)
        {
            cnt++;
            x /= f;
        }
        res.push_back(make_pair(f, cnt));
    }
    if (x > 1)
    {
        res.push_back(make_pair(x, 1));
    }
    return res;
}

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    i64 x;
    cin >> x;
    for (i64 a = -120; a < 120; a++)
        for (i64 b = -120; b < 120; b++)
        {
            if (pow(a, 5) - pow(b, 5) == x)
            {
                cout << a << ' ' << b << endl;
                return;
            }
        }
}

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


Measured memory_bytes: 4060