akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string.h>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <math.h>
#define ff first
#define ss second
#define ll long long
#define mod 1000000007
using namespace std;
string s[300009];
int cnt0[100], cnt1[100];
ll ans = 0;
ll mypow(ll a, ll b, ll modd) {
    ll rv = 1;
    while (b) {
        if (b % 2)
            rv = rv*a%modd;
        a = a*a %modd;
        b /= 2;
    }
    return rv;
}
int main () {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i = 0; i < n; i++) {
        ll x;
        cin>>x;
        while(x != 0) {
            s[i].push_back(x % 2 + 48);
            x /= 2;
        }
        reverse(s[i].begin(), s[i].end());
    }
    for(int i = n - 1; i > 0; i--) {
        int sz = s[i].size();
        for(int j = sz - 1, ct = 0; j >= 0 || ct < 64; j--, ct++) {
            if(j >= 0) {
                if(s[i][j] == '0')
                    cnt0[ct]++;//, cnt0[ct] %= mod;
                else
                    cnt1[ct]++;//, cnt1[ct] %= mod;
            }
            else {
                cnt0[ct]++;//, cnt0[ct] %= mod;
            }
        }
        ll curans = 0;
        sz = s[i - 1].size();
        for(int ct = 0, j = sz - 1; ct < 64 || j >=0 ; ct++, j--) {
            if(j >= 0) {
                if(s[i - 1][j] == '0') {
                    curans += cnt1[ct] * 1ll * mypow(2, ct, mod);
                    curans %= mod;
                }
                else {
                    curans += cnt0[ct] * 1ll * mypow(2, ct, mod);
                    curans %= mod;
                }
            }
            else {
                curans += cnt1[ct] * 1ll * mypow(2, ct, mod);
                curans %= mod;
            }
        }
        //cout<<i<<" "<<curans<<endl;
        ans += curans;
        ans %= mod;
    }
    cout<<ans;
}
/*
 9 2
 6 19 3 4 4 2 6 7 8
 1 7 21
 1 5 18
 1 3 14
 1 1 8
 0 8 38
 0 6 36
 0 4 32
 0 2 26
 */


Measured memory_bytes: 35456
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <fstream>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef map<int, int> mii;
typedef map<int, string> mis;
typedef map<string, int> msi;
typedef set<int> si;
typedef set<ll> sl;
typedef map<ll, ll> mll;
typedef queue<int> qi;
typedef queue<ii> qii;
typedef vector<string> vs;
typedef pair<ll, ll> iil;
typedef vector<iil> viil;

#define pb push_back
#define mp make_pair
#define rep(i, n) for (int i = 0 ; i < n ; i++)
#define INF 1000000000

void solve() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    map<int, int> ps;
    ps.insert({1 + a[0], 1});
    ll ans = 0;
    for (int i = 1 ; i < n ; i++) {
        ans += ps[i + 1 - a[i]];
        if (ps.count(i + 1 + a[i])) {
            ps[i + 1 + a[i]]++;
        }
        else {
            ps.insert({i + 1 + a[i], 1});
        }
    }
    cout << ans << endl;
}

void querySolve() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}

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


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

using namespace std;
const long long MOD=1e9+7;
vector<int> g[100005];
long long f[100005][2];
int n;
void DFS(int u, int p)
{
    f[u][0]=f[u][1]=1;
    bool ok=true;
    for(auto v:g[u])
    {
        if (v==p) continue;
        ok=false;
        DFS(v,u);
        f[u][0]*=f[v][0]+f[v][1]; f[u][0]%=MOD;
        f[u][1]*=f[v][0]; f[u][1]%=MOD;
    }
    //if (ok) f[u][0]=f[u][1]=1;
}
int main()
{
    cin>>n;
    for(int i=1;i<n;i++)
    {
        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    DFS(1,0);
    cout<<(f[1][0]+f[1][1])%MOD;
    return 0;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, i;

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


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

#define _CRT_SECURE_NO_WARNINGS

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

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

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

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

	int n;
	string s, t;
	cin >> n >> s >> t;

	for (int i = n; i >= 0; i--) {
		if (s.substr(n - i) == t.substr(0, i)) {
			cout << n * 2 - i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>

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

using namespace std;

int main(){
	for(int n;scanf("%d",&n),n;){
		int y,ans; scanf("%d",&y);
		double p_ans=-1;
		rep(i,n){
			int b,r,t; scanf("%d%d%d",&b,&r,&t);
			double p;
			if(t==1){ // tanri
				p=1+y*r/100.0;
			}
			else{ // fukuri
				p=pow(1+r/100.0,y);
			}
			if(p_ans<p) p_ans=p, ans=b;
		}
		printf("%d\n",ans);
	}

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

ll A[100100];
int main(){
    int N;
    cin >> N;

    int minus = 0;
    ll small = 1e10;
    ll sum = 0;
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a;
        if(a < 0) minus++;
        chmin(small, abs(a));
        sum += abs(a);
    }

    ll ans = 0;
    if(minus % 2 == 0){
        ans = sum;
    }
    else{
        ans = sum - 2*small;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9000000000000000000;
const double PI = acos(-1);

int N, W;
int v[10001], w[10001];
int dp[10001];
int main() {
	cin >> N >> W;
	for (int i = 0; i < N; i++) {
		cin >> v[i] >> w[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < W; j++) {
			if (j + w[i] > W)continue;
			dp[j + w[i]] = max(dp[j + w[i]], dp[j] + v[i]);
		}
	}
	cout << dp[W] << endl;
}

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

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

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;


struct Edge {
    int a, b, c;
    void print() {
        cout << a << ' ' << b << ' ' << c << endl;
    }
};

int n;
int b;
int sum;
Edge e[61];
int E;

int main() {
    cin >> n;
    int temp = n;
    while (temp) {
        temp >>= 1;
        ++b;
    }
    for (int i = 1; i < b; ++i) {
        e[E++] = Edge {i, i + 1, 1 << (b - i - 1)};
        e[E++] = Edge {i, i + 1, 0};
    }
    int cur = 1 << (b - 1);
    for (int i = 2; i <= b; ++i) {
        if (cur + (1 << (b - i)) - 1 < n) {
            e[E++] = Edge {1, i, cur};
            cur += (1 << (b - i));
        }
    }

    cout << b << ' ' << E << endl;
    for (int i = 0; i < E; ++i) {
        e[i].print();
    }
    return 0;
}


Measured memory_bytes: 3656
from collections import deque


def solve(string):
    n, q, *abpx = map(int, string.split())
    ab, px = abpx[:2 * n - 2], abpx[2 * n - 2:]
    check = [True] * (n + 1)
    t = {i: [] for i in range(n + 1)}
    c = [0] * (n + 1)
    d = deque([1])
    for a, b in zip(*[iter(ab)] * 2):
        t[a].append(b)
        t[b].append(a)
    for p, x in zip(*[iter(px)] * 2):
        c[p] += x
    while len(d) > 0:
        curr = d.pop()
        check[curr] = False
        next_ = [i for i in t[curr] if check[i]]
        for n_ in next_:
            c[n_] += c[curr]
        d.extend(next_)
    return " ".join([str(_c) for _c in c[1:]])


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n + m -1)])))


Measured memory_bytes: 114584
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    Scanner sc = new Scanner(System.in);
    int INF = 1 << 28;
    int ans;
    int m;
    List<Integer> f;
    int as[];

    void run() {
        int n = sc.nextInt();
        char[] id = new StringBuilder(sc.next()).reverse().toString()
                .toCharArray();
        m = sc.nextInt();
        as = new int[m];
        for (int i = 0; i < m; i++) {
            as[i] = sc.nextInt();
        }
        f = new ArrayList<Integer>();
        int sum = 0;
        for (int i = 0; i < n; i++) {
            if (id[i] == '*') {
                f.add(i);
                continue;
            }
            int num = id[i] - '0';
            if (i % 2 == 1)
                num *= 2;
            sum += num / 10 + num % 10;

        }
        ans = 0;
        solve(0, sum);
        System.out.println(ans);
    }

    void solve(int k, int sum) {
        if (k == f.size()) {
            if (sum % 10 == 0) {
                ans++;
            }
            return;
        }
        for (int i = 0; i < m; i++) {
            int num = as[i];
            if (f.get(k) % 2 == 1) {
                num *= 2;
            }
            solve(k + 1, sum + num / 10 + num % 10);
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }

}

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

using namespace std;

int calc(int r, int c, vector<vector<int>>& v)
{
	int res = 0;
	for (int i = -1; i <= 1; i++) {
		for (int j = -1; j <= 1; j++) {
			res += -v[r+i][c+j];
		}
	}
	return res;
}

int main()
{
	int H, W;
	cin >> H >> W;
	vector<vector<int>> v(H+2, vector<int>(W+2, 0));
	for (int i = 0; i < H; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < W; j++) {
			if (s[j] == '#') v[i+1][j+1] = -1;
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (v[i+1][j+1] == -1) cout << '#';
			else cout << calc(i+1, j+1, v);
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
p = 0
r = 100

for i in a:
  p += b[i-1]
  if i == r+1:
    p += c[i-2]
  r = i

print(p)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> v(N);
  for(int i=0;i<N;i++){
    cin >> v[i];
  }
  for(int i=N-1;i>=0;i--){
    cout << v[i];
    if(i != 0)
      cout << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int n,h,m;
char com;
double s,l;

int main(){
	cin>>n;
	while(cin>>h>>com>>m){
		s=6.0*m;
		l=0.5*(h*60+m);
		double a=l-s;
		if(a<0)a*=-1;
		a=min(a,360.0-a);
		if(a<30)cout<<"alert"<<endl;
		else if(a<90)cout<<"warning"<<endl;
		else cout<<"safe"<<endl;
	}
}

Measured memory_bytes: 0
/* 
This code is written by 
	Prateek Mittal	
	# AcFreak
	PDPM IIITDMJ
	Junior
	:)

*/

#include<bits/stdc++.h>
using namespace std;

#define llint long long int
#define lint long int 
#define show(a) for(i=0;i<a.size();i++) cout<<a[i]<<" ";
#define mm 1000000007
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define FORD(i,a,b) for(i=a;i>=b;i--)
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) ((a)*((b)/gcd(a,b)))
#define maxm(arr) *max_element(arr.begin(),arr.end())
#define minm(arr) **min_element(arr.begin(),arr.end())


typedef vector<int >vi;
typedef vector<llint> vlli;
typedef map<int ,int >mii;


class Graph
{
    int V; 
    int parent=-1;  
    list<int> *adj;
 
    void DFSUtil(int v, bool visited[],int *arr,int kp);
public:
    Graph(int V);   // Constructor
    void addEdge(int v, int w);
    void connectedComponents(int *arr);
};
 
// Method to print connected components in an
// undirected graph
void Graph::connectedComponents(int *arr)
{
    // Mark all the vertices as not visited

	int kp=0;
    bool *visited = new bool[V];
    for(int v = 0; v < V; v++)
        visited[v] = false;
 
    for (int v=0; v<V; v++)
    {
        if (visited[v] == false)
        {
            // print all reachable vertices
            // from v
            DFSUtil(v, visited,arr,kp);
 
           // cout << "\n";
            kp++;
        }

    }
}
 
void Graph::DFSUtil(int v, bool visited[],int *arr,int kp)
{
    // Mark the current node as visited and print it
    visited[v] = true;
   // cout << v << " ";
    arr[v]=kp;
 	
    // Recur for all the vertices
    // adjacent to this vertex
    list<int>::iterator i;
    for(i = adj[v].begin(); i != adj[v].end(); ++i)
        if(!visited[*i])
            DFSUtil(*i, visited,arr,kp);
}
 
Graph::Graph(int V)
{
    this->V = V;
   
    adj = new list<int>[V];
}
 
// method to add an undirected edge
void Graph::addEdge(int v, int w)
{
    adj[v].push_back(w);
    adj[w].push_back(v);
}
 


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

	vi arr(n);

	int i,j;

	REP(i,n)
	{
		cin>>arr[i];
		arr[i]--;
	}
	Graph g(n);
	int a,b;
	REP(i,m)
	{
		cin>>a>>b;

		a--;
		b--;

		g.addEdge(a,b);
	}
	int parent[n];
	g.connectedComponents(parent);

	int ans=0;
	for(i=0;i<n;i++)
	{
		if(parent[i]==parent[arr[i]])
			ans++;
	}
	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 12928
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

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

  fenwick_tree<int64_t> fw(n);

  for (int i = 0; i < n; i++) {
    int64_t a;
    cin >> a;
    fw.add(i, a);
  }

  for (int i = 0; i < q; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == 0) {
      fw.add(b, c);
    } else {
      cout << fw.sum(b, c) << endl;
    }
  }
}


Measured memory_bytes: 8220
#include <stdio.h>
int main()
{
    int S, h, m, s;
    scanf("%d\n",&S);

    h = S/3600;
    m = (S%3600) / 60;
    s = S%60;

    printf("%d:%d:%d\n", h, m, s);

 
return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
unsigned long long arr[100014] = {};
int main() {
    memset(arr, 0, sizeof(arr));
    unsigned long long ans = 1;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    for (int i = 0; i < n; i++) {
        if (ans > 1000000000000000000LL / arr[i]) {
            for (int j = i + 1; j < n; j++) {
                if (arr[j] == 0) {
                    cout << 0 << endl;
                    return 0;
                }
            }
            cout << -1 << endl;
            return 0;
        }
        ans *= arr[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4408
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int[] A = nextInts();

		String ans="No";
		if(Math.abs(A[0]-A[1])<=A[3]&&Math.abs(A[2]-A[1])<=A[3]){
			ans="Yes";
		}
		if(Math.abs(A[0]-A[2])<=A[3]){
			ans="Yes";
		}

		System.out.println(ans);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
struct point{
	int a;
	char c;
	int i;
	bool operator <(const point&p)const{
		return a<p.a;
	}
	bool operator <=(const point&p)const{
		return a<=p.a;
	}
	bool operator ==(const point&p)const{
		return a==p.a;
	}
}a[100005];
int n;
int pa(int l,int r,int p){
	point x=a[r];
	int i=p-1;
	for(int j=p;j<r;j++){
		if(a[j]<=x){
			i++;
			swap(a[i],a[j]);
		}
	}
	swap(a[i+1],a[r]);
	return i+1;
}
void qs(int p,int r){
	if(p<r){
		int m=pa(0,r,p);
		qs(p,m-1);
		qs(m+1,r);
	}
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n;cin>>n;
	for(int i=0;i<n;i++)cin>>a[i].c>>a[i].a,a[i].i=i;
	qs(0,n-1);
	bool ok=1;
	for(int i=0;i<n-1;i++)
		if(a[i]==a[i+1])if(a[i].i>a[i+1].i)ok=0;
	if(ok)cout<<"Stable"<<"\n";
	else cout<<"Not stable"<<"\n";
	for(int i=0;i<n;i++)
		cout<<a[i].c<<' '<<a[i].a<<"\n";
	return 0;
}


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

int main() {
        char c;
        char t = 'a';
        for (int i = 0; i != 4; ++i) {
                std::cin >> c;
                if (c == t) {
                        std::cout << "Bad" << std::endl;
                        return 0;
                }
                t=c;
        }
        std::cout<<"Good"<<std::endl;
        return 0;
}


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

int main() {
    string S;
    cin >> S;
    int count = 0;
    if (S.at(0) == 'o') {
        count++;
    }
    if (S.at(1) == 'o') {
        count++;
    }
    if (S.at(2) == 'o') {
        count++;
    }
    int ans = 0;
    ans = 700 + count*100;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
#define maxn 1005
#define LL long long
#define mod 1000000007

using namespace std;

LL x;

int main()
{
    scanf("%lld",&x);
    printf("%lld\n",x/500*1000+x%500/5*5);

    return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $n, $m);
$h = explode(" ", trim(fgets(STDIN)));
$ma = array_fill(0, $n, 0);

for ($i=0; $i<$m; $i++){
  fscanf(STDIN, "%d %d", $a, $b);
  $a--;
  $b--;
  $ma[$a] = max($ma[$a],$h[$b]);
  $ma[$b] = max($ma[$b],$h[$a]);
}

$ans = 0;
for ($i=0; $i<$n; $i++){
  if ($ma[$i] < $h[$i]) {
    $ans++;
  }
}

echo $ans;
?>


Measured memory_bytes: 27132
s = input()
t = input()

ss = len(s)
tt = len(t)

ans = 1145141919
for i in range(ss-tt+1):
    a = 0
    for j in range(tt):
        if s[i+j] != t[j]:
            a += 1
    ans = min(a,ans)
    
print(ans)

Measured memory_bytes: 67404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
vector<int> v;
int nowmaxi = 0;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r, s, p;
    cin >> r >> s >> p;
    for(int timer = 0; timer < p; timer++) {
        int i, j;
        cin >> i >> j;
        int now = r - i + 1;
        if(j <= s) {
            now += (s - j + 1);
        } else {
            now += j - s;
        }
        v.push_back(now);
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < v.size(); i++) {
        if(nowmaxi < v[i]) nowmaxi = v[i];
        else nowmaxi++;
    }
    cout << nowmaxi << endl;
    return 0;
}


Measured memory_bytes: 4992
// Problem : D - Bouquet
// Contest : AtCoder Beginner Contest 156
// URL : https://atcoder.jp/contests/abc156/tasks/abc156_d
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define y1 y114514
#define y2 y1919810
typedef pair <int, int> PII;
#define all(x) (x.begin(),  x.end())
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int (i) = 1; (i) <= (int)n; (i)++)
#define rep(i, n) for (int (i) = 0; (i) < (int)n; (i)++)
#define range(i, s, t)  for (int (i) = s; (i) <= (int)t; (i)++)
#define int long long
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
long long qread() {
	char c = getchar();
	int neg = 1;
	long long val = 0;
	while (c != '-' && !isdigit(c)) c = getchar();
	if (c == '-') c = getchar(), neg = -1;
	while (isdigit(c)) val = (val << 3) + (val << 1) + c - '0', c = getchar();
	return neg * val;
}
const int MOD = 1e9 + 7;
LL fact(LL x) {
	LL ans = 1;
	repn(i, x) ans = ans * i % MOD;
	return ans;
}LL qpow(LL a, LL b, LL p = MOD) {
	LL ans = 1;
	for (; b; b >>= 1) {
		if (b & 1) ans = ans * a % p;
		a = a * a % p;
	}
	return ans;
}
LL getInv(LL x) {
	return qpow(x, MOD - 2);
}
LL fct;
LL c[200010];
signed main() {
	LL n = qread(), a = qread(), b = qread();
	LL ans = qpow(2, n);
	c[0] = 1;
	repn(i, max(a, b)) c[i] = c[i - 1] * (n - i + 1) % MOD * getInv(i) % MOD;
	cout << (ans - 1 - c[a] - c[b] + 10000000 * MOD) % MOD;
	return 0;
}


Measured memory_bytes: 1792
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int N = Integer.parseInt(sc.next());
        int[][] a = new int[2][N];
        for (int j = 0; j < N; j++) {
            a[0][j] = Integer.parseInt(sc.next());
        }
        for (int j = 0; j < N; j++) {
            a[1][j] = Integer.parseInt(sc.next());
        }
        int ans = 0;
        
        for (int i = N - 1; i >= 0; i--) {
            int sum = 0;
            for (int j = 0; j <= i; j++) {
                sum += a[0][j];
            }
            for (int j = i; j < N; j++) {
                sum += a[1][j];
            }
            ans = Math.max(ans, sum);
        }

        out.println(ans);
        
        out.flush();
    }
}

Measured memory_bytes: 23764
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const A = parseInt(arg[0].split(" ")[0]);
    const B = parseInt(arg[0].split(" ")[1]);
    const C = parseInt(arg[0].split(" ")[2]);
    
    const sum = A + B + C;
    
    console.log(sum < 22 ? "win" : "bust");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 22080
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

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

void swap(int i, int j, char cp[40][40]){
    char temp = cp[i][j];
    cp[i][j] = cp[i][j + 1];
    cp[i][j + 1] = temp;
}

bool downBlock(int i, int j, char m[40][40]){
    bool f = false;
    if(m[i][j] != '.' && m[i + 1][j] == '.'){
        m[i + 1][j] = m[i][j];
        m[i][j] = '.';
        f = true;
    }
    return f;
}

bool allDownBlock(int h, int w, char m[40][40]){
    bool f = false;
    rep(k,40){
        for(int i = h - 2; i >= 0; i--){
            rep(j,w){
                if(downBlock(i,j,m)) f = true;
            }
        }
    }
    return f;
}

bool check(int h, int w, char m[40][40]){
    rep(i,h){
        rep(j,w){
            if(m[i][j] != '.') return 0;
        }
    }
    return 1;
}

void relocatDots(int h, int w, bool f[40][40], char m[40][40]){
    rep(k,h){
        rep(l, w){
            if(f[k][l] == 1){
                m[k][l] = '.';
            }
            //cout << m[k][l];
        }
        //cout << endl;
    }
    //cout << endl;
}

void dfs(int i, int j, int h, int w, int n, bool f[40][40], char m[40][40]){
    rep(k,4){
        int cnt = 0;
        rep(l, INF){
            int ny = i + dy[k] * l;
            int nx = j + dx[k] * l;
            if(ny < 0 || ny >= h || nx < 0 || nx >= w) break;

            if(m[ny][nx] == m[i][j]) cnt++;
            else break;
        }
        if(cnt >= n){
            rep(l,INF){
                int ny = i + dy[k] * l;
                int nx = j + dx[k] * l;
                if(m[ny][nx] != m[i][j]) break;
                f[ny][nx] = 1;
            }
        }
    }
}

bool deleteBlock(int h, int w, int n, char m[40][40]){
    allDownBlock(h, w, m);
    while(true){
        bool f[40][40] = {0};
        rep(i,h){
            rep(j,w){
                if(m[i][j] == '.') continue;
                dfs(i, j, h, w, n, f, m);
            }
        }
        relocatDots(h, w, f, m);
        if(not allDownBlock(h, w, m)) break;
    }
    return check(h,w,m);
}

int main(){
    char m[40][40];
    int h, w, n;
    cin >> h >> w >> n;
    rep(i,h) rep(j,w) cin >> m[i][j];

    rep(i, h){
        rep(j, w - 1){
            char cp[40][40];
            rep(k,h) rep(l,w) cp[k][l] = m[k][l];
            swap(i,j,cp);
            if(deleteBlock(h, w, n, cp)){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3080
S = input()
nagasa = len(S)
ichi_list = []
counter = 0
for i in range(nagasa):
    if S[i] == 'A' or S[i] == 'T' or S[i] == 'C' or S[i] == 'G':
        counter += 1
    else:
        ichi_list.append(counter)
        counter = 0

ichi_list.append(counter)
print(max(ichi_list))

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

int main(){
    string s,t; cin >> s >> t;
    vector<string> ans;
    int l = s.size() - t.size() + 1;
    for(int i = 0; i < max(0,l); i++){
        string tmp = s;
        for(int j = 0; j < t.size(); j++){
            if(i+j > s.size()-1)break;
            if(tmp[i+j]==t[j]||tmp[i+j]=='?')tmp[i+j]=t[j];
            else break;
            if(j == t.size()-1){
                for(int k = 0; k < tmp.size(); k++){
                    if(tmp[k]=='?')tmp[k] = 'a';
                }
                ans.push_back(tmp);
            }
        }
    }
    sort(ans.begin(),ans.end());
    if(ans.size()!=0)cout << ans[0] << endl;
    else cout << "UNRESTORABLE" << endl;
    return 0;
    
    
    
}

Measured memory_bytes: 3604
// #pragma GCC optimize(3)
#include "bits/stdc++.h"
using namespace std;
#ifdef __attribute__
#define fast __attribute__((optimize(3), target("no-ieee-fp,arch=corei7")))
#define inline fast inline
#else
#define fast
#endif
namespace io
{
	// #define USE_FREAD_IO
#ifdef USE_FREAD_IO
#define BUF_SIZE 5000010
	char buf[BUF_SIZE]; int cur = BUF_SIZE; FILE *in = stdin;
	inline char gnc()
	{
		if (cur == BUF_SIZE) { fread(buf, BUF_SIZE, 1, in); cur = 0; }
		return buf[cur++];
	}
#else
	inline char gnc()
	{
		return (char)getchar();
	}
#endif
	template<typename T>
	inline void gi(T &dx)
	{
		dx = 0;
		int yc = gnc();
		bool nega = false;
		while (yc < '0' || yc > '9') { nega = (yc == '-' ? true : nega); yc = gnc(); }
		while (yc >= '0' && yc <= '9') { dx = (T)(dx * 10 + yc - '0'); yc = gnc(); }
		if (nega) { dx = -dx; }
	}
	void gc(char &a)
	{
		do a = gnc(); while (!isgraph(a));
	}
	void gss(char *c)
	{
		*c = gnc();
		while (!isgraph(*c)) *c = gnc();
		while (isgraph(*c)) *++c = gnc();
		*c = 0;
	}
#if __cplusplus >= 201103l || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103l)
	template<typename T, typename ...Args> inline void gi(T &a, Args &...args)
	{ gi(a); gi(args...); }
#else
	template<typename t1, typename t2> inline void gi(t1 &a, t2 &b) { gi(a); gi(b); }
	template<typename t1, typename t2, typename t3> inline void gi(t1 &a, t2 &b, t3 &c) { gi(a); gi(b); gi(c); }
	template<typename t1, typename t2, typename t3, typename t4> inline void gi(t1 &a, t2 &b, t3 &c, t4 &d) { gi(a); gi(b); gi(c); gi(d); }
	template<typename t1, typename t2, typename t3, typename t4, typename t5> inline void gi(t1 &a, t2 &b, t3 &c, t4 &d, t5 &e) { gi(a); gi(b); gi(c); gi(d); gi(e); }
#endif
}
using namespace io;

const int maxn = 111111;
int a[maxn];
int c[5];
int n;
int main()
{
	gi(n);
	for (int i = 1; i <= n; ++i) {
		gi(a[i]);
		if (a[i] % 4 == 0) ++c[4];
		else if (a[i] % 2 == 0) ++c[2];
		else ++c[1];
	}
	c[1] += !!c[2];
	if (c[1] <= c[4] + 1) {
		puts("Yes");
	} else {
		puts("No");
	}
}



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

int main()
{
	int a=0;
	string S;
	cin >> S;
	size_t size = S.length();
	for (int i = 0; i < size; i++)
	{
		if ((i+1)%2==0)
		{
			if (S[i] == 'R')
			{
				a = 1;
				break;
			}
			else
			{

			}
		}
		else
		{
			if (S[i] == 'L')
			{
				a = 1;
				break;
			}
			else
			{

			}
		}
	}
	if (a==0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[3][202];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=2;i++){
		for(int j=1;j<=n;j++){
			scanf("%d",&dp[i][j]);
		}	
	}
	for(int i=1;i<=2;i++){
		for(int j=1;j<=n;j++){
			dp[i][j]+=max(dp[i][j-1],dp[i-1][j]);
		}	
	}
	printf("%d\n",dp[2][n]);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2e5+100;
int a[maxn];
int b[maxn];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        b[i]=a[i];
    }
    sort(b+1,b+n+1);
    if(n==2){
        printf("%d\n%d\n",a[2],a[1]);
        return 0;
    }
    else{
     //   int l2=b[n/2-1];
        int l1=b[n/2];
        int r1=b[n/2+1];
      //  int r2=b[n/2+2];
        for(int i=1;i<=n;i++){
            if(a[i]>=r1)printf("%d\n",l1);
            else printf("%d\n",r1);
        }
    }
    return 0;
}


Measured memory_bytes: 3712
#include<stdio.h>
#include<stdlib.h>
#define datatype char
#define max 10

struct stack{
	int maxsize;
	int top;
	datatype item[max];
};

struct stack* init_stack(struct stack *p){
	p = (struct stack *)malloc(sizeof(struct stack));
	p->top = -1;
	p->maxsize = max;
	return p;
}

void push(struct stack *p, datatype a){
	p->top++;
	if(p->top >= p->maxsize){
		printf("overflow\n");
		exit(1);
	}else{
		p->item[p->top] = a;
	}
}

datatype pop(struct stack *p){
	if(p->top > -1){
		datatype a;
		a = p->item[p->top];
		p->top--;
		return a;
	}else{
		printf("underflow\n");
		exit(1);
	}
}

int empty_stack(struct stack *p){
	/*if stack is empty, return 1. Else, return 0.*/
	return p->top == -1;
}

void print_stack(struct stack *p){
	while(p->top != -1){
		printf("%c", pop(p));
	}
	printf("\n");
}

void print_stack_r(struct stack *p){
	struct stack *a;
	a = init_stack(a);
	while(empty_stack(p) == 0){
		push(a, pop(p));
	}
	print_stack(a);
}

int main(){
	int i, tmp, m;
	tmp = 0;
	datatype buf[11], s[11];
	for(i = 0; i < 11; i++)s[i] = '\0';
	struct stack *a;
	a = init_stack(a);
	scanf("%s", buf);
	for(i = 0; buf[i] != '\0'; i++){
		if(buf[i] == 'B' && empty_stack(a)){
			
		}else if(buf[i] == 'B'){
			pop(a);
		}else{
			push(a, buf[i]);
		}
	}
	print_stack_r(a);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> d(n);
    for(int i=0;i<n;i++){
        cin>>d[i];
    }
    sort(d.begin(),d.end());
    vector<int> dsum(n+1,0);
    
    cout<<d[n/2]-d[n/2-1];
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main() {
	int a, b, k, cont[101];
	scanf("%d %d %d", &a, &b, &k);
	int i = 1, j = 0;		
	for(i = 1; i < 101; i++){
			if(a%i == 0 && b%i == 0){
				cont[j] = i;
				j++;
			}			
	}
	printf("%d\n", cont[j-k]);

	return 0;
}

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



int main(){

   ll k,n;
   cin>>k>>n;

   ll arr[n];

   for(ll i=0;i<n;i++){
       cin>>arr[i];
   }
   arr[n] = k;

   ll sum = 0;

   for(ll i=0;i<n-1;i++){
     sum+=(arr[i+1]-arr[i]);
   }

   sum+=(k-arr[n-1]+arr[0]);

   ll fin = sum;

//    cout<<sum<<endl;

   for(ll i=0;i<n;i++){
       fin = min(fin,sum-(arr[i+1]-arr[i]));
   }

   fin = min(fin,sum-(k-arr[n-1]+arr[0]));
   
   cout<<fin;

}

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

int main(){
  int K, S, X, Y, Z, ans = 0;
  cin >> K >> S;
  
  for (X = 0; X <= K; X++){
    for (Y = X; Y <= K; Y++){
      for (Z = Y; Z <= K; Z++){
        if (X + Y + Z != S){
          continue;
        }
        
        if (X == Y && Y == Z){
          ans += 1;
        }
        else if(X == Y || Y == Z || Z == X){
          ans += 3;
        }
        else{
          ans += 6;
        }
      }
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3520
N = int(input())
H = list(map(int, input().split()))
h = H[-1]
ans = "Yes"
for i in range(N-1, -1, -1):
  if H[i] <= h+1:
    h = min(h, H[i])
  else:
    ans = "No"
    break
print(ans)

Measured memory_bytes: 14224
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
int h;
int n;
int k;
long long a[200009];
int main(){
	while(cin>>n>>k){
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		long long sum=0;
		sort(a,a+n);
		for(int i=n-1;i>=0;i--){
			if(k>0){
				k--;
				continue;
			}else{
				sum+=a[i];
			}
		}
		cout<<sum<<endl;
	}
	return 0;
} 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
#define ll long long

signed main() {
  string s;
  cin >> s;
  int st = 0;
  int ed = 1;
  rep(i, s.length()-1) {
    if(s[st]==s[ed]) {
      cout << st+1<<" "<<ed+1 << endl;
      return 0;
    }
    st++;
    ed++;
  }
  st = 0;
  ed = 2;
  rep(i, s.length()-2) {
    if(s[st]==s[ed]) {
      cout << st+1<<" "<<ed+1 << endl;
      return 0;
    }
    st++;
    ed++;
  }
  cout << "-1 -1" << endl;
  return 0;
}

Measured memory_bytes: 3728
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<tuple>
#include<set>
#include<cmath>
#include<numeric>
#define ll long long
#define MOD = 1e9+7
const double PI=3.14159265358979323846; 
using namespace std;

int main(){
  int K;
  string S;
  cin >> K >> S;
  if(S.size() <= K){
     cout << S << endl;
  }else{
    for(int i=0;i<K;i++){
      cout << S[i];
    }
    cout << "..." << endl;
  }
}


Measured memory_bytes: 3068
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N, K;
  cin >> N >> K;

  int n = 1;
  for (int i = 0; i < N; i++) {
    n = min(n * 2, n + K);
  }

  cout << n << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
dp = [[0, 0, 0] for _ in range(N + 1)]

for i in range(1, N+1):
    a = list(map(int, input().split()))
    for j in range(3):
        dp[i][j] = a[j] + max(dp[i - 1][(j+1) % 3], dp[i - 1][(j+2) % 3])

print(max(dp[N]))

Measured memory_bytes: 86260
#pragma GCC target("popcnt")
#include <bits/stdc++.h>
using namespace std;
int N;
int a[111];
int b[111][11];
int ans=-2e9;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>N;
    for(int i=0;i<N;i++){
        int r=0;
        for(int j=0;j<10;j++){
            r*=2;
            int x;
            cin>>x;
            r+=x;
        }
        a[i]=r;
    }
    for(int i=0;i<N;i++)
        for(int j=0;j<11;j++)
            cin>>b[i][j];
    for(int x=1;x<1024;x++){
        int y=0;
        for(int i=0;i<N;i++){
            auto z=x&a[i];
            y+=b[i][__builtin_popcount(z)];
        }
        ans=max(ans,y);
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int mxN=300, M=1e9+7;
int n, c[3];
long double dp[mxN+1][mxN+1][mxN+1];
int main()
{
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);

	cin >> n;
	for(int i=0; i<n; ++i)
    {
		int ai;
		cin >> ai;
		++c[ai-1];
	}
	for(int k=0; k<=c[2]; ++k)
		for(int j=0; j<=n; ++j)
			for(int i=0; i<=n; ++i)
			{
				int tc=i+j+k;
				if(!tc||tc>n)
					continue;
				dp[i][j][k]=1;
				if(i)
					dp[i][j][k]+=dp[i-1][j][k]*i/n;
				if(j)
					dp[i][j][k]+=dp[i+1][j-1][k]*j/n;
				if(k)
					dp[i][j][k]+=dp[i][j+1][k-1]*k/n;
				dp[i][j][k]*=(long double)n/tc;
			}
	cout << fixed << setprecision(16) <<  dp[c[0]][c[1]][c[2]];
	return 0;
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;

int n, d;

int main(){
  cin >> n >> d;
  int x[n][d];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < d; j++){
      cin >> x[i][j];
      // cout << i << " "<<j<<" "<<x[i][j] << endl;
      // cout  << n << endl;
    }
  }
  // for(int i = 0; i < n; i++){
  //   for(int j = 0; j < d; j++){
  //     cout << i << " "<<j<<" "<<x[i][j] << endl;
  //   }
  // }
  // cout << x[0][0] << endl;
  int ans = 0;
  // cout << n << endl;
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      double distance = 0;
      for(int k = 0; k < d; k++){
        // cout << distance << endl;
        // cout << x[i][k] << " " << x[j][k] << endl;
        distance += pow((x[i][k]-x[j][k]), 2);
      }

      // cout <<  i <<" "<< j << " "<< distance << endl;
      // cout << sqrt(distance) << endl;
      double check = sqrt(distance) - (int)sqrt(distance);
      if(check == 0)ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
a = int(input())
ar = list(map(int,input().split(" ")))
ar.insert(0,0)
ar.append(0)
count = 0
for i in range(1,a+2):
    count += abs(ar[i]-ar[i-1])
for i in range(1,a+1):
    b = abs(ar[i-1]-ar[i+1])
    c = abs(ar[i-1]-ar[i])
    d = abs(ar[i]-ar[i+1])
    print(count + b - c - d)

Measured memory_bytes: 14048
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    ll ans = 0;
    REP(p_bit, (int)pow(2, n - 1)) {
        int r = 0;
        int l = 0;
        while(l < n and r < n) {
            FOR(i, l, n - 1)if((p_bit >> i & 1) == 1 or i == n - 1) {
                r = i;
                break;
            }
            ans += stoll(s.substr(l, r - l + 1));
            l = r + 1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
def factrization(n):
    arr = []
    temp = n
    
    for i in range(2, int(n**0.5//1) + 2):
        if temp%i == 0:
            cnt = 0
            while temp%i == 0:
                cnt += 1
                temp //= i
            arr.append(i)
    
    if temp != 1:
        arr.append(temp)
    
    if arr == []:
        arr.append(n)
    
    return arr

a, b = map(int, input().split())
ans = 0

la = factrization(a)
lb = factrization(b)

if 1 not in la:
    la.append(1)
if 1 not in lb:
    lb.append(1)

for i in la:
    if i in lb:
        ans += 1

print(ans)

Measured memory_bytes: 9472
a,b,c,d = map(int,input().split())
ta = 0
ao = 0
if c % b == 0:
    ta = c//b
else:
    ta = c//b + 1

if a % d == 0:
    ao = a // d
else:
    ao = a // d + 1

if ao < ta:
    print('No')
else:
    print('Yes')

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

int coin[6] = {500,100,50,10,5,1};

int main(){
  int c,t;
  int ans;
  
  while(true){
    
    scanf(" %d",&c);
    if(c==0)break;
    
    t = 1000 - c;
    
    ans = 0;
    for(int i=0;i<6;i++){
      while(t>=coin[i]){
        t-=coin[i];
        ans++;
      }
    }
    
    printf("%d\n",ans);
  }
  
  return 0;
}

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

#define INF (1<<21)

int **num;
int *dat;

void matrixChainOrder(int*,int**,int);

int main(){
  int n;
  int i=0,j;
  scanf("%d",&n);

  num=malloc(sizeof(int *)*(n+2));
  dat=malloc(sizeof(int)*(n*2+2));
  while(i!=n+2){
    num[i++]=malloc(sizeof(int)*(n+2));
  }
  
  
  for(i=1;i<=n;i++){
    scanf("%d%d",&dat[i-1],&dat[i]);
  }
  matrixChainOrder(dat,num,n);

  i=0;

  while(i!=n+2){
    free(num[i++]);
  } 
  free(num);
  free(dat);

  return 0;
}

void matrixChainOrder(int *dat,int **num,int n){
  int i,j,k,l;
  int q;

  for(i=1;i<=n;i++){
    num[i][i]=0;
  }
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      num[i][j]=INF;
      for(k=i;k<j;k++){
	q=num[i][k]+num[k+1][j]+dat[i-1]*dat[k]*dat[j];
	if(num[i][j]>q) num[i][j]=q;
      }
    }
  }
  printf("%d\n",num[1][n]);
}

Measured memory_bytes: 636
def solve(string):
    n, k, *a = map(int, string.split())
    a, t = [_a - 1 for _a in a], [0] * n
    p = c = 0
    while not t[a[p]]:
        c += 1
        t[a[p]] = c
        p = a[p]
        if c == k:
            return str(p + 1)
    k = (k - t[a[p]] + 1) % (t[p] - t[a[p]] + 1)
    for _ in (range(k)):
        p = a[p]
    return str(p + 1)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 109096
s = input()
t = input()

dp = [[0]*len(t) for i in range(len(s))]


for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            if i > 0 and j > 0:
                dp[i][j] = dp[i-1][j-1] + 1
            else:
                dp[i][j] = 1
        else:
            if i > 0:
                dp[i][j] = max(dp[i-1][j], dp[i][j])
            if j > 0:
                dp[i][j] = max(dp[i][j-1], dp[i][j])


ret = ['']*dp[-1][-1]
id = dp[-1][-1]
i = len(s) - 1
j = len(t) - 1
while(i >= 0 and j >= 0):
    #print(s[i], t[j], i, j)
    if s[i] == t[j]:
        id -= 1
        ret[id] = s[i]
        i -= 1
        j -= 1
        # print(ret)
    else:
        if i > 0 and dp[i-1][j] >= dp[i][j-1]:
            i -= 1
        else:
            j -= 1

print(''.join(ret))
#print(*dp, sep='\n')


Measured memory_bytes: 113244