akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <random>
#include <ctime>
#include <chrono>

using namespace std;

typedef int64_t ll;
typedef uint64_t ull;

const ll LINF = 9187201950435737471;
const ll nLINF = -9187201950435737472;
const int INF = 2139062143;
const int LOL = 450;
const int nINF = -2139062144;
const ull ULINF = numeric_limits<ull>::max();
const int MAXN = 3e5 + 15;
const ll MOD = 1e9;
const double EPS = 1e-6;
const double PI = acos(-1);
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rnd(seed);

#define all(_v) _v.begin(), _v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define sqr(_v) ((_v) * (_v))
#define eb emplace_back
#define pb push_back
#define mod(x, m) ((x) % m + ((x) < 0 ? m: 0))
#define vi vector<int>
#define pi pair<int,int>


inline void IO() {
#if(DEBUG_LEVEL > 0)
    freopen("../input.txt", "r", stdin);
    freopen("../out.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
}

template <typename T>
istream& operator >> (istream& in, vector<T>& a) {
    for (auto& i : a)
        in >> i;
    return in;
}

template <typename T>
ostream& operator << (ostream& out, const vector<T>& a) {
    for (auto& i : a) {
        out << i << " ";
    }
    return out;
}

template <typename T, typename D>
istream& operator >> (istream& in, pair<T, D>& a) {
    in >> a.first >> a.second;
    return in;
}

template <typename T, typename D>
ostream& operator << (ostream& out, const pair<T, D>& a) {
    out << a.first << " " << a.second;
    return out;
}

#define int ll

inline void solve() {
    string s;
    int n;
    cin >> s;
    n = sz(s);
    vi cnt(n, 0);
    for (int i = 0; i < n; ++i) {
        int r = i;
        while (r < n && s[r] == s[i]) {
            r++;
        }
        r--;
        int to = i, for_to = i - 1;
        if (s[i] == 'R') {
            to = r;
            for_to = r + 1;
        }
        for (int j = i; j <= r; ++j) {
            if (abs(to - j) % 2 == 1) {
                cnt[for_to]++;
            }
            else {
                cnt[to]++;
            }
        }
        i = r;
    }
    cout << cnt;
}

signed main() {
    IO();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4244
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, t, a;
    cin >> n;
    cin >> t >> a;
    vector<float> h(n);
    rep(i, n)
    {
        cin >> h[i];
        h[i] = abs(t - h[i] * 0.006 - a);
    }
    
    auto min_it = min_element(h.begin(), h.end());
    size_t min_idx = distance(h.begin(), min_it);
    
    cout << min_idx + 1 << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
a = input()
b = input()
c = input()

start = "a"

for i in range(len(a) + len(b) + len(c)):
  if start == "a":
    if len(a) == 0:
      print("A")
      exit()
    start = a[0]
    a = a[1:]
  elif start == "b":
    if len(b) == 0:
      print("B")
      exit()
    start = b[0]
    b = b[1:]
  else:
    if len(c) == 0:
      print("C")
      exit()
    start = c[0]
    c = c[1:]

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int a, b;
  cin >> a >> b;
  if (a == 1) a = 14;
  if (b == 1) b = 14;
  cout << (a > b ? "Alice" : a < b ? "Bob" : "Draw") << endl;
}


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

#define BTC 380000
using namespace std;

bool isBTC(string u){
        return (u == "BTC");
}


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

        double sum = 0;
        double x;
        string u;
        for(int i = 0; i < N; i++){
                cin >> x >> u;
                if(isBTC(u)) sum += x * BTC;
                else sum += x;
        }

        cout << fixed << sum;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 21:06:53 2019

@author: doppe
"""

N = int(input())
S = input()
K = int(input())

ans = ""
for c in S:
    if (c == S[K - 1]):
        ans += c
    else:
        ans += '*'
print(ans)

Measured memory_bytes: 3060
#include <iostream>
typedef long long ll;
ll gcd(ll _a, ll _b) {
  unsigned long long a = abs(_a), b = abs(_b);
  if(a == 0) return b;
  if(b == 0) return a;
  int shift = __builtin_ctzll(a | b);
  a >>= __builtin_ctzll(a);
  do {
    b >>= __builtin_ctzll(b);
    if(a > b) std::swap(a, b);
    b -= a;
  }while(b);
  return (a << shift);
}

int cnt[1000001];

int main(){
  int n;scanf("%d", &n);
  for(int i=0;i<n;i++) {
    int num;scanf("%d", &num);
    cnt[num]++;
  }
  int max_S = 0;
  for(int i=2;i<=1000000;i++){
    int S = 0;
    for(int j=i;j<=1000000;j+=i) S += cnt[j];
    max_S = std::max(max_S, S);
  }
  if(max_S<2) printf("pairwise coprime\n");
  else if(max_S != n) printf("setwise coprime\n");
  else printf("not coprime\n");
}


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

int main() {
    string s; cin >> s;
    long long k; cin >> k;
    for (int i = 0; i < min<long long>(s.size(), k); i++) {
        if (s[i] >= '2') return !(cout << s[i] << endl);
    }
    cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
# define M_PI           3.14159265358979323846  /* pi */
using namespace std;

#define int long long
#define loop(x) for(int i = 0;i<(x);i++)
string alpha = "abcdefghijklmnopqrstuvwxyz";
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout.tie(0);
	int x; cin >> x;
	cout << (2 * x * M_PI);
}



Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
const int mxN=1e5;
int a[mxN+2],b[mxN+2],c[mxN+2],dp[mxN+2][3]{};
int main()
{
    int n;cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i]>>b[i]>>c[i];
    for(int i=1;i<=n;i++)
    {
        dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
        dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
        dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}


Measured memory_bytes: 5908
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
int a[100010];
P p[100010];
signed main() {	
	int n, m;
	cin >> n >> m;
	rep(i, n) {
		cin >> a[i];
	}
	sort(a, a + n);
	rep(i, m) {
		cin >> p[i].second >> p[i].first;
	}
	sort(p, p + m, greater<>());
	int s = 0;
	rep(i, m) {
		rep(j, p[i].second) {
			if (s >= n)break;
			if (a[s] <= p[i].first) {
				a[s] = p[i].first;
				s++;
			}
			else break;
		}
	}
	int ans = 0;
	rep(i, n) {
		ans += a[i];
	}
	cout << ans << endl;
}


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

#define int long long

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

/*
#define cin ifs
#define cout ofs
ifstream ifs("in.txt");
ofstream ofs("out.txt");
//*/

int N, M;
vector<int> G[100000];
int color[100000] = {};
vector<bool> bipartite;
vector<int> npoints;

bool dfs(int n, int c) {
    color[n] = c;
    npoints[npoints.size() - 1]++;
    bool res = true;
    for (int i = 0; i < G[n].size(); i++) {
        if (color[G[n][i]] == c) {
            res = false;
        } else if (color[G[n][i]] == 0) {
            res &= dfs(G[n][i], -c);
        }
    }
    return res;
}

signed main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int u, v;
        cin >> u >> v;
        G[u - 1].push_back(v - 1);
        G[v - 1].push_back(u - 1);
    }
    for (int i = 0; i < N; i++) {
        if (color[i] == 0) {
            npoints.push_back(0);
            bipartite.push_back(dfs(i, 1));
        }
    }
    int a = 0, b = 0, c = 0;
    for (int i = 0; i < npoints.size(); i++) {
        if (npoints[i] == 1) {
            a++;
        } else if (!bipartite[i]) {
            b++;
        } else {
            c++;
        }
    }
    int ans = 2 * a * N - a * a + b * b + 2 * b * c + 2 * c * c;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13312
#include <iostream>
#include <string.h>
using namespace std;

int main(){
  string str;
  long long k;
  cin >> str >> k;
  if(k!=1){
    for(int i=0;i<str.size();i++){
      if(str[i]!='1'){
        cout << str[i] << endl;
        return 0;
      }else if(k==(i+1)){
        cout << str[i] << endl;
        return 0;
      }
    }
  }else{
    cout << str[0] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

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

using i64 = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

i64 read() {
    using namespace _buff;
    i64 ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

size_t reads(int *s) {
    using namespace _buff;
    size_t ret = 0;
    char c = getc();
    for (; c != '0' && c != '1'; c = getc()) {
        assert(~c);
    }
    for (; c == '0' || c == '1'; c = getc()) {
        s[ret++] = c ^ 48;
    }
    return ret;
}

using u64 = unsigned long long;

const size_t L = 60;

struct Basis {
    u64 b[L];

    Basis() {
        memset(b, 0, sizeof b);
    }

    void add(u64 x) {
        for (size_t i = L; i--; ) {
            if (x >> i & 1) {
                if (!b[i]) {
                    b[i] ^= x;
                    return;
                }
                x ^= b[i];
            }
        }
    }

    bool query(u64 x) {
        for (size_t i = L; i--; ) {
            if (x >> i & 1) {
                x ^= b[i];
            }
        }
        return !x;
    }
};

void add(Basis &b, u64 x) {
    static u64 bas[L];
    memcpy(bas, b.b, sizeof b.b);
    for (size_t i = 0; i < L; ++i) {
        b.add(bas[i] ^ x);
    }
}

const size_t N = 2E2 + 5;

u64 a[N]; int b[N];

void solve() {
    int n = read();
    generate_n(a, n, read);
    assert(n == (int) reads(b));
    reverse(a, a + n); reverse(b, b + n);
    Basis bas;
    for (int i = 0; i < n; ++i) {
        if (b[i]) {
            if (!bas.query(a[i])) {
                puts("1"); return;
            }
        } else {
            add(bas, a[i]);
        }
    }
    puts(bas.query(0) ? "0" : "1");
}

int main() {
    for (int t = read(); t--; ) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
int w[4],c[4],V;
const int MAXN=5001*5001;
int f[MAXN];
int solve_package()
{
	memset(f,0,sizeof f);
	int res=0;
	for(int j=1;j<=3;++j)
	{
		if(c[j]<=0)
			continue;
		for(int i=w[j];i<=V;++i)
		{
			f[i]=max(f[i],f[i-w[j]]+c[j]);
			res=max(res,f[i]);
		}	
	}
	return res;
}
int pr[2][4];
signed main()
{
	V=read();
	for(int i=0;i<2;++i)
		for(int j=1;j<=3;++j)
			pr[i][j]=read();
	for(int i=1;i<=3;++i)
	{
		c[i]=pr[1][i]-pr[0][i];
		w[i]=pr[0][i];
	}
	V+=solve_package();
	for(int i=1;i<=3;++i)
	{
		c[i]=pr[0][i]-pr[1][i];
		w[i]=pr[1][i];
	}	
	V+=solve_package();
	cout<<V<<endl;
	return 0;
}


Measured memory_bytes: 195584
#include<bits/stdc++.h>
using namespace std;
string s;
int main() {
	cin >> s;
	for(int i = 1; i<s.size(); i++)
		if(s[i] == s[i - 1]) {
			cout << i << " " << i + 1 << endl;
			return 0;
		}
	for(int i = 2; i < s.size(); i++)
		if(s[i] == s[i - 2]) {
			cout << i - 1 << " " << i + 1 << endl;
			return 0;
		}
	cout << "-1 -1\n" <<endl;
	return 0;
}

Measured memory_bytes: 512
import collections

n,q = map(int,input().split())

a = collections.deque()

for i in range(n):
    a.append(input().split())
    #print(a)

time = 0

while len(a) > 0:
    p = int(a[0][1])
    #print(p)
    if p > q:
        p -= q
        a[0][1] = str(p)
        a.append(a.popleft())
        time += q
        #print(a,time)
    else:
        time += p
        print(a.popleft()[0],time)


Measured memory_bytes: 17400
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Diagnostics;
using System.Reflection.Metadata;
using System.Threading;
using System.Runtime.CompilerServices;

namespace AtCoder
{
    class Program
    {

        struct Point
        {
            public int x;
            public int y;

            public Point(int x, int y)
            {

                this.x = x;
                this.y = y;

            }

        }


        const int BiggestMod = 1000000007;

        public static void Main()
        {

            var num = int.Parse(Console.ReadLine());
            var h = int.Parse(Console.ReadLine());
            var w = int.Parse(Console.ReadLine());

            Console.WriteLine((num - h + 1) * (num - w + 1));

        }

    }

}

Measured memory_bytes: 27452
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> a;
int main()
{
	int K;
	cin>>K;
	if( K<=10 )
	{
		cout << K << endl;
		return 0;
	}
	for( int i=1;i<=9;i++)
		a.push_back(i);
	int s = 9;
	while(true)
	{
		vector<ll> tmp;
		for( int i=0; i<a.size(); i++ )
		{
			int b = a[i]%10;
			if( b>0 )
			{
				tmp.push_back(a[i]*10+b-1);
				s++;
				if( s==K )
				{
					cout << a[i]*10+b-1 << endl;
					return 0;
				}
			}
			tmp.push_back(a[i]*10+b);
			s++;
			if( s==K )
			{
				cout << a[i]*10+b << endl;
				return 0;
			}
			if( b<9 )
			{
				tmp.push_back(a[i]*10+b+1);
				s++;
				if( s==K )
				{
					cout << a[i]*10+b+1 << endl;
					return 0;
				}
			} 
		}
		a = tmp;
	}
		
	return 0;
}


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

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

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

  int t;
  for (int i = 1; i <= 5; ++i) {
    cin >> t;
    if (t == 0) {
      cout << i << endl;
      exit(0);
    }
  }
  
  return 0;
}


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

int main(int argc, char const *argv[]) {
    int n;
    string s;
    cin >> n >> s;

    for (int i = 0; i < s.size(); i++) {
        s[i] += n;
        if (s[i] > 'Z') s[i] -= 26;
    }

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3656
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>
#include<functional>
#include<numeric>
#include <tuple>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
#define tpop(p) p.top();p.pop()
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bitcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}*/
//---------------------------------------------------
int n;
map<string, int>m;
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		char b[10];
		for (int j = 0; j < s.size();j++) {
			b[j] = s[j];
		}
		sort(b, b + s.size());
		s = "";
		for (int j = 0; j < 10; j++) {
			s += b[j];
		}
		m[s]++;
	}
	int ans = 0;
	for (auto g : m) {
		ans += g.sc * (g.sc - 1) / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 12800
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

M = list(input())
N = [int(m) for m in M]

ans_list = [N[0],'+',N[1],'+',N[2],'+',N[3],'=',7]

for i in range(1<<3):
    tmp = N[0]
    for j in range(3):
        if i & (1<<j):
            tmp += N[j+1]
            ans_list[j*2+1] = '+'
        else:
            tmp -= N[j+1]
            ans_list[j*2+1] = '-'
    if tmp == 7:
        ans_maped = map(str,ans_list)
        ans = ''.join(ans_maped)
        print(ans)
        break

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

int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		double Xa, Ya, Ra, Xb, Yb, Rb;
		cin >> Xa >> Ya >> Ra >> Xb >> Yb >> Rb;

		double distance = sqrt(pow(Xb - Xa, 2) + pow(Yb - Ya, 2));
		if (distance > Ra + Rb)
		{
			cout << 0 << endl;
			continue;
		}
		if (distance + Rb < Ra)
		{
			cout << 2 << endl;
			continue;
		}
		if (distance + Ra < Rb)
		{
			cout << -2 << endl;
			continue;
		}
		cout << 1 << endl;
	}

	return 0;
}

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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int a;
  cin >> a;
  cout << (a % 10 == 9 || a >= 90 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
use std::fmt;
use std::io::stdin;
use std::io::BufRead;
use std::str;
use std::str::FromStr;
use std::vec::Vec;

fn main() {
    let stdin = stdin();
    let mut scan = InputScanner::new(stdin.lock(),256);

    let n:usize = scan.next();
    let m:usize = scan.next();

    let c:Vec<usize> = (0..m).map(|_| scan.next()).collect::<Vec<usize>>();

    let mut dp:Vec<usize> = (0..(n+1)).map(|_| 0).collect::<Vec<usize>>();

    dp[0] = 0;

    for n in 1..(n+1) {
        let mut min = std::usize::MAX;

        for &c in &c {
            if c <= n && dp[n-c] + 1 < min {
                min = dp[n-c] + 1;
            }
        }

        dp[n] = min;
    }

    println!("{}",dp[n]);
}
struct InputScanner<R: BufRead> {
	reader: R,
	buf: Vec<u8>, // Should never be empty
	pos: usize,   // Should never be out of bounds as long as the input ends with '\n'
}
impl<R: BufRead> InputScanner<R> {
	fn new(reader: R, capacity: usize) -> Self {
		InputScanner {
			reader: reader,
			buf: Vec::with_capacity(capacity),
			pos: 0,
		}
	}

	#[inline]
	fn next<T: FromStr>(&mut self) -> T
	where
		T::Err: fmt::Debug,
	{
		if self.buf.is_empty() {
			self._read_next_line();
		}
		let mut start = None;
		loop {
			match (self.buf[self.pos], start.is_some()) {
				(b' ', true) | (b'\n', true) | (b'\r', true) => break,
				(_, true) | (b' ', false) => self.pos += 1,
				(b'\n', false) | (b'\r', false) => self._read_next_line(),
				(_, false) => start = Some(self.pos),
			}
		}
		let target = &self.buf[start.unwrap()..self.pos];
		unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
	}

	#[inline]
	fn _read_next_line(&mut self) {
		self.pos = 0;
		self.buf.clear();
		if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
			panic!("Reached EOF");
		}
	}
}




Measured memory_bytes: 5032
#include <iostream>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <math.h>


int main(){
  int N;
  scanf("%d",&N);
  std::string S;
  std::cin >> S;
  for (int i=0; i<S.length(); i++){
    printf("%c",(S[i]-65+N)%26+65);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 888
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		int N=sc.nextInt();
		int M=sc.nextInt();
		long K=sc.nextLong();
		long[] A=new long[N];
		long[] B=new long[M];
		for (int i=0;i<N;++i) {
			A[i]=sc.nextLong();
			if (i>0) A[i]+=A[i-1];
		}
		for (int i=0;i<M;++i) {
			B[i]=sc.nextLong();
			if (i>0) B[i]+=B[i-1];
		}
		int p=0;
		long ans=0;
		while (p<N && A[p]<=K) ++p;
		for (int q=0;q<=M;++q) {
			while (p>0 && (p==0?0:A[p-1])+(q==0?0:B[q-1])>K) --p;
			long v=(p==0?0:A[p-1])+(q==0?0:B[q-1]);
			if (v<=K) ans=Math.max(ans, p+q);
		}
		System.out.println(ans);
	}

	void tr(Object...o) {System.out.println(Arrays.deepToString(o));}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
        	ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    
    public double nextDouble() { return Double.parseDouble(next());}
}


Measured memory_bytes: 40744
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define sf(n) scanf("%f",&n)
#define pf(n) printf("%.12f",n)
#define psp printf(" ")
#define endc printf("\n")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

//const int maxn = 2e5 + 7; 
//const int md = 1e9 + 7;

string no = "UNRESTORABLE";

int main() {
	string s,t;
	cin>>s>>t;

	if (t.size() > s.size()) {
		cout<<no<<endl; return 0;
	}
	

	string inf = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
	string b = inf;

	string ans = inf;

	for (int i = 0; i + t.size() <= s.size(); i++) {
		string b = s; bool ok = true;
		for (int j = 0; j < t.size(); j++) {
			//cout<<s[i + j];
			if (s[i + j] != '?' && s[i + j] != t[j]) {
				ok = false; break;
			}
			b[i + j] = t[j];
		}
		//cout<<endl;

		if (!ok) continue;

		for (int j = 0; j < s.size(); j++) {
			if (b[j] == '?') b[j] = 'a';
		}

		ans = min(ans, b);
	}

	if (ans == inf) {
		cout<<no<<endl;
	} else {
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<iterator>
using namespace std;
using ll = long long;

int main(){
    int M,N; cin >> N >> M;
    vector<int> c{2,5,5,4,5,6,3,7,6};
    vector<int> a(M); for(int i=0;i<M;i++) cin >> a[i], a[i]--;
    sort(rbegin(a), rend(a));
    vector<int> dp(N+1, -1e9);
    vector<int> prev(N+1);
    dp[0] = 0;
    for(int i=1;i<=N;i++){
        for(int j=0; j<M; j++)if(i-c[a[j]] >= 0){
            int curr = dp[i - c[a[j]]] + 1;
            if(curr > dp[i]){
                dp[i] = curr;
                prev[i] = a[j];
            }
        }
    }

    string res;
    while(N>0){
        res += '1' + prev[N];
        N -= c[prev[N]];
    }
    cout << res << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














string S;
//---------------------------------------------------------------------------------------------------
#define good "Good"
#define bad "Bad"
string solve() {
	rep(i, 0, 3) if (S[i] == S[i + 1]) return bad;
	return good;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> S;
	cout << solve() << endl;
}







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

using ll = long long;
using namespace std;

#define int ll

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define YES(f) if((f)){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(f) if((f)){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(12)

#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);

#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
#define MOD 1000000007

template<class T>
inline T GET() {
	T x;
	cin >> x;
	return x;
}


void init();
void solve();

signed main()
{
	init();
	solve();
}

void init()
{
	int N;
	cin >> N;
	double res = 0;
	rep(i, N) {
		double x;
		string s;
		cin >> x >> s;
		if (s[0] == 'J') {
			res += x;
		} else {
			res += x * 380000.0;
		}
	}
	fcout << res << endl;
}

void solve()
{
}




Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	lli S,a,b;
	cin >> S;

	a = (S + 999999999) / 1000000000;
	b = 1000000000 * a - S;

	cout << 0 << " " << 0 << " " << 1000000000 << " " << b << " " << 1 << " " << a << endl;



	return 0;
}

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

int main(){
    int n;
    cin>>n;
    int t= n%10;
    if(t==2||t==4||t==5||t==7||t==9){
        cout<<"hon"<<endl;
    }else if(t==0||t==1||t==6||t==8){
        cout<<"pon"<<endl;
    }else{
        cout<<"bon"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
 
using namespace std;
 
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define DEBUG(a, i, j) cout << #a << "[" << i << "][" << j << "]: " << a[i][j] << '\t'
 
const int MAXN = 2005;
bool S[MAXN][MAXN];
int v[MAXN][MAXN];
int e[MAXN][MAXN];
int rowe[MAXN][MAXN];
int cole[MAXN][MAXN];
int N, M, Q;
int x1, y1, x2, y2;
 
int main() {
	cin >> N >> M >> Q;
	char c;
	int crow_vsum;
	REP(i, 1, N + 1) {
		crow_vsum = 0;
		REP(j, 1, M + 1) {
			cin >> c;
			S[i][j] = c - '0';
			crow_vsum += S[i][j];
			v[i][j] = crow_vsum + v[i - 1][j];
			e[i - 1][j] += (S[i - 1][j] & S[i][j]);
			rowe[i - 1][j] = rowe[i - 1][j - 1] + (S[i - 1][j] & S[i][j]);
			e[i][j - 1] += (S[i][j - 1] & S[i][j]);
			cole[i][j - 1] = cole[i - 1][j - 1] + (S[i][j - 1] & S[i][j]);
		}
	}
	int crow_esum;
	REP(i, 1, N + 1) {
		crow_esum = 0;
		REP(j, 1, M + 1) {
			crow_esum += e[i][j];
			e[i][j] = crow_esum + e[i - 1][j];
		}
	}
	int vsum, esum;
	REP(i, 0, Q) {
		cin >> x1 >> y1 >> x2 >> y2;
		vsum = v[x2][y2] - v[x1 - 1][y2] - v[x2][y1 - 1] + v[x1 - 1][y1 - 1];
		esum = e[x2][y2] - e[x1 - 1][y2] - e[x2][y1 - 1] + e[x1 - 1][y1 - 1];
		esum -= rowe[x2][y2] - rowe[x2][y1 - 1] + cole[x2][y2] - cole[x1 - 1][y2];
		cout << vsum - esum << '\n';
	}
	return 0;
}

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

const int N = 1e5;
int dp[N][3];
int cs[N][3];

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

	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> cs[i][0] >> cs[i][1] >> cs[i][2];
	}
	dp[0][0] = cs[0][0];
	dp[0][1] = cs[0][1];
	dp[0][2] = cs[0][2];
	for (int i = 1; i < n; ++i) {
		for (int a = 0; a < 3; ++a) {
			for (int b = 0; b < 3; ++b) {
				if (a == b) continue;
				dp[i][a] = max(dp[i][a], dp[i-1][b] + cs[i][a]);
			}
		}
	}
	int res = max(max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]);
	cout << res << '\n';
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int n,ans,a,b;
int main(){
    cin>>a>>b;
    for(int i=a;i<b+1;i++){
        if(i%10==i/10000&&(i%100)/10==(i%10000)/1000)ans++;
    }
    cout<<ans<<endl;
}


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

int main()
{
    int N, temp;
    long ans, ans2, ans3;
    cin >> N;
    ans2 = 0;
    for(int i=1;i<10;i++)
        for(int j=i;j<10;j++){
            ans = 0;
            ans3 = 0;
            if(i==j){
                if(i <= N)
                    ans++;
                if(10*i+j <= N)
                    ans++;
                temp = 10;
                REP(k, 4){
                    REP(l, temp)
                        if(temp*10*i+l*10+j <= N)
                            ans++;
                    temp *= 10;
                }
                ans2 += ans*ans;
            }else{
                if(10*i+j <= N)
                    ans++;
                temp = 10;
                REP(k, 4){
                    REP(l, temp)
                        if(temp*10*i+l*10+j <= N)
                            ans++;
                    temp *= 10;
                }
                
                if(10*j+i <= N)
                    ans3++;
                temp = 10;
                REP(k, 4){
                    REP(l, temp)
                        if(temp*10*j+l*10+i <= N)
                            ans3++;
                    temp *= 10;
                }
                ans2 += ans*ans3*2;
            }
            
        }
    cout << ans2 << endl;
    return 0;
}



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

using namespace std;
const int mod = 1e9 + 7;

int sum(vector<int> &A) {
    int N = A.size();
    int ret = 0;
    for(int i = 0; i < N - 1; i++) {
        long long plus = (i + 1LL) * (N - 1 - i) % mod;
        plus = plus * (A[i + 1] - A[i]) % mod;
        ret = (ret + plus) % mod;
    }
    return ret;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N), B(M);
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < M; i++) cin >> B[i];
    cout << (1LL * sum(A) * sum(B)) % mod << endl; 
    return 0;
}

Measured memory_bytes: 1024
opponent = input()
count_p = 0
count_g = 0
point = 0
for i in range(len(opponent)):
    if opponent[i] == 'g':
        if count_p < count_g:
            count_p += 1
            point += 1
        else:
            count_g += 1
    if opponent[i] == 'p':
        if count_p < count_g:
            count_p += 1
        else:
            count_g += 1
            point -= 1
print(point)


Measured memory_bytes: 3316
#include <cstdlib>
#include <iostream>

using namespace std;

enum stampState{
    EMPTY = 0,
    O = 1,
    X = 2,
};


int main(){
    int n;
    string s;
    bool isO[100000];
    int OXStamp = 0;
    stampState beforeStamp = EMPTY;

    cin >> n;
    cin >> s;

    for(int i=0; i<n; i++){
        if(s[i] == 'O'){
            isO[i] = true;
        }else{
            isO[i] = false;
        }
    }

    for(int i=0; i<n; i++){
        switch(beforeStamp){
            case EMPTY :
                if(isO[i]){
                    beforeStamp = O;
                }else{
                    beforeStamp = X;
                }
                break;
            case O :
                //cout << "Oyo" << endl;
                if(!isO[i]){
                    OXStamp++;
                    beforeStamp = EMPTY;
                }
                break;
            case X :
                //cout << "Xyo" << endl;
                if(isO[i]){
                    OXStamp++;
                    beforeStamp = EMPTY;
                }
                break;
        }
    }
    cout << OXStamp << endl;

    return 0;
}


Measured memory_bytes: 3424
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int r,c;
    while(1)
    {
        cin>>r>>c;
        if(r==0 && c==0)
            break;
        else
        {
            for(int i=0; i<r; i++)
            {
                for(int j=0; j<c; j++)
                {
                    if(j%2==0 && i%2==0)
                        cout<<"#";
                    else if(j%2==1 && i%2==1)
                        cout<<"#";

                    else
                        cout<<".";
                }
                cout<<endl;
            }
        }

        cout<<endl;
    }

    return 0;
}



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

using namespace std;

bool dfs(int v, vector<vector<int> > & g, vector<int> & used) {
    if (used[v]) {
        return false;
    }
    used[v] = 1;
    for (int j = 0; j < g[v].size(); j++) {
        int next = g[v][j];
        dfs(next, g, used);
    }
    return true;
}

bool isConnected(int n, vector<vector<int> > & g) {
    int cnt = 0;
    vector<int> used(n);
    for (int i = 0; i < n; i++) {
        if (dfs(i,g,used)) {
            cnt++;
        }
    }
    return cnt == 1;
}

int countB(int n, int m, vector<pair<int, int> > & e) {
    int ans = 0;
    for (int i = 0; i < m; i++) {
        vector<vector<int> > g(n);
        for (int j = 0; j < m; j++) {
            if (j == i) {
                continue;
            }
            int a = e[j].first;
            int b = e[j].second;
            g[a].push_back(b);
            g[b].push_back(a);
        }
        if (!isConnected(n, g)) {
            ans++;
        }
    }
    return ans;
}

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

    int n, m;
    cin >> n >> m;
    vector<pair<int, int> > e;
    for (int j = 0; j < m; j++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        e.push_back(make_pair(a,b));
    }

    cout << countB(n,m,e) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

class List {

    struct Node {
        int key;
        Node *prev, *next;
    };

    Node *nil;

    void delete_(Node *node) {
        if (node == nil) return;
        node->next->prev = node->prev;
        node->prev->next = node->next;
        delete node;
    }

public:
    List() {
        nil = new Node{-1};
        nil->prev = nil;
        nil->next = nil;
    }

    void insert(int x) {
        Node *node = new Node{x};
        node->prev = nil;
        node->next = nil->next;
        nil->next->prev = node;
        nil->next = node;
    }

    void delete_(int x) {
        Node *node = nil;
        while (node->key != x) {
            node = node->next;
            if (node == nil) break;
        }
        delete_(node);
    }

    void deleteFirst() {
        delete_(nil->next);
    }

    void deleteLast() {
        delete_(nil->prev);
    }

    void dump() {
        Node *node = nil->next;
        if (node != nil) {
            cout << node->key;
            node = node->next;
            while (node != nil) {
                cout << " " << node->key;
                node = node->next;
            }
            cout << endl;
        }
    }
};

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

    List L;

    string command;
    int x;
    while (n--) {
        cin >> command;
        if (command == "insert") {
            cin >> x;
            L.insert(x);
        } else if (command == "delete") {
            cin >> x;
            L.delete_(x);
        } else if (command == "deleteFirst") {
            L.deleteFirst();
        } else {
            L.deleteLast();
        }
    }

    L.dump();
}


Measured memory_bytes: 34376
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,sum;
  cin >> N >> K;
  sum=1;
  for (int i=0; i<N;i++){
    if (sum*2 <= sum+K){
      sum +=sum;
    }
    else{
      sum +=K;
    }
  
  }
  cout << sum << endl;
}

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

using namespace std;

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

    int max = 0, aInd = -99, zInd = -99;
    bool isAdd = false, isZ = false;
    for(unsigned int i = 0; i < s.size(); i++) {
        if(s[i] == 'A' && !isAdd) {
            aInd = i;
            isAdd = true;
        }

        if(s[s.size() - 1 - i] == 'Z' && !isZ) {
            zInd = s.size() - i;
            isZ = true;
        }
    }
    if(isAdd && isZ) {
        max = zInd - aInd;
    } else {
        max = 0;
    }

    std::cout << max << endl;

    return 0;
}

Measured memory_bytes: 640
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
A=[a1[0],a1[1],a1[2],a2[0],a2[1],a2[2],a3[0],a3[1],a3[2]]
#print(A)
n=int(input())
b=[]
for i in range(n):
    b.append(int(input()))

for i in range(n):
    for j in range(9):
        if b[i]==A[j]:
            A[j]="atari"
#print(A)
if A[0]==A[3]==A[6]:
    print("Yes")
elif A[1]==A[4]==A[7]:
    print("Yes")
elif A[2]==A[5]==A[8]:
    print("Yes")
elif A[0]==A[1]==A[2]:
    print("Yes")
elif A[3]==A[4]==A[5]:
    print("Yes")
elif A[6]==A[7]==A[8]:
    print("Yes")
elif A[0]==A[4]==A[8]:
    print("Yes")
elif A[2]==A[4]==A[6]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ull unsigned long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define of(i,p,n) for(ll i=n-1;i>=p;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define mem(x,p) memset(x,p,sizeof(x))
#define trav(it,a) for(auto it=a.begin();it!=a.end();++it)
#define kk "\n"
const ll mod=1e9+7;
int main()
{
  IOS
  ll n,k;
  cin>>n>>k;
  if(n==k||k==1||n==0||(n%k==0))
    cout<<0;
  else
  {
    ll p=abs(n-k);
    if(n<k)
    {
      if(p<n)
        cout<<p;
      else
        cout<<n;
    }
    else
    {
      ll q=n/k;
      q=n-(q*k);
      ll r=abs(q-k);
      cout<<min(r,q);
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[205],i,n,ans=0;
	cin>>n;
	for(i=1;i<=n*2;i++)
		cin>>a[i];
	sort(a+1,a+1+2*n);
	for(i=1;i<=2*n;i+=2)
		ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int N=1e5+11,INF=~0u>>2;
struct Point{int pos,x,y,id;}p[N<<2];
int h,w,n,cnt,S[N<<2],top;
bool cmp(Point a,Point b){
	if(a.pos!=b.pos) return a.pos<b.pos;
	if(a.pos==1) return a.y<b.y;
	if(a.pos==2) return a.x<b.x;
	if(a.pos==3) return a.y>b.y;
	return a.x>b.x;
}
void solve(int x,int y,int i){
	cnt++;p[cnt].id=i;
	if(x==0) p[cnt].pos=1;
	else if(x==h) p[cnt].pos=3;
	else if(y==0) p[cnt].pos=4;
	else if(y==w) p[cnt].pos=2;
	p[cnt].x=x;p[cnt].y=y;
}
bool check(int a,int b){
	if(a==0||a==h||b==0||b==w) return 1;
	return 0;
}
int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return f*x;
}
int main(){
//	freopen("ex.in","r",stdin);
	h=read();w=read();n=read();
	for(int i=1;i<=n;++i){
		int a=read(),b=read(),c=read(),d=read();
		if(check(a,b)&&check(c,d)) solve(a,b,i),solve(c,d,i);
	}
	sort(p+1,p+1+cnt,cmp);
	for(int i=1;i<=cnt;++i){
		S[++top]=p[i].id;
		if(top>1&&S[top]==S[top-1]) top-=2;
	}
	if(top==0) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 5248