akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
  ll N; cin>>N;
  vector<ll> X(N);
  vector<ll> Y(N);
  for(ll i=0; i<N; i++){
    ll A; cin>>A;
    X[i]=A;
    Y[i]=A;
  }
  sort(X.begin(), X.end());
  ll M1=X[N/2];
  ll M2=X[(N/2)-1];
  for(ll i=0; i<N; i++){
    if(Y[i]<M1) cout<<M1<<endl;
    else cout<<M2<<endl;
  }
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
  // vector<vector<ll>> f;
  vector<ll> g,h;
  ll recF(ll n, ll x);
  ll recG(ll n);
  ll recH(ll n);
};

Tmp::Tmp(int N)
  : g(N+1, -1)
  , h(N+1, -1)
{}

ll Tmp::recF(ll n, ll x)
{
  if (n == 0) {
    return 1;
  }

  if (1 == x) {
    return 0;
  }
  else if (1 < x && x <= recG(n-1) + 1 ) {
    return recF(n-1, x-1);
  }
  else if (x == recG(n-1) + 2) {
    return recH(n-1) + 1;
  }
  else if (recG(n-1) + 2 < x && x < recG(n)) {
    return recH(n-1) + 1 + recF(n-1, x-2-recG(n-1));
  }
  else if (x == recG(n)) {
    return 2 * recH(n-1) + 1;
  }
  else {
    assert(false);
  }
}

ll Tmp::recG(ll n)
{
  if (g[n] != -1) {
    return g[n];
  }
  if (n == 0) {
    return g[n] = 1;
  }
  return g[n] = 2 * recG(n-1) + 3;
}

ll Tmp::recH(ll n)
{
  if (h[n] != -1) {
    return h[n];
  }
  if (n == 0) {
    return h[n] = 1;
  }
  return h[n] = 2 * recH(n-1) + 1;
}

void solve(void)
{
  int N;
  ll X;
  cin >> N >> X;
  Tmp t(N);
  auto ans = t.recF(N, X);
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,ans(0);
  cin >> k;
  
  for(int i = 1;i<=k;i++){
    for(int j = 1;j<=k;j++){
      for(int l = 1;l<=k;l++){
        ans += gcd(gcd(i,j),l);
      }
    }
  }
  
  cout << ans << endl;
}

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

int main(void)
{
    int n,i;
    char s[101],t[101];

    scanf("%d",&n);
    scanf("%s %s",s,t);

    for ( i = 0; i < n; i++)
    {
        printf("%c%c",s[i],t[i]);
    }

    return 0;
}

Measured memory_bytes: 128
#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 <iomanip>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
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 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;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

ll gcd(ll a, ll b) {
  return b ? gcd(b, a%b) : a;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  invar(ll, A);invar(ll, B);
  cout << lcm(A,B) << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
INF = 10**18

n, k = map(int, input().split())
p = [int(item) - 1 for item in input().split()]
c = [int(item) for item in input().split()]
visited = [0] * n
cycles = []

for i in range(n):
    if visited[i]:
        continue
    nc = []
    v = i
    visited[v] = True
    nc.append(c[v])
    while not visited[p[v]]:
        v = p[v]
        visited[v] = True
        nc.append(c[v])
    cycles.append(nc)

ans = -INF 
for cycle in cycles:
    length = len(cycle)
    c_num = max(0, (k - 1) // length - 1)
    total = max(0, sum(cycle) * c_num)
    rest = k - (c_num * length)
    l_cycle = cycle + cycle + cycle
    for l in range(length):
        total_rest = 0
        for diff in range(rest):
            total_rest += l_cycle[l + diff]
            ans = max(ans, total + total_rest)

print(ans)

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

int main()
{

        string s;
        cin >> s;

        map<char, int> m;
        for (int i = 0; i < s.length(); ++i) {
                char c;
                c = s[i];
                m[c] += 1;
        }
        for (auto i : m) {

                if (i.second > 1) {
                        cout << "no" << endl;
                        exit(0);
                }

        }
        cout << "yes" << endl;
}


Measured memory_bytes: 256
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef  long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        ll a,b,c,k;
        cin >> a >> b >> c >> k;
        if(k%2==0){
            cout<<a-b<<endl;
        }
        else cout<<b-a<<endl;



return 0;
}



Measured memory_bytes: 256
S = input()
T = input()
s, t = len(S), len(T)
c = "z" * s
for i in range(s - t + 1):
    if all(S[i + j] in (T[j], "?") for j in range(t)):
        c = min(c, S[:i] + T + S[i + t:])
print("UNRESTORABLE" if c == "z" * s else c.replace("?", "a"))


Measured memory_bytes: 9064
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N; cin >> N;
  vector<int> A(N);
  for (auto& a : A) { cin >> a; }
  int res{};
  for (int i = 0; i < N; ++i) {
    if (A[i] != i+1) { continue; }
    auto j = i == N-1 ? i-1 : i+1;
    std::swap(A[i], A[j]);
    ++res;
  }
  cout << res << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<math.h>
#include<algorithm>
#include<cstdio>
using namespace std;
int N,M;
int K[200];int X[200][10];int D[200][10];
int dp[200][10][100];
int INF=1000*1000*1000;
int main()
{
	while(true){
		scanf("%d%d",&N,&M);
		if(N==0&&M==0)return 0;
		for(int i=0;i<N;i++){
			scanf("%d",&K[i]);
			for(int j=0;j<K[i];j++){
				scanf("%d%d",&X[i][j],&D[i][j]);
			}
		}
		for(int i=0;i<N;i++){
			for(int j=0;j<K[i];j++){
				for(int k=0;k<=M;k++){
					dp[i][j][k]=INF;
				}
			}
		}
		for(int j=0;j<K[0];j++)dp[0][j][0]=0;
		if(M!=0){
			for(int j=0;j<K[1];j++)dp[1][j][1]=0;
		}
		for(int i=1;i<N;i++){
			for(int j=0;j<K[i];j++){
				for(int k=0;k<=M;k++){
					int dpijk=dp[i][j][k];
					if(i!=1&&k!=0){
						for(int l=0;l<K[i-2];l++){
							dpijk=min(dpijk,dp[i-2][l][k-1]+(D[i-2][l]+D[i][j])*abs(X[i-2][l]-X[i][j]));
						}
					}
					for(int l=0;l<K[i-1];l++){
						dpijk=min(dpijk,dp[i-1][l][k]+(D[i-1][l]+D[i][j])*abs(X[i-1][l]-X[i][j]));
					}
					dp[i][j][k]=dpijk;
					//printf("%d,%d,%d:%d\n",i,j,k,dpijk);
				}
			}
		}
		int ans=INF;
		for(int j=0;j<K[N-1];j++){
			for(int k=0;k<=M;k++){
				ans=min(ans,dp[N-1][j][k]);
			}
		}
		for(int j=0;j<K[N-2];j++){
			for(int k=0;k<M;k++){
				ans=min(ans,dp[N-2][j][k]);
			}
		}
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

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

using namespace std;

#define INF 1 << 30
#define MOD 1000000000 + 7

#define NIL -1

struct Node
{
	int p, l, r;

	Node()
	{

	}

	Node(int p, int l, int r)
	{
		this->p = p;
		this->l = l;
		this->r = r;
	}
};

vector<Node> t;
vector<int> depth;

void rec(int u, int p)
{
	depth.at(u) = p;
	if (t.at(u).r != NIL)
	{
		rec(t.at(u).r, p);
	}
	if (t.at(u).l != NIL)
	{
		rec(t.at(u).l, p + 1);
	}
}

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

	depth.resize(n);

	for (int i = 0; i < n; i++)
	{
		t.push_back(Node(-1, -1, -1));
	}

	int l;
	for (int i = 0; i < n; i++)
	{
		int v, d;
		cin >> v >> d;
		for (int j = 0; j < d; j++)
		{
			int c;
			cin >> c;

			if (j == 0)
			{
				t.at(v).l = c;
			}
			else
			{
				t.at(l).r = c;
			}
			l = c;
			t.at(c).p = v;
		}
	}

	int r;
	for (int i = 0; i < n; i++)
	{
		if (t.at(i).p == NIL)
		{
			r = i;
		}
	}

	rec(r, 0);

	for (int i = 0; i < n; i++)
	{
		cout << "node " << i << ": ";
		cout << "parent = " << t.at(i).p << ", ";
		cout << "depth = " << depth.at(i) << ", ";

		if (t.at(i).p == NIL)
		{
			cout << "root, ";
		}
		else if (t.at(i).l == NIL)
		{
			cout << "leaf, ";
		}
		else
		{
			cout << "internal node, ";
		}

		cout << "[";

		for (int j = 0, c = t.at(i).l; c != NIL; j++, c = t.at(c).r)
		{
			cout << (j > 0 ? ", " : "") << c;
		}

		cout << "]" << endl;
	}
}


Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
int a=0,b=0,k=0,c=0;
    int main(){
 	cin>>a>>b;
 	c=a+b;
   	if(c%2==0)
    cout<<c/2;
	else    	
	cout<<"IMPOSSIBLE";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF ll(1e18)
///#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 1000000007

int main() {
	string s,t;
	cin>>s>>t;
	ll k=s.length();
	ll counter=0;
	for (ll i=0;i<k;i++) {
		if (s[i]!=t[i]) counter++;
	}
	cout<<counter;
}


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

struct Item {
  int value, weight;
  char type;
  unsigned long long date;
  std::string name;

  Item(int value, int weight, char type, unsigned long long date,
       std::string name)
    :value(value),
     weight(weight),
     type(type),
     date(date),
     name(name)
  {}

  bool operator<(const Item& other) const {
    if (value != other.value) return value < other.value;
    if (weight != other.weight) return weight < other.weight;
    if (type != other.type) return type < other.type;
    if (date != other.date) return date < other.date;
    return name < other.name;
  }
};

int main(void) {
  int n;
  std::cin >> n;

  std::vector<Item> items{};
  for (int i = 0; i < n; ++i) {
    int v, w;
    char t;
    unsigned long long d;
    std::string s;
    
    std::cin >> v >> w >> t >> d >> s;
    items.push_back(Item(v, w, t, d, s));
  }

  std::sort(items.begin(), items.end());

  for (auto iter = items.begin(); iter != items.end(); ++iter) {
    auto item = *iter;
    std::cout << item.value << ' ' << item.weight << ' '
              << item.type << ' ' << item.date << ' '
	      << item.name << std::endl;
  }
}


Measured memory_bytes: 12316
#include<iostream>
#include<stdio.h>
using namespace std;

int main() {
	int dis[10];
	int v[2];

	while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &dis[0], &dis[1], &dis[2], &dis[3], &dis[4], &dis[5], &dis[6], &dis[7], &dis[8], &dis[9], &v[0], &v[1]) != EOF) {
		double total_dis = 0.0;
			for (int i = 0; i < 10; i++) {
				total_dis += static_cast<double>(dis[i]);
			}
			double meet_time = total_dis / (v[0] + v[1]);
			double meet_dis = meet_time*v[0];
			double passed_dis = 0;
			for (int i = 0;; i++) {
				passed_dis += static_cast<double>(dis[i]);
				if (passed_dis == meet_dis) {
					cout << i+1 << endl;
					break;
				}
				if (passed_dis > meet_dis) {
					cout << i+1 << endl;
					break;
			}
		}
	}
}

Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
// ascending order
#define asort(array, N) sort(array, array + N)
// descending order
#define asort_r(array, N) sort(array, array + N, greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

ll N;
ll a[100000];
ll d[100001];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	for(int i = 0; i <= 100000; i++) d[i] = 0;
	for(int i = 0; i < N; i++) {
		cin >> a[i];
		d[a[i]]++;
	}

	ll ans = 0;
	ans = d[0] + d[1];
	for(int X = 1; X <= 100000; X++) {
		ll tmp = d[X - 1] + d[X] + d[X + 1];
		ans = max(ans, tmp);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
import copy
import sys
def advance(visited,now):
    result=W*H+1
    if now==W*H-1:
        result=min( len(visited),result)
    else:
        for i in range(W*H):
            if i in visited:
                continue
            elif G[i][now]==1:
                _visited=copy.copy(visited)
                _visited.append(now)
                result=advance(_visited,i)
    return result

H,W=[int(i) for i in input().split(" ")]
Map=[]
white=0
for i in range(H):
    l=[]
    s=input()
    for j in s:
        if j==".":
            l.append(0)
            white+=1
        else:
            l.append(-1)

    Map.append(l)
Map[0][0]=1
G=[[0 for i in range(H*W)] for j in range(H*W)]

for i in range(H):
    for j in range(W):
        if Map[i][j]==-1 :
            continue
        else:
            try:
                if Map[i+1][j]==0:
                    G[W*i+j][W*(i+1)+j]=1
                    G[W*(i+1)+j][W*i+j]=1
            except IndexError:
                pass
            try:
                if Map[i][j+1]==0:
                    G[W*i+j][W*i+j+1]=1
                    G[W*i+j+1][W*i+j]=1
            except IndexError:
                pass

advanced=[[0,0]]
step=2
while Map[-1][-1]==0:
    _advanced=[]
    for i in advanced:
        try:
            if Map[i[0]+1][i[1]]==0:
                Map[i[0]+1][i[1]]=step
                _advanced.append([i[0]+1,i[1]])
        except IndexError:
            pass
        try:
            if Map[i[0]][i[1]+1]==0:
                Map[i[0]][i[1]+1]=step
                _advanced.append([i[0],i[1]+1])
        except IndexError:
            pass
        try:
                if Map[i[0]-1][i[1]]==0 and i[0]!=0:
                    Map[i[0]-1][i[1]]=step
                    _advanced.append([i[0]-1,i[1]])
        except IndexError:
                pass
        try:
                if Map[i[0]][i[1]-1]==0 and i[1]!=0:
                    Map[i[0]][i[1]-1]=step
                    _advanced.append([i[0],i[1]-1])
        except IndexError:
                pass
    step+=1
    advanced=copy.deepcopy(_advanced)
    if len(advanced)==0:
        print(-1)
        sys.exit()
print(white-Map[-1][-1])


Measured memory_bytes: 55136
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<ctime>
#include<map>
#define R(i, n) for(int i = 0;i < n;i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SA(i, n, a) R(i, n) scanf("%d", a + i)
#define SAL(i, n, a) R(i, n) scanf("%lld", a + i)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;

int A, B, C, D;

int main() {
	S3(A, B, C);
	S(D);
	bool flag = true;
	while (true) {
		C -= B;
		if (C <= 0)break;
		A -= D;
		if (A <= 0) {
			flag = false;
			break;
		}
	}
	if (flag)printf("Yes");
	else printf("No");
}
	

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if (b/a > c) {
    cout << c << "\n";
  } else {
    cout << b/a << "\n";
  }
}


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

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

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

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

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    bool is_zero_exist = false;
    for(ll a : A){
        if(a==0){
            is_zero_exist = true;
        }
    }
    if(is_zero_exist){
        ll sum = 0;
        for(ll a : A){
            sum += abs(a);
        }
        p(sum);
        return 0;
    }

    ll minus_count = 0;
    for(ll a : A){
        if(a<0){
            minus_count++;
        }
    }
    
    if(minus_count%2==0){
        ll sum = 0;
        for(ll a : A){
            sum += abs(a);
        }
        p(sum);
        return 0;
    }
    else{
        vector<ll> B;
        for(ll a : A){
            B.push_back(abs(a));
        }
        sort(ALL(B));
        B[0] *= -1;
        ll sum = 0;
        for(ll b : B){
            sum += b;
        }
        p(sum);
        return 0;
    }


    return 0;
}

Measured memory_bytes: 2168
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
#define mop2 998244353

using namespace std;

int main() {

	string s;
	cin >> s;
	if (s == "ABC")cout << "ARC";
	else { cout << "ABC"; }
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>	
using namespace std;
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
typedef long long         ll;
const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }
#define pb					push_back
#define P(x)				cout<<#x<<" = { "<<x<<" }\n"
clock_t T;
#define ctime cerr << "Time : " << double(clock() - T) / CLOCKS_PER_SEC << endl
void GOAT()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("output.txt", "w	", stdout);
#else
#endif

}
int r, c;
char grid[1007][1007];
int mem[1007][1007];
bool valid(int i, int j)
{
	return (i < r && j < c);
}
const int m = 1e9 + 7;
int solve(int i, int j)
{
	if (i == r - 1 && j == c - 1)return 1;
	int& ret = mem[i][j];
	if (~ret)return ret;
	ret = 0;
	if (valid(i, j + 1) && grid[i][j + 1] != '#')ret=((ret%m)+(solve(i, j + 1)%m))%m;
	if (valid(i + 1, j) && grid[i + 1][j] != '#')ret = ((ret % m) + (solve(i+1, j) % m)) % m;
	return ret%m;
}
int main() {
	//GOAT();
	
		clr(mem, -1);
		cin >> r >> c;
		for (int i = 0; i < r; i++)
		{
			for (int j = 0; j < c; j++)
			{
				cin>>grid[i][j];
			}
		}
		cout << solve(0, 0) << endl;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
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;

long long h[100010];
long long dp[100010];

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

  for (int i = 0; i < n; i++) cin >> h[i];

  for (int i = 0; i < 100010; i++) dp[i] = INF;
  dp[0] = 0;

  for (int i = 0; i < n; i++) {
    chmin(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
    chmin(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
from itertools import combinations
A1,A2,A3=(map(int,input().split()))
A4,A5,A6=(map(int,input().split()))
A7,A8,A9=(map(int,input().split()))
x=[A1,A2,A3,A4,A5,A6,A7,A8,A9]
N=int(input())
num=[]
win=[]
for i in range(0,N):
    num.append(int(input()))
for i in num:
    if i in x:
        y=x.index(i)+1
        win.append(y)
        win.sort()
win1=[(1,2,3),(4,5,6),(7,8,9),(1,4,7),(2,5,8),(3,6,9),(1,5,9),(3,5,7)]
a=list(combinations(win,3))
for i in a:
    if i in win1:
        print('Yes')
        break
else:
    print('No')

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

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	string a,b,c;
	cin>>a>>b>>c;
	cout<<(char)toupper(a[0])<<(char)toupper(b[0])<<(char)toupper(c[0])<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i64,
        a: i64,
        b: i64,
    }
    let ans: i64 = (1..n + 1)
        .filter(|num| {
            let s = sum_digits(*num);
            a <= s && s <= b
        })
        .sum();
    println!("{}", ans);
}

fn sum_digits(num: i64) -> i64 {
    let mut num = num;
    let mut sum = 0;
    while num != 0 {
        sum += num % 10;
        num /= 10;
    }
    sum
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    char X,Y; cin >> X >> Y;
    if(X<Y) cout << "<" << endl;
    else if(X>Y) cout << ">" << endl;
    else cout << "=" << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, i, j, k,m;
    cin >> n >> m;
    vector<set<ll>> G(n);
    for(i=0;i<m;i++){
        ll x,y;
        cin >> x >> y;
        G[--x].insert(--y);
        G[y].insert(x);
    }
    ll ret = 0;
    vector<ll> v(n-1);
    iota(v.begin(),v.end(),1);
    do{
        ll now = 0,ok=1;
        for(i=0;i<n-1;i++){
            if(G[now].find(v[i])==G[now].end()){
                ok = 0;
                break;
            }
            now = v[i];
        }
        if(ok)ret++;

    }while(next_permutation(v.begin(),v.end()));
    cout << ret << 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 ll;

int main(){
  int n; cin >> n;
  map<string, int> mp;
  rep(i,n){
    string s; cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }
  ll ans = 0;
  for(auto& p : mp){
    int cnt = p.second;
    ans += (ll)cnt*(cnt-1)/2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11136
n,k=map(int,input().split())
a=list(map(int,input().split()))
tu=0
td=0
if k>=40:
  a=[n]*n
else:
  for j in range(k):
    temp=[0]*n
    for i in range(n):
      td=max(i+1-a[i],1)
      temp[td-1]=temp[td-1]+1
      tu=min(i+1+a[i],n)
      if tu!=n:
        temp[tu]=temp[tu]-1
    a[0]=temp[0]
    for i in range(1,n):
      a[i]=a[i-1]+temp[i]
L=[str(t) for t in a]
L=" ".join(L)
print(L)

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

int main(){
  for(int i=0; ;i++){
      int n;
      cin >> n;
      if(n == 0){
          return 0;
      }
      vector<int>a(n);
      long long sum =0;
      for(int i=0;i<n;i++){
          cin >> a[i];
          sum += a[i];
      }
      int av = sum/n;
      int ans =0;
      for(int i=0;i<n;i++){
          if(a[i] <= av){
              ans++;
          }
      }
      cout << ans << endl;
    }
}



Measured memory_bytes: 3132
# AC
import math

D, G = map(int, input().split())
p_c_list = [list(map(int, input().split())) for _ in range(D)]

min_n_solved = 1000000000
for p_combi in range(1 << D):
    tmp_score = 0
    n_solved = 0
    selected_p_idxs = []  # Selected indexes of problems
    for digit in range(D):
        if (p_combi >> digit) & 1:
            # p_i: p_c_list[digit][0]
            # c_i: p_c_list[digit][1]
            tmp_score += \
                100 * (digit+1) * p_c_list[digit][0] + p_c_list[digit][1]
            n_solved += p_c_list[digit][0]
            selected_p_idxs.append(digit)
    score_diff = tmp_score - G
    # print('1:', n_solved, 'score_diff:', score_diff)
    if score_diff >= 0:
        # Fine-tuning to reduce "n_solved" problems over solved
        # "selected_p_idxs" were already sorted by probrems
        # from low points to high
        p_idx_lowest = selected_p_idxs[0]
        score_per_p = 100 * (p_idx_lowest + 1)
        # if score_diff - bonus_point > 0
        n_oversolved = None
        score_diff_wo_bonus = score_diff - p_c_list[p_idx_lowest][1]
        if score_diff_wo_bonus > 0:
            n_oversolved = round(score_diff_wo_bonus / score_per_p)
            if n_oversolved < p_c_list[p_idx_lowest][0]:
                n_solved -= n_oversolved
        # print('2:', n_solved)
    else:
        not_selected_p_idxs = \
            [p_idx for p_idx in range(D) if p_idx not in selected_p_idxs]
        not_selected_p_idxs = sorted(not_selected_p_idxs, reverse=True)
        # Select a problem index
        # which have highest point in not_selected_p_idxes
        not_selected_p_idx_highest = not_selected_p_idxs[0]
        num_p = p_c_list[not_selected_p_idx_highest][0]
        addable_score = \
            100 * num_p * (not_selected_p_idx_highest + 1)
        if score_diff + addable_score > 0:
            score_per_p = 100 * (not_selected_p_idx_highest + 1)
            n_undersolved = math.ceil(abs(score_diff) / score_per_p)
            if n_undersolved < num_p:
                n_solved += n_undersolved
            # print('3:', n_solved)
    if n_solved > 0 and score_diff >= 0:
        min_n_solved = min(n_solved, min_n_solved)

print(min_n_solved)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,a,ak,h;
    cin>>n>>k>>a;
    h=a;
    for(int i=2;i<=n;i++)
    {
        cin>>ak;
        a=__gcd(a,ak);      
        h=max(ak,h);
    }
    if(k%a==0&&k<=h)    
    {
        cout<<"POSSIBLE"<<endl;
    }
    else
    {
        cout<<"IMPOSSIBLE"<<endl;
    }}

Measured memory_bytes: 256
#include <stdio.h>

int F[44];

int fib(int n) {
	int i;
	F[0] = 1;
	F[1] = 1;
	for (i = 2; i <= n; i++) F[i] = F[i-2] + F[i-1];

	return F[n];
}

int main() {
	int n;

	scanf("%d", &n);

	n = fib(n);

	printf("%d\n", n);

	return 0;
}

Measured memory_bytes: 596
#include<iostream>
#include<string>
using namespace std;
int main(){
  int k;
  cin >> k;
  string s;
  cin >> s;
  int n = s.size();
  if(n <= k){
    cout << s;
  }
  else{
    for(int i = 0; i < k; i++){
      cout << s[i];
    }
    cout << "...";
  }
  
}
    

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N;
	cin >> N;

	int mod = 1e9 + 7;
	int kotae = 0;
	ll kazu = 1;
	int kari = 0;
	int imos[1000010] = {};
	int sq = 1ll * (N - 1) * (N - 1) % mod;
	rep1(i, N - 1) {
		kari = (kari + *(imos + i)) % mod;
		kazu = (kazu + kari) % mod;
		kotae = (kotae + kazu * sq) % mod;
		imos[i + 3] = kazu;
		if (i + 3 > N) kotae = (kotae + kazu * (N - 1)) % mod;
		else kotae = (kotae + kazu * (i + 1)) % mod;
	}
	kazu = (kazu + kari + *(imos + N)) % mod;
	kotae += N * kazu % mod;

	co(kotae % mod);
	
	Would you please return 0;
}

Measured memory_bytes: 4224
/**
 *      purpose : 
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

constexpr int64 MOD = 1e9 + 7;

struct Combination {
  int64 fac[202020];
  int64 inv[202020];
  int64 finv[202020];
};

constexpr Combination lookup_table() {
  Combination com {};
  com.fac[0] = 1; com.fac[1] = 1;
  com.finv[0] = 1; com.finv[1] = 1;
  com.inv[1] = 1;
  for (int i = 2; i <202020; ++i) {
    com.fac[i] = com.fac[i - 1] * i % MOD;
    com.inv[i] = MOD - com.inv[MOD % i] * (MOD / i) % MOD;
    com.finv[i] = com.finv[i - 1] * com.inv[i] % MOD;
  }
  return com;
}

const Combination table = lookup_table();

int64 my_com(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return table.fac[n] * (table.finv[k] * table.finv[n - k] % MOD) % MOD;
}

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

  int n, k; cin >> n >> k;
  for (int i = 1; i <= k; ++i) {
    int64 ans = 0;
    (ans += my_com(n - k + 1, i) * my_com(k - 1, i - 1)) %= MOD;
    cout << ans << '\n';
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int a[101][101],dp[101][101];
int main()
{
	cin>>n;
	for(int i=1;i<=2;i++)
	for(int j=1;j<=n;j++)
    {
    	cin>>dp[i][j];
	}
    
	for(int i=1;i<=2;i++)
	for(int j=1;j<=n;j++)
	{
		dp[i][j]=max(dp[i-1][j],dp[i][j-1])+dp[i][j];
	}
	cout<<dp[2][n]<<endl;
}

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

using VI = vector<long>;

int main() {
  int m, nmin, nmax;
  while (1) {
    cin >> m >> nmin >> nmax;
    if (m) {
      VI ps;
      for (int i = 0; i < m; i++) {
        long p;
        cin >> p;
        ps.push_back(p);
      }
      long n;
      long maxgap = 0;
      for (int i = nmin; i <= nmax; i++) {
        assert(i - 1 >= 0);
        assert(i < m);
        long gap = ps[i - 1] - ps[i];
        if (gap >= maxgap) {
          maxgap = gap;
          n = i;
        }
      }
      cout << n << endl;
    } else {
      return 0;
    }
  }
}



Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
int main(){
 int n,w,h,i,j,k,l,c,dw,dh;
 while(cin>>n,n){
  int m[128][128]={0},ma=0;
  cin>>w>>h;
  while(n--){
   cin>>i>>j;
   m[i][j]++;
  }
  cin>>dw>>dh;
  for(i=1;i<=w-dw+1;i++){
   for(j=1;j<=h-dh+1;j++){
    c=0;
    for(k=i;k<=i+dw-1;k++){
     for(l=j;l<=j+dh-1;l++){
      if(m[k][l])c++;
     }
    }
   ma=max(c,ma);
   }
  }
  cout<<ma<<endl;
 }
return 0;
}

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

int main ()
{
  int a, b, c;
  cin>>a>>b>>c;
  
  a*=b;
  
  if(a<c)
  {
    cout<<a<<endl;
  }
  else
  {
    cout<<c<<endl;
  }
}

Measured memory_bytes: 256
from sys import setrecursionlimit
setrecursionlimit(100000)
from collections import deque

S = input().split(" ")
N = int(S[0])
Q = int(S[1])

arr = []
prr = []
for i in range(N-1):
    S = input().split(" ")
    ar = [int(S[0]),int(S[1])]
    arr.append(ar)

for i in range(Q):
    S = input().split(" ")
    pr = [int(S[0]), int(S[1])]
    prr.append(pr)



def prepare(n, q, arr, prr):
    links = [[] for _ in range(n)]
    values = [0 for _ in range(n)]
    finalValues = [0 for _ in range(n)]
    for ar in arr:
        start = ar[0] - 1
        end = ar[1] - 1
        links[start].append(end)
        links[end].append(start)

    for pr in prr:
        i = pr[0] - 1
        x = pr[1]
        values[i] += x

    return links, values, finalValues


links, values, finalValues = prepare(N, Q, arr, prr)


def bfs():
    q = deque()

    q.append((0,-1,0))

    while len(q) > 0:
        currentNode,parentNode,parentAccumulate = q.popleft()
        parentAccumulate += values[currentNode]
        finalValues[currentNode] += parentAccumulate
        childNodes = links[currentNode]
        for ch in childNodes:
            if ch == parentNode:
                continue
            q.append((ch,currentNode,finalValues[currentNode]))

bfs()
print(*finalValues)

Measured memory_bytes: 131628
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
using namespace std;
const int MAXN=1e5;
int st[10*MAXN];
int flag;
int insert(int root,int l,int r,int ql,int qr){
	//cerr<<l<<" "<<r<<endl;
	if(l>qr || r<ql)return st[root];
	if(l==r ){
		if(st[root]==1){
			flag=0;
			
		}
		else {
		st[root]=1;
		flag=1;
		}
		return 1;
	}
	int m=l+(r-l)/2;
	int rt=(root<<1)+1;
	int lf=root<<1;
	if(!st[rt]){
		int val=insert(rt,m+1,r,ql,qr);
		st[root]=min(st[lf],val);
		if(flag)
	return st[root];
	}
	if(!st[lf]){
		int val=insert(lf,l,m,ql,qr);
		st[root]=min(st[rt],val);
		if(flag)
		return st[root];
	}
	flag=0;
	return st[root];
	
}
int main(){
	int n,m;cin>>n>>m;
	vector<pair<int,int>> arrmv;
	for(int i=0;i<n;i++){
		int a,b;cin>>a>>b;
		arrmv.push_back(make_pair(b,a));
	}
	sort(arrmv.begin(),arrmv.end(),greater<pair<int,int>>());
	int ans=0;
	memset(st,0,sizeof(st));
	for(int i=0;i<n;i++){
		int l=m- (arrmv[i].second-1);
		if(l<=0)continue;
		flag=0;
		 insert(1,1,m,1,l);
		 //for(int j=1;j<=7;j++)cerr<<st[j]<<" ";
		 //cerr<<endl;
		if(flag)ans+=arrmv[i].first;
		else continue;
	}
	
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5108
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int X, Y;
	cin >> X >> Y;
	cout << X + Y / 2 << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 1012
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(s, Q, queries):
    l = ['']
    r = ['']
    rev = 0
    for q in queries:
        if q[0] == 1:
            rev += 1
            continue
        f = q[1]
        c = q[2]
        if rev % 2 == 0 and f == 2 or rev % 2 == 1 and f == 1:
            r.append(c)
        else:
            l.append(c)
    if rev % 2 == 0:
        l.reverse()
        ret = ''.join(l) + s + ''.join(r)
    else:
        r.reverse()
        ret = ''.join(r) + s[::-1] + ''.join(l)
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = str(next(tokens))
    Q = int(next(tokens))
    q = []
    for i in range(Q):
        t = int(next(tokens))
        if t == 1:
            q.append([1, None, None])
        else:
            f = int(next(tokens))
            c = str(next(tokens))
            q.append([2, f, c])
    solve(s, Q, q)

if __name__ == '__main__':
    main()


Measured memory_bytes: 105564
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ans,num=0;
    string s;
    cin>>s;
    int n=s.length();
    for(int i=0;i<n;i++){
        if(i%2){
            if(s[i]=='1')num++;
        }
        else{
            if(s[i]=='0')num++;
        }
    }
    ans=num;
    num=0;
    for(int i=0;i<n;i++){
        if(i%2){
            if(s[i]=='0')num++;
        }
        else{
            if(s[i]=='1')num++;
        }
    }
    cout << (min(ans,num))<<endl;
    return 0;
}


Measured memory_bytes: 512
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          pb push_back
#define          N (int)2e5+5
#define          PI acos(-1.0)
#define          int long long 
#define          vi vector<int>
#define          mod 1000000007
#define          ld long double
#define          eb emplace_back
#define          mii map<int,int>
#define          vpii vector<pii>
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) rbegin(x),rend(x)
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

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

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q;
string s;
vi adj[N];
int vis[N],par[N],a[N];

int FastExpo(int x, int n )
{
	int ans = 1;
	while(n)
	{
		if( n&1 ) ans = ( ans%mod * x%mod )%mod;
		x = ( x%mod * x%mod )%mod;
		n >>= 1;
	}
	return ans;
}


void go()
{
	cin >> n >> k;

	int cn = 0;
	vi ans(k+1,0);

	rfo(i,k,1)
	{
		ans[i] = FastExpo( k / i , n);

		for( int j = 2*i; j <= k; j += i)
		{
			ans[i] = ( ans[i] - ans[j] + mod )%mod;
		}

		cn = ( cn%mod + ans[i]%mod * i%mod )%mod;
	}

	cout << cn << endl;
}

int32_t main()
{
	FAST;     
	int t=1; 
	// cin>>t;
	test(t) go();
}

 

Measured memory_bytes: 8748
h,n=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(n)]

max_A=max(AB)[0]+h
DP=[float("inf")]*max_A
DP[0]=0

for i in range(h):
    for a,b in AB:
        DP[i+a]=min(DP[i+a],DP[i]+b)

print(min(DP[h:]))

Measured memory_bytes: 43356
import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N = II()
    a = LI()
    ans = 0


    for i in range(N):
        if (i+1)%2==1 and a[i]%2==1:
            ans += 1

    
    print(ans)

if __name__ == "__main__":
	main()

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

using namespace std;

int main(){
    ll x;
    cin >> x;
    cout << 1-x << endl;
    return 0;
}

Measured memory_bytes: 3636