akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <deque>
#include <map>
using namespace std;

#define ii pair <int, int>
#define lli long long
#define pb push_back
#define X first
#define Y second

const int Mod = 1E9 + 7;
const int Inf = 1E9 + 7;
const int N = 80 + 10;
const int M = 80 * 160 + 1;

int n, m, a[N][N], b[N][N];
bool F[N][N][M][2];

void Input()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> a[i][j];
    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> b[i][j];
}

void Solve()
{
    memset(F, 0, sizeof(F));
    int Sum = a[1][1] - b[1][1];
    Sum = abs(Sum);
    F[1][1][Sum][1] = F[1][1][Sum][0] = true;


    for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
    for (int k = 0; k < M; k++)
    for (int l = 0; l <= 1; l++){
        if (F[i][j][k][l] == true) {
            int sign = 1;
            if (l == 0) sign = -1;
            int k1 = k * sign + a[i + 1][j] - b[i + 1][j];
            int k2 = k * sign + a[i][j + 1] - b[i][j + 1];

            if (k1 >= 0) F[i + 1][j][k1][1] = true;
            else F[i + 1][j][-k1][0] = true;

            if (k2 >= 0) F[i][j + 1][k2][1] = true;
            else F[i][j + 1][-k2][0] = true;
            ///
            k1 = k * sign - a[i + 1][j] + b[i + 1][j];
            k2 = k * sign - a[i][j + 1] + b[i][j + 1];

            if (k1 >= 0) F[i + 1][j][k1][1] = true;
            else F[i + 1][j][-k1][0] = true;

            if (k2 >= 0) F[i][j + 1][k2][1] = true;
            else F[i][j + 1][-k2][0] = true;

        }
    }

    for (int k = 0; k < M; k++) if (F[n][m][k][0] == true || F[n][m][k][1] == true) {
        cout << k << " ";
        return ;
    }
}

#define task "test"
int main()
{
    if (fopen(task ".inp", "r")) {
        freopen(task ".inp", "r", stdin);
        freopen(task ".out", "w", stdout);
    }
    int testcase = 1;
    /// cin >> testcase;
    while (testcase--) {
        Input();
        Solve();
    }
}




Measured memory_bytes: 205752
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
struct edge {int to,costa,costb;};
vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
signed main() {
    vector<bool> prime=prime_table(55555);
    int n;
    cin>>n;
    
    for(int i=0;i<55555;i++)if(prime[i]&&i%5==1){
        cout<<i<<' ';
        n--;
        if(n==0)break;
    }

return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
    ld r; cin >> r;
    outl(2 * r * M_PI);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

using namespace std;

typedef long long ll;

int plus_minus(vector<ll> A, int N, int id) {
    int sum = 0;
    for(int i = 0; i < N-1; i++) {
        if(i%2 == 0) sum += A[(N+id+i)%N];
        else sum -= A[(N+id+i)%N];
    }
    return sum;
}

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

    vector<ll> A(N, 0);
    //vector<ll> sum(N+1, 0);
    ll sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        if(i % 2 == 0) sum += A[i];
        else sum -= A[i];
    }

    vector<ll> Ans(N, sum);

    cout << Ans[0] << " ";
    for(int i = 1; i < N; i++) {
        Ans[i] = 2 * A[i-1] - Ans[i-1];
        cout << Ans[i] << " ";
    }

}

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

using namespace std;

int main(){
  int n,m,a,b,c;
  a=0;
  char A,B,C;
  for(int i = 0 ;i< 4;i++ ){
    cin >> A;
    if(A=='+') a++;
    else a--;
  }
  cout << a << endl;
}


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

int main() {
    int v[100010];
    int N;
    cin >> N;
    for (int i = 0; i < N;i ++) {
        cin >> v[i];
    }

    int a[100010] = {0};
    for (int i = 0; i < N; i++) {
        a[v[i]]++;
    }

    int ans = 0;
    for (int i = 0; i <= 100000; i++) {
        ans = max(a[i-1] + a[i] + a[i+1], ans);
    }

    cout << ans << endl;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll aa[100000];
int main()
{
	ll a,b,c;
	string s;
	cin>>a>>b>>c;
	if(b-c>=0){
		cout<<"delicious";
	}else if(a+b-c>=0){
		cout<<"safe";
	}else{
		cout<<"dangerous";
	}
}

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

using namespace std;
using ll=long long;
using db=double;

typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<bool> vbl;

int inf=(1LL<<31)-1;
int MOD=1000000007;

#define fi(a,b) for(int i=a;i<b;i++)
#define fj(a,b) for(int j=a;j<b;j++)
#define f_i(a,b) for(int i=a;i<=b;i++)
#define f_j(a,b) for(int j=a;j<=b;j++)
#define vvii(c,a,b) vector<vector<ii>> c(a,vector<ii>(b,0))
#define vvll(c,a,b) vector<vector<ll>> c(a,vector<ll>(b,0))
#define vvstr(c,a,b) vector<vector<string> c(a,vector<string>(b,0))
#define vvbol(c,a,b) vector<vector<bool>> c(a,vector<bool>(b,true))

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

    int n;
    cin >> n;
    vll num(n+1,0);
    vll ans(n+1,0);
    ll mx=-10;
    f_i(1,n)
    {
        cin >> num.at(i);
        mx=max(mx,num.at(i));
    }
    ll count=inf;
    f_i(1,mx)
    {
        ll a=0;
        f_j(1,n)
        {
            a+=(num.at(j)-i)*(num.at(j)-i);
        }
        count=min(count,a);
    }
    cout << count << endl;
    return(0);

}

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

int main() {
    int N;
    cin >> N;
    int P[N];
    for(int i = 0; i < N; ++i) cin >> P[i];
    
    int counter = 0;
    int Pmin = P[0];

    for(int i = 0; i < N; i++){
        if(P[i] <= Pmin) counter++;
        if(P[i] < Pmin) Pmin = P[i];
    }
    cout << counter << endl;
}

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

using namespace std;

const int maxn = 30;
string s;
int a[maxn];

int main(){
	cin >> s;
	for(int i=0; i<s.size()-2; i++)
		a[i] = ((s[i]-48)*100) + ((s[i+1]-48)*10) + (s[i+2]-48);
	for(int i=0; i<s.size()-2; i++)
		a[i] = max(a[i]-753, 753-a[i]);
	int ans = a[0];
	for(int i=1; i<s.size()-2; i++)
		ans = min(ans, a[i]);
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
//const long long INF = 1LL << 60;
 int INF = 500000;
 int MAX = 1e5+10;
 ll mod = 1e9+7;


int main(){
  int n,d;
  cin >> n;
  vector<int> a(n,0);
  vector<int> a_p(n,0);
  rep(i,n)cin >> a[i];
  copy(all(a),a_p.begin());
  sort(rall(a_p));
  rep(i,n){
    if(a_p[0] == a[i]) cout << a_p[1] << endl;
    else cout << a_p[0] << endl;
  }
}

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

int main() {
  int a,b,x;
  cin>>a>>b>>x;
  if(a+b<x){
    cout<<"NO"<<endl;
  }
  else if(a>x){
    cout<<"NO"<<endl;
  }
  else{
    cout<<"YES"<<endl;
  }
  
}


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

#define MAX 200000

int main(void){
  long i,ans1=0,ans2=1;

  char str[MAX+1];
  scanf(" %s",str);

  int reset=0;
  for(i=0;i<strlen(str);i++){
    if(reset==0){
      ans1++;
      reset=1;
    }else if(str[i]!=str[i-1]){
      ans1++;
    }else if(i!=strlen(str)-1){
      ans1++;
      i++;
      reset=0;
    }
  }

  reset=0;
  for(i=2;i<strlen(str);i++){
    if(reset==0){
      ans2++;
      reset=1;
    }else if(str[i]!=str[i-1]){
      ans2++;
    }else if(i!=strlen(str)-1){
      ans2++;
      i++;
      reset=0;
    }
  }

  if(ans1>=ans2){
    printf("%ld\n",ans1);
  }else{
    printf("%ld\n",ans2);
  }

  return 0;
}


Measured memory_bytes: 384
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::collections::BTreeMap;

fn main() {
    let n: usize = read();
    let a: Vec<u32> = read_col(n);
    let mut b = a.clone();
    b.sort();
    let mut map: BTreeMap<u32, usize> = BTreeMap::new();
    for i in 0..n {
        map.insert(b[i], i);
    }
    let mut cnt: u32 = 0;
    for i in 0..n {
        let j = map.get(&a[i]).unwrap();
        if (i + j) % 2 == 1 {
            cnt += 1;
        }
    }
    println!("{}", cnt / 2);
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
//#pragma GCC optimize(2)
//#define int long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(a>0&&c>0)
	{
		c-=b;
		if(c<=0) break;
		a-=d;
		if(a<=0) break;
	}
	if(a>0) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


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

#define int long long

using namespace std;

//int dp[3005][3005]={0};
//int dp[100005]={0};

signed main(){
	int a; cin>>a;
	// while(a--){
	//
	// }
	cout<<(a + a*a + a*a*a);
	// int n; cin>>n;
}


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

int main(){
    string s;
    cin>>s;
    int N=s.size();
    int check=0;
    rep(i, (N-1)/2){
        if(s.at(i)!=s.at((N-3)/2-i)){
            check=1;
            break;
        }
    }
    rep(i, (N-1)/2){
        if(s.at((N+1)/2+i)!=s.at(N-i-1)){
            check=1;
            break;
        }
    }
    rep(i, N){
        if(s.at(i)!=s.at(N-i-1)){
            check=1;
            break;
        }
    }
    if(check==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % MOD;
       base = base * base % MOD;
    }
    return tot;
}

int n;

int interval = 500;
pair<int, int> buckets[500][2];
int arr[200005];

void update(int value, int position){

    arr[position] = value;

    int parity = position % 2;

    int left = position / interval * interval;
    int right = min(n, left + interval);

    buckets[left / interval][parity] = make_pair(1e9, 1e9);

    for(int pos = left; pos < right; ++pos){
        if(pos % 2 == parity)
            buckets[pos / interval][parity] = min(buckets[pos / interval][parity], make_pair(arr[pos], pos));
    }

}

pair<int, int> query(int left, int right, int parity){

    pair<int, int> best = make_pair(1e9, 1e9);

    for(;left % interval > 0 && left < right; ++left)
        if(left % 2 == parity)
            best = min(best, make_pair(arr[left], left));

    while(left + interval < right){
        best = min(best, buckets[left / interval][parity]);
        left += interval;
    }

    for(;left < right; ++left)
        if(left % 2 == parity)
            best = min(best, make_pair(arr[left], left));

    return best;

}

void init(){
    for(int i = 0; i < n; ++i)
        update(arr[i], i);
}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    cin >> n;

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

    init();

    priority_queue<vector<int>> pq;

    pair<int, int> ree1 = query(0, n, 0);
    pair<int, int> ree2 = query(ree1.second, n, 1);

    pq.push({-ree1.first, -ree2.first, ree1.second, ree2.second, 0, n});

    while(!pq.empty()){

        vector<int> state = pq.top(); pq.pop();
        int l = state[2], r = state[3], pl = state[4], pr = state[5];

        cout << -state[0] << " " << -state[1] << " ";

        //left side
        if(pl < l){
            ree1 = query(pl, l, pl % 2);
            ree2 = query(ree1.second, l, 1 - pl % 2);
            pq.push({-ree1.first, -ree2.first, ree1.second, ree2.second, pl, l});
        }

        //center side
        if(l + 1 < r){
            ree1 = query(l + 1, r, 1 - l % 2);
            ree2 = query(ree1.second, r, l % 2);
            pq.push({-ree1.first, -ree2.first, ree1.second, ree2.second, l + 1, r});
        }

        //right side
        if(r + 1 < pr){
            ree1 = query(r + 1, pr, 1 - r % 2);
            ree2 = query(ree1.second, pr, r % 2);
            pq.push({-ree1.first, -ree2.first, ree1.second, ree2.second, r + 1, pr});
        }

    }

    return 0;

}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    vvi to(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    rep(i, n) cout << to[i].size() << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

int n;
long long h, a[100005], b[100005];
int main() {
	std::cin >> n >> h;
	for (int i = 0; i < n; ++i)
		std::cin >> a[i] >> b[i];
	std::sort(a, a + n, std::greater<long long>());
	std::sort(b, b + n, std::greater<long long>());

	long long ans = 0;
	for (int i = 0; i < n&&h>0; ++i)
		if (b[i] > a[0])
			++ans, h -= b[i];
	if (h > 0)
		ans += (h + a[0] - 1) / a[0];
	std::cout << ans << std::endl;
	return 0;
}


Measured memory_bytes: 1792
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    A = LI()
    S = defaultdict(int)
    for a in A:
        S[a]+=1
        if S[a]>=3:
            print(0)
            return
    if S[0]>=2:
        print(0)
        return 
    print(pow(2,N//2,mod))

    

if __name__ == '__main__':
    main()

Measured memory_bytes: 80984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int cnt=0;
    int n=len(s);
    rep(i,len(s)){
      if(s[i]=='o') cnt++;
    }
    cnt+=15-n;
    if(cnt>=8){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 384
import collections
from operator import itemgetter
N,K = map(int,input().split())
ball = [int(j) for j in input().split()]

kind = dict(collections.Counter(ball))

if len(kind) <= K:
    print(0)
else:
    skind = sorted(kind.items(),key=itemgetter(1))
    sumNum = 0
    for i in range(len(skind)-K):
        sumNum += skind[i][1]
    print(sumNum)

Measured memory_bytes: 39284
#include <bits/stdc++.h>
#define mk make_pair
using namespace std;
typedef long long ll;
const int N = 3e3 + 5;
int n, m, tt, dp[N][N];
char s[N], t[N], ans[N];
pair<int, int> pre[N][N];
int main() {
	scanf("%s %s", s + 1, t + 1);
	n = strlen(s + 1);
	m = strlen(t + 1);
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if (dp[i - 1][j] > dp[i][j - 1])
				pre[i][j] = mk(i - 1, j);
			else
				pre[i][j] = mk(i, j - 1);
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]); 
			if (s[i] == t[j] && dp[i - 1][j - 1] + 1 > dp[i][j]) {
				pre[i][j] = mk(i - 1, j - 1);
				dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
			}
		}
	}
	int i = n, j = m;
	while (i || j) {
		int ii = pre[i][j].first;
		int jj = pre[i][j].second;
		if (ii != i && jj != j) ans[++tt] = s[i];
		i = ii;
		j = jj;
	}
	reverse(ans + 1, ans + 1 + tt);
	ans[tt + 1] = 0;
	cout << ans + 1 << endl; //cout << dp[n][m];
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    string S;
    string T;
    cin >> S >> T;

    ll N = S.length();

    REP(i, N){
        bool flag = true;
        REP(j, N){
            if(S[(i+j)%N] != T[j]){
                flag = false;
                break;
            }
        }
        if(flag){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main(){
    int n,max;
    cin>>n>>max;
    vector<int> cdx(n,0);
    for(int &x:cdx)cin>>x;
    int ttl=0;
    for(int i=0;i<n;i++){
        if(cdx.at(i)<=max/2){
            ttl+=cdx.at(i)*2;
        }else{
            ttl+=(max-cdx.at(i))*2;
        }
    }
    cout<<ttl<<endl;
    return 0;
}

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

const int INF = 100000000;

int h,w;
char field[101][101];

bool row[101];
bool col[101];



int main() {
    cin >> h >> w;
    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            cin >> field[i][j];
        }
    }

    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            if(field[i][j]=='#'){
                row[i] = 1;
            }
        }
    }

    for(int i=0;i<w;++i){
        for(int j=0;j<h;++j){
            if(field[j][i]=='#'){
                col[i] = 1;
            }
        }
    }

    // for(int i=0;i<h;i++){
    //     cout << row[i];
    // }    
    // cout << endl;
    // for(int i=0;i<w;i++){
    //     cout << col[i];
    // }    
    
    // cout << endl;

    for(int i=0;i<h;++i){
        for(int j=0;j<w;++j){
            if(row[i]==1&&col[j]==1){
                cout << field[i][j];
            }
            if(j==w-1&&row[i]==1)cout << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 764
N = int(input())

A,S = [0]*32,[0]*32
A[0],A[1],S[0],S[1] = 1,-2,1,-2
for i in range(2,32):
    A[i] = A[i-1]*(-2)
    S[i] = S[i-2] + A[i]

X = ["0"]*32
t = 0
flg = True
while N != 0:
    if N > 0:
        for i in range(32):
            if S[i] >= N:
                break
    else:
        for i in range(32):
            if S[i] <= N:
                break
    X[i] = "1"
    N -= A[i]

print(int("".join(X)[::-1]))

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>
using namespace std;

int main(){
  bool card[4][13];
  for(int i = 0; i<4; i++){
    for(int j=0; j<13; j++){
      card[i][j]=false;
    }
  }

  int n;
  cin>>n;

  char kind;
  int num;
  for(int i = 0; i<n; i++){
    cin>>kind>>num;
    switch (kind) {
      case 'S':
        card[0][num-1]=true;
        break;
      case 'H':
        card[1][num-1]=true;
        break;
      case 'C':
        card[2][num-1]=true;
        break;
      case 'D':
        card[3][num-1]=true;
        break;
      }
    }
  char c[4]={'S','H','C','D'};
  for(int i = 0; i<4; i++){
    for(int j = 0; j<13; j++){
      if(!card[i][j]){
        cout<<c[i]<<' '<<j+1<<endl;
      }
    }
  }
}

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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
// clang-format on
/* }}} */


signed main() 
{
  int n;
  cin >> n;
  int tmp;
  vector<int> v(n);
  REP(i,n)
  {
    cin >> v[i];
  }
  sort(ALL(v));
  v.erase(unique(ALL(v)),v.end());
  int cnt=v.size();
  cout << cnt << endl;
}

Measured memory_bytes: 256
//Compiler optimization
#pragma GCC optimize("Ofast")

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

//typedef
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vl> mat;

//macro
#define reverse(a) reverse(a.begin(),a.end())
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define each(x, v) for (auto &x : v)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll pow(ll a,ll n, ll m){
    ll ret=1;
    for(;n>0;n>>=1,a=a*a%m){
        if(n%2==1){
        ret=ret*a%m;
        }
    }
    return ret;
}

//abbreviation
#define pb push_back
#define elif else if
#define mp make_pair
#define endl '\n'

//debug
#define debug(x) cerr << #x << ": " << x << endl
#define v_debug(v) cerr << #v << endl;fr(i,v.size()) cerr << i << ": " << v[i] << endl

//const
const  ll INF = 1e18;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(20);
    int t;cin >> t;
    ll n,m,a,b;
    while(t--){
        cin >> n >> m >> a >> b;
        cout << atcoder::floor_sum(n,m,a,b) << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N, M;
  long long ans = 0;
  long long cnt = 0;

  cin >> N >> M;

  vector<long long> A(N);
  vector<long long> B(N);
  vector<pair<long long, long long>> AB(N);
  for(int i = 0; i < N; i++){
    cin >> A[i] >> B[i];
    AB[i] = make_pair(A[i], B[i]);
  }

  sort(AB.begin(), AB.end());

  for(int i = 0; i < N; i++){
    //cout << AB[i].first << ", " << AB[i].second << endl;
    //cout << "i = " << i << ", cnt = " << cnt << endl;

    if((M - cnt) >= AB[i].second){
      //全部買ってもまだ足りない
      ans += AB[i].first * AB[i].second;
      cnt += AB[i].second;
      //cout << "p1:++ ,  ans += " << AB[i].first * AB[i].second << endl;
    }else{
      //全部買ったら多すぎる
      int pcNum = M - cnt; 
      ans += AB[i].first * pcNum;
      //cout << "p2:++ ,  ans += " << AB[i].first * pcNum << endl;
      break;
    }
    //cout << "ans = " << ans << endl;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3328
#include <cstdio>
int a,b;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int main(){
    while(~scanf("%d%d",&a,&b)){printf("%d %lld\n",gcd(a,b),1LL*a*b/gcd(a,b));}
    return 0;
}

Measured memory_bytes: 2644
from itertools import accumulate
from bisect import bisect

n, m, k = map(int, input().split())
(*a,) = accumulate(map(int, input().split()))
(*b,) = accumulate(map(int, input().split()))
a = (0,) + tuple(i for i in a if i <= k)
b = tuple(i for i in b if i <= k)
print(max(i + bisect(b, k - a[i]) for i in range(len(a))))

Measured memory_bytes: 47840
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;

int main(){
  int r;
  cin >> r;
  cout << 3*r*r;
  return 0;
}

Measured memory_bytes: 256
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


s = S()
t = S()
if s == t:
    print(0)
    exit()

ans = len(t)
for i in range(len(s)-len(t)+1):
    # print(f'{i=}')
    now = 0
    for j in range(len(t)):
        # print(f'{(s[i+j], t[j])=}')
        if s[i+j] != t[j]:
            now += 1
    # print(f'{now=}')
    ans = min(ans, now)

print(ans)


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

#define prime 50021
#define Sprime 223

int main() {
	int sn, bn, n;
	bool not_prime[prime + 1];
	for (int i = 2; i <= Sprime; i++) {
		if (!not_prime[i]) {
			for (int j = i + i; j <= prime; j += i) {
				not_prime[j] = true;
			}
		}
	}
	while (cin >> n) {
		sn = bn = n;
		while (not_prime[--sn]);
		while (not_prime[++bn]);
		cout << sn << " " << bn << endl;
	}
}


Measured memory_bytes: 3128
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int n,m; cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
use std::cmp;

// Input macro
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

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

// Test Code
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
    // "0 75 25 100" => "50",
    "0 33 66 99" => "0",
    // "10 90 20 80" => "60",
}

fn main() {
    println!("{}", solve(&stdin!()));
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        a_start: u32,
        a_end: u32,
        b_start: u32,
        b_end: u32,
    }

    let start = cmp::max(a_start, b_start);
    let end = cmp::min(a_end, b_end);

    cmp::max(end as i32 - start as i32, 0).to_string()
}

Measured memory_bytes: 4352
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  char c; cin >> c;
  cout << ++c << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3572
#include <stdio.h>
#define N 100
int main(){
  int n,i,j,u,k,v,M[N][N];

  scanf("%d",&n);

  for(i=0 ; i<n ; i++)
    {
      for(j=0 ; j<n ; j++)
	{
	  M[i][j] = 0;
	}
    }

  for(i=0 ; i<n ; i++)
    {
      scanf("%d",&u);
      scanf("%d",&k);
      for(j=0 ; j<k ; j++)
	 {
	  scanf("%d",&v);
	  M[u-1][v-1] = 1;
	}
    }

    for(i=0 ; i<n ; i++)
    {
      for(j=0 ; j<n-1 ; j++)
	{
	  printf("%d ",M[i][j]);
	}
      printf("%d",M[i][n-1]);
      printf("\n");
    }
  
  return 0;
}



Measured memory_bytes: 2104
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cctype>
#define DEBUG(x) cout<<#x<<" = "<<x<<endl
using namespace std;
bool judge(const string &s)
{
    if(s[0]!='A')return false;
    int sz=s.size();
    if(isupper(s[sz-1])||isupper(s[1]))return false;
    int uc=0;
    for(int i=2;i<=sz-2 ;i++ ){
        if(s[i]=='C')uc++;
        else if(isupper(s[i]))return false;
    }
    if(uc==1)return true;
    return false;
}
int main()
{
//    freopen("in.txt","r",stdin);
    string s;
    while(cin>>s)
    {
        string ans;
        if(judge(s))ans="AC";
        else ans="WA";
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        static long inf = (long) 1e17;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int[] p = new int[n];
            for (int i = 0; i < n; i++) {
                p[i] = Integer.parseInt(in.next());
            }
            long min = inf;
            int ans = 0;
            for (int i = 0; i < n; i++) {
                if (p[i] < min) {
                    min = p[i];
                    ans++;
                }
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 51476
class MyStack(object):
    """stack class

    Attributes:
        stack: stack
    """

    def __init__(self):
        self.stack = [0] * 1000
        self.top = 0

    def pop(self):
        """pop method

        Returns:
            popped object
        """
        if self.top - 1 < 0:
            print("Stack Underflow")
        else:
            value = self.stack[self.top]
            self.stack[self.top] = 0
            self.top -= 1
            return value

    def push(self, value):
        """ push method
        Args:
            value: value to be pushed
        """
        if self.top + 1 >= len(self.stack):
            print("Stack Overflow")
        else:
            self.top += 1
            self.stack[self.top] = value

sequence = raw_input().split()
operators = {"*": "*", "+": "+", "-": "-"}
stack = MyStack()
for s in sequence:
    if s in operators:
        value2 = stack.pop()
        value1 = stack.pop()
        stack.push(str(eval(value1 + operators[s] + value2)))
    else:
        stack.push(s)

print(stack.pop())

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

int Max(vector<int> x){
  int a=x.size();
  for(int i=0;i<a-1;i++){
    x.at(i+1)=max(x.at(i),x.at(i+1));
  }
  return x.at(a-1);
}

int Min(vector<int> x){
  int a=x.size();
  for(int i=0;i<a-1;i++){
    x.at(i+1)=min(x.at(i),x.at(i+1));
  }
  return x.at(a-1);
}

int main() {
  int N,M,A,B;
  cin>>N>>M;
  vector<int> a(M);
  vector<int> b(M);
  for(int i=0;i<M;i++){
    cin>>a.at(i)>>b.at(i);
  }
  A=Max(a);
  B=Min(b);
  if(A>B){
    cout<<0;
  }
  else{
    cout<<B-A+1;
  }
  
}


Measured memory_bytes: 1416
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{
  string o,e;
  cin>>o>>e;

  rep(i,o.length()+e.length()){
    if(i%2==0){
      cout<<o[i/2];
    }else{
      cout<<e[i/2];
    }
  }

  cout<<endl;
  return 0;
}


Measured memory_bytes: 3636
#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;
}

int N, M;
int a[1050], b[1050], c[1050][20];

void input() {
    cin >> N >> M;
    for(int i = 1; i <= M; i++) {
        cin >> a[i] >> b[i];
        for(int j = 1; j <= b[i]; j++) cin >> c[i][j];
    }
}

void solve() {
    input();
    const int INF = 1e9;
    vector<int> dp(5000, INF);
    dp[0] = 0;
    for(int item = 1; item <= M; item++) {
        int now = 0;
        for(int j = 1; j <= b[item]; j++) {
            now |= (1 << (c[item][j] - 1));
        }
        for(int bits = 0; bits < (1 << N); bits++) {
            chmin(dp[bits | now], dp[bits] + a[item]);
        }
    }
    if(dp[(1 << N) - 1] == INF) dp[(1 << N) - 1] = -1;
    cout << dp[(1 << N) - 1] << endl;
    return;
}

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


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

int main() {
	long long N;
	string S;
	cin >> N >> S;
	for (int i = 0; i < S.size(); i++) {
		long long C = S[i] - 'A';
		C = (C + N) % 26;
		S[i] = (C + 'A');
	}
	cout << S << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
char a[110];
long long int ad(long long int b, long long int c, long long int d){
    if(a[b]=='\0'){
        return d+c;
    }
    return ad(b+1,c*10+a[b]-'0',d)+ad(b+1,a[b]-'0',d+c);
}
int main(){
    scanf("%s",a);
    printf("%lld",ad(1,a[0]-'0',0));
}

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

void run(void){
  int n;
  scanf("%d",&n);
  int *a=(int *)calloc(n,sizeof(int));
  int *used=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",a+i);
  int g=0;
  for(i=0;i<n;i++) g^=a[i];
  int cnt=0;
  while(g>0){
    int b=1;
    while(2*b<=g) b*=2;
    for(i=0;i<n;i++) if(!used[i] && a[i]%(2*b)==b) break;
    if(i>=n){
      printf("-1\n");
      return;
    }
    g=g^a[i]^(a[i]-1);
    a[i]--;
    used[i]=1;
    cnt++;
  }
  printf("%d\n",cnt);
}

int main(void){
  run();
  return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  int ans = 1;
  int ans1, ans2;

  for(int i=0; i<N; i++) {
    ans1 = ans*2;
    ans2 = ans+K;
    if(ans1 < ans2) ans = ans1;
    else ans = ans2;
  }
  cout << ans << endl;
}

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

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

  vector<string> s(n);
  for (int i = 0; i < n; i++) cin >> s[i];

  sort(s.begin(), s.end());

  string t;
  for (int i = 0; i < n; i++) {
    t += s[i];
  }

  cout << t << endl;
}

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

int d[14];
int memo[10][4][2][1 << 14];
bool solve(int p, int cnt, bool r,int u) {
	if (memo[p][cnt][r][u] != -1)return memo[p][cnt][r][u];
	bool ok = false;
	if (cnt == 3) {
		int f = -1, s = -1;
		rep(i, 14) {
			if (!(u>>i&1)) {
				if (f == -1)f = d[i];
				else if (s == -1)s = d[i];
				else ok = true;
			}
		}
		if (!ok) {
			if (f == s)return memo[p][cnt][r][u]=true;
			return memo[p][cnt][r][u]=false;
		}
		ok = true; cnt = 0;
	}
	rep(i, 14) {
		if (!(u>>i&1) && (ok || (r&&d[i] == p + 1) || (!r&&d[i] == p))) {
			u |= 1 << i;
			if (solve(d[i], cnt + 1, r,u))return memo[p][cnt][r][u]=true;
			if (ok) {
				if (solve(d[i], cnt + 1, !r,u))return memo[p][cnt][r][u]=true;
			}
			u ^= 1 << i;
		}
	}
	return memo[p][cnt][r][u]=false;
}
int main() {
	while (1) {
		int cnt[10]{};
		rep(i, 13) {
			if (!~scanf("%1d", &d[i]))return 0;
			cnt[d[i]]++;
		}
		bool flag = false;
		for (int i = 1; i <= 9; i++) {
			if (cnt[i] >= 4)continue;
			d[13] = i;
			memset(memo, -1, sizeof(memo));
			if (solve(0, 3, 0, 0)) {
				if (flag)printf(" ");
				printf("%d", i);
				flag = true;
			}
		}
		if (!flag)printf("0");
		printf("\n");
	}
}

Measured memory_bytes: 8312
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
const long long INF = numeric_limits<long long>::max();
template <class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

string A, B;
ll func() {
    if (A == B) {
        return 0;
    } else if (A.size() < B.size()) {
        return -1;
    } else if (A.size() > B.size()) {
        return 1;
    }
    for (ll i = 0; i < A.size(); ++i) {
        ll a = A[i] - '0';
        ll b = B[i] - '0';
        if (a > b) return 1;
        if (a < b) return -1;
    }
    return 0;
}
int main() {
    cin >> A >> B;

    ll ans = func();
    if (ans == 0) {
        cout << "EQUAL" << endl;
    } else if (ans < 0) {
        cout << "LESS" << endl;
    } else if (ans > 0) {
        cout << "GREATER" << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <stdio.h>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cfloat>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <iomanip>

using namespace std;

#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
// #define req(j, n) for (ll j = 1; j < (n+1); j++)
// #define rer(k, n) for (ll k = 1; k < (n+1); k++)



int main()
{
    int a;
    cin >> a;
    int ans;
    ans = a + pow(a,2) + pow(a,3);
    cout << ans << endl;
}


Measured memory_bytes: 4096
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder118A
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            //int a = int.Parse(Console.ReadLine());
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            // 文字列の入力
            //string s = Console.ReadLine();
            int c = (B % A);
            if (c == 0)
            {
                Console.WriteLine(A+B);
            }
            else
            {
                Console.WriteLine(B-A);
            }
        }
    }
}


Measured memory_bytes: 13140
//@winlere
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std; typedef long long ll;
inline int qr(){
	int ret=0,f=0,c=getchar();
	while(!isdigit(c)) f|=c==45,c=getchar();
	while( isdigit(c)) ret=ret*10+c-48,c=getchar();
	return f?-ret:ret;
}
const int maxn=2e5+5;
int n,m;
char w[maxn];
vector<int> e[maxn<<1];
int usd[maxn<<1];
void add(int fr,int to){e[fr].push_back(to);}

void dfs(int now,int last){
	usd[now]=1;
	for(auto t:e[now])
		if(t^last){
			if(!usd[t]) dfs(t,now);
			else if(usd[t]!=-1) puts("Yes"),exit(0);
		}
	usd[now]=-1;
}

int main(){
	n=qr(); m=qr();
	scanf("%s",w+1);
	for(int t=1,a,b;t<=m;++t){
		a=qr(),b=qr();
		if(w[a]!=w[b]) add(a,b+n),add(b,a+n);
		else add(a+n,b),add(b+n,a);
	}
	for(int t=1;t<=n+n;++t)
		if(!usd[t]) dfs(t,0);
	puts("No");
	return 0;
}


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

int M,N,B[100];

bool isTokyo(int x){
	int w = 0, h = 1;
	for(int i=0;i<N;){
		if(w+B[i]>x){
			w = 0;
			if(++h>M) return true;
		}
		else w += B[i++];
	}
	return false;
}

int main(){
	while(cin>>M>>N,M||N){
		for(int i=0;i<N;i++) cin>>B[i];
		int l = 0, r = 1500000;
		while(l+1!=r){
			int piv = (l+r)/2;
			if(!isTokyo(piv)) r = piv;
			else l = piv;
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 1136
#include <iostream>
using namespace std;
int main() {
	int a, b;
	while (true) {
		cin >> a >> b;
		if (a == 0 && b == 0) { break; }
		for (int i = 0; i < a; i++) {
			for (int j = 0; j < b; j++) {
				if ((i + j) % 2 == 0) { cout << '#'; }
				else { cout << '.'; }
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3108
import itertools
from sys import stdin
input = stdin.readline


def main():
  N, M, Q = list(map(int, input().split()))
  cands = itertools.combinations(range(N+M-1), N)
  Qs = [tuple(map(int, input().split())) for _ in range(Q)]

  seq = [0]*N
  max_ = 0
  for cand in cands:
    temp_max = 0
    for i in range(N):
      seq[i] = cand[i] - i

    for a, b, c, d in Qs:
      if seq[b-1] - seq[a-1] == c:
        temp_max += d
    max_ = max(max_, temp_max)

  print(max_)


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 73736
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(A: int, B: int):
    ret = (A + B) % 24
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
  int A,B,C,D,E,F,sum=0,min=101;
  scanf("%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F);
  sum=A+B+C+D+E+F;
  if(E>F) sum-=F;
  else sum-=E;

  if(A>B) min=B;
  else min=A;
  if(min>C) min=C;
  if(min>D) min=D;
  sum-=min;
  printf("%d\n",sum);

  return 0;
}



Measured memory_bytes: 2096
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
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++)

int main(void) {
    int n,a,b;
    cin >> n;
    a = n / 10;
    b = n % 10;
    if (a==9 | b==9) {
      cout << "Yes";
    } else {
      cout << "No";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256