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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define fo(i, a, b) for(reg i = a; i <= b; i++)
#define fd(i, a, b) for(reg i = a; i >= b; i--)
#define bp __builtin_popcount
#define cr const reg&
using namespace std;
const int N = 2e5 + 1, mod = 998244353, inv2 = mod + 1 >> 1;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int read() {
	reg 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 << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(LL x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(LL x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(LL x) {put(x), putchar(' ');}
I void pr2(LL x) {put(x), puts("");}

struct edge {
	int x, y, next;
} e[N * 2]; int len, last[N];
int tp, mx, rt, sta[N], fa[N];
int f[N][3][3], tmp[3][3];
//x-y,y-x

I void ins(cr x, cr y) {e[++len] = edge{x, y, last[x]}, last[x] = len;}

void dfs(cr x, cr dep) {
	if(dep > mx) mx = dep, rt = x;
	for(reg k = last[x]; k; k = e[k].next) if(e[k].y ^ fa[x]) fa[e[k].y] = x, dfs(e[k].y, dep + 1);
}

void treedp(cr x, cr fa, cr dep) {
	dep == tp / 2 ? f[x][1][1] = 1 : f[x][0][0] = 1;
	for(reg k = last[x]; k; k = e[k].next) if(e[k].y ^ fa){
		reg y = e[k].y;
		treedp(y, x, dep + 1);
		fo(i, 0, 2) fo(j, 0, 2) fo(k, 0, 2) fo(l, 0, 2) fo(g, -1, 1) {
			reg z = _min(2, i + k * (g == 1)), p = _min(2, j + l * (g == -1));
			tmp[z][p] = (tmp[z][p] + (LL)f[x][i][j] * f[y][k][l]) % mod;
		} fo(i, 0, 2) fo(j, 0, 2) f[x][i][j] = tmp[i][j], tmp[i][j] = 0;
	}
}

int main() {
	reg n = read();
	fo(i, 1, n - 1) {
		reg x = read(), y = read();
		ins(x, y), ins(y, x);
	} dfs(1, 1), mx = fa[rt] = 0, dfs(rt, 1);
	for(; rt; rt = fa[rt]) sta[++tp] = rt;
	if(tp & 1) rt = sta[tp / 2 + 1], treedp(rt, 0, 0), pr2((LL)inv2 * f[rt][1][1] % mod);
	else {
		reg x = sta[tp / 2], y = sta[tp / 2 + 1];
		treedp(x, y, 1), treedp(y, x, 1);
		reg c1 = ((LL)f[x][1][0] + f[x][1][1] + f[x][1][2]) % mod, c2 = ((LL)f[y][1][0] + f[y][1][1] + f[y][1][2]) % mod;
		pr2((LL)c1 * c2 % mod);
	} return 0;
}



Measured memory_bytes: 20608
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>
using namespace std;
using ll = long long;
#define rep(i,k) for (int i = 0; i < (int)(k); i++)
#define all(c) begin(c), end(c)

using Weight = int;
using Capacity = int;
struct Edge {
    int src, dst; Weight weight;
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

const int INF = 1e9;

Graph g;
int n;
int k;

int solve_even() {
    int ans = 1e9;
    for (int i = 0; i < n; i++) {
        int dist[2010];
        fill(dist, dist + n, INF);
        queue<int> q;
        q.push(i);
        dist[i] = 0;
        int vis = 0;
        while (q.size()) {
            int v = q.front();
            q.pop();
            ++vis;
            if (dist[v] == k / 2) continue;
            for (auto &e : g[v]) {
                int d = e.dst;
                if (dist[d] > dist[v] + 1) {
                    q.emplace(d);
                    dist[d] = dist[v] + 1;
                }
            }
        }
        ans = min(ans, n - vis);
    }
    return ans;
}

int rec(int u, int p, int lim) {
    int res = 1;
    if (lim == 0) return res;
    for (auto &e : g[u]) {
        if (e.dst == p) continue;
        res += rec(e.dst, u, lim - 1);
    }
    return res;
}

int solve_odd() {
    int ans = INF;
    for (auto &es : g) {
        for (auto &e : es) {
            int x = rec(e.src, e.dst, k / 2);
            int y = rec(e.dst, e.src, k / 2);
            //assert(x + y == n);
            ans = min(ans, n - (x + y));
        }
    }
    return ans;
}


int main() {
    while (cin >> n) {
        cin >> k;
        g.assign(n, {});
        for (int i = 0; i < n-1; i++) {
            int a, b;
            cin >> a >> b;
            --a; --b;
            g[a].emplace_back(a, b, 1);
            g[b].emplace_back(b, a, 1);
        }
        if (k % 2 == 0) {
            cout << solve_even() << endl;
        } else {
            cout << solve_odd() << endl;
        }
    }
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin >> N;
    ll t,i;
    ll prime[1000001];
    ll ans=0;
    for(i=2;i<=1000000;i++){
        if(N%i==0){
            t=N;
            while(t%i==0){
                t=t/i;
            }
            if(t%i==1){
                ans++;
            }
        }
    }
    t=N;
    for(i=2;i<=1000000;i++){
            while(t%i==0)t=t/i;
    }
    ll t1,t2;
    if(t!=1){
        t1=t;
        while(t1<N){
            t2=N;
            while(t2%t1==0){
                t2=t2/t1;
            }
            if(t2%t1==1){
                ans++;
            }
            t1+=t;
        }
    }
    if(N>1000000)ans++;
    ll tcnt,cnt=1;
    t=N-1;
    for(i=2;i<=1000000;i++){
        tcnt=0;
        while(t%i==0){
            t=t/i;
            tcnt++;
        }
        cnt*=tcnt+1;
    }
    if(t!=1)cnt*=2;
    ans+=cnt-1;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
using namespace std;
 
int main()
{
  int n;
  cin >> n;
  int ans = 0;
  while (n != 0)
  {
    if (n % 10 == 2)
    {
      ans++;
    }
    n /= 10;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<deque>

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

using namespace std;

bool check(string &s,int sp,int ep) {
  int a = 0, b = 0;
  REP(i,sp+1,ep) {
    if( s[i] == '(' ) ++a;
    if( s[i] == '[' ) ++b;
    if( s[i] == ')' ) --a;
    if( s[i] == ']' ) --b;
    if( a < 0 || b < 0 ) return false;
  }
  return a == 0 && b == 0;
}

int main() {
  string s;
  while( getline(cin,s), s != "." ) {
    bool ok = true;
    deque<int> a,b;
    rep(i,(int)s.size()) {
      if( s[i] == '(' ) a.push_back(i);
      if( s[i] == '[' ) b.push_back(i);
      if( s[i] == ')' ) {
	if( a.empty() ) { ok = false; break; }
	int sp = a.back(); a.pop_back();
	if( !check(s,sp,i) ) { ok = false; break; }
      }
      if( s[i] == ']' ) {
	if( b.empty() ) { ok = false; break; }
	int sp = b.back(); b.pop_back();
	if( !check(s,sp,i) ) { ok = false; break; }
      }
    }
    if( a.size() || b.size() ) ok = false;
    puts(ok?"yes":"no");
  }
  return 0;
}

Measured memory_bytes: 3136
#include<iostream>
using namespace std;
int n, k, mod, i, j, ii;
int d[305][305], s[305][305], c[305][305];
int main(){
    cin>> n >> k >> mod;
    c[0][0] = 1;
    for(i = 1; i <= n; i++){
        c[i][0] = 1;
        for(j = 1; j <= i; j++){
            c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
        }
    }
    for(i = k; i >= 0; i--){
        d[1][i] = 1;
        s[1][i] = s[1][i + 1] + 1;
    }
    for(i = 2; i <= n + 1; i++){
        for(j = k; j >= 0; j--){
            for(ii = 1; ii < i; ii++){
                d[i][j] = (d[i][j] + d[i - ii][j] * 1LL * s[ii][j + 1] % mod * c[i - 2][ii - 1]) % mod;
            }
            s[i][j] = (s[i][j + 1] + d[i][j]) % mod;
        }
    }
    cout<< d[n + 1][0];
}


Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>
#include <bitset>
#include <string.h>
// #include <limits.h>

#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long        ll;
typedef unsigned long long    ull;

#define INTMAX  99999999

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

string S;

#define MAX_S (100000)
int numg[MAX_S+1];
int nump[MAX_S+1];
int diff[MAX_S+1];

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	cin >> S;

	FORULE(i,1,S.size()) {
	// FOR(i,S.size()) {
		if(S[i-1]=='g') {
			numg[i] = numg[i-1]+1;
			nump[i] = nump[i-1];
		}
		else {
			numg[i] = numg[i-1];
			nump[i] = nump[i-1]+1;
		}
		// DOUT << "numg["<<i<<"]="<<numg[i]<<", nump["<<i<<"]="<<nump[i]<<endl;
		diff[i] =numg[i]-nump[i];
		// DOUT << "diff["<<i<<"]="<<diff[i]<<endl;
	}

	cout << diff[S.size()]/2 << endl;

	return 0;
}
 


Measured memory_bytes: 1616
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define PI 3.14159265358979
 
void mul_mod(ll& a, ll b){
    a *= b;
    a %= MOD;
}
 
void add_mod(ll& a, ll b){
    b += MOD;
    a += b;
    a %= MOD;
}

int main(void){
    int q,k,dp[1234][1234],i,j,n,m;
    string x,y;
    cin >> q;
    for(k=0; k<q; ++k){
        fill(dp[0],dp[1234],0);
        cin >> x >> y;
        n = x.l_ength();
        m = y.l_ength();
        for(i=0; i<n; ++i){
            for(j=0; j<m; ++j){
                dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
                if(x[i] == y[j]){
                    dp[i+1][j+1] = max(dp[i][j]+1,dp[i+1][j+1]);
                }
            }
        }
        cout << dp[n][m] << endl;
    }
    return 0;
}


Measured memory_bytes: 9064
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;

static class MainClass
{
    public static void Main(string[] args)
    {
        var abc = Console.ReadLine().SplittedStringToInt32List();
        var a = abc[0];
        var b = abc[1];
        var c = abc[2];
        var isok = false;
        if (a == 1)
        {
            isok = true;
        }
        else
        {
            for (int i = 1; i <= a * a * a ; i++)
            {
                var ii = a * i;
                if (ii % b == c)
                {
                    isok = true;
                }
            }

        }
        
        Console.WriteLine(isok ? "YES" : "NO");
        Console.ReadLine();
    }
    

    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<long> SplittedStringToInt64List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();
    public const int INF = int.MaxValue / 2;
    public const long LONGINF = long.MaxValue / 2;

  
  

    public static void PrintArray(int[,] array)
    {
        for (int i = 0; i < array.GetLength(0); i++)
        {
            var sb = new StringBuilder();
            for (int j = 0; j < array.GetLength(1); j++)
            {
                sb.Append(array[i, j]).Append(" ");
            }
            Console.WriteLine(sb.ToString());
        }
    }

    #endregion
}



Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define eps 1e-8
#define pi 3.14159265358979
#define LL long long
#define MP make_pair
#define PH push
#define PB push_back
#define PII pair<int,int>
#define VI vector<int>
#define X first
#define Y second
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
#define sqr(x) ((x)*(x))
#define CL(a) memset(a,0,sizeof a)
#define fr(i,n) for(int i=1;i<=n;i++)
#define FR(i,S,n) for(int i=S;i<=n;i++)
#define dr(i,n) for(int i=n;i;i--)
#define DR(i,n,S) for(int i=n;i>=S;i--)
#define SZ(x) ((int)(x).size())
#define rd(x) scanf("%d",&x)
#define pr(x) printf("%d",x)
const int N=305;
LL Pw(LL a,LL b,LL p){LL v=1;for(;b;b>>=1,a=a*a%p)if(b&1)v=v*a%p;return v;}
using namespace std;
int n,m,f[N][N][N];char s[N];bool v[N][N][N];
int dp(int l,int r,int k){
	if(k<0)return -1e9;
	if(l>r)return 0;
	if(l==r)return 1;
	if(v[l][r][k])return f[l][r][k];v[l][r][k]=1;
	int an=max(dp(l+1,r,k),dp(l,r-1,k));
	an=max(an,dp(l+1,r-1,k-(s[l]!=s[r]))+2);
	return f[l][r][k]=an;
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);rd(m);
	printf("%d\n",dp(1,n,m));
}

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

int main(){
  ll n,a,i,j,b;
  cin >> n;
  b=n;
  a=0;
  n=n/2;
  while(n!=0){
    n=n/5;
    a+=n;
  }
  if(b%2==1) a=0;
  cout <<a;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int a,b,c;
int main(){
	cin>>a>>b>>c;
	if(a==b&&b==c)puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
function Main(input){
  input = input.split("\n");//[N, L L L L L,]数字として認識していない状態
  const hairetu = input[1].split(" ").map((l) => parseInt(l, 10));;//[L,L,L,L,L,]
  let result = 0;

  for(let i = 0; i < hairetu.length; i++){
   for(let j = i+1; j < hairetu.length; j++){
    for(let k = j +1; k < hairetu.length; k++){
      if(hairetu[i] < hairetu[j] + hairetu[k] &&
        hairetu[j] < hairetu[i] + hairetu[k]&&
        hairetu[k] < hairetu[i] + hairetu[j]
        && hairetu[i] !== hairetu[j] && hairetu[j] !== hairetu[k] && hairetu[i] !== hairetu[k]){
             result++;}//要素3つが三角形の成立条件を満たしているか
      }
    }
   }
    console.log(result);
  }
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 32408
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  string s, t;
  cin >> s >> t;

  bool a = true;
  rep(i, s.size()){
    if (s.at(i) != t.at(i)) a = false;
  }

  if (a) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3632
#include <queue>
#include <map>
#include <cstdio>
#include <algorithm>
using namespace std;
map<int,vector<int> >a;
map<int,int>m;
vector<pair<int,pair<int,int> > >v;
int T;
void D(int k){
	m[k]=1;
	int t=T;
	for(int i=0;i<a[k].size();i++)if(!m[a[k][i]])++T,D(a[k][i]);
	T++;
	v.push_back(make_pair(k,make_pair(t,T)));
}
main(){
	int i,j,k,N,n=0;
	for(scanf("%d",&N);n<N;n++)for(scanf("%d%d",&i,&k);k--;a[i].push_back(j))scanf("%d",&j);
	for(T=0,i=1;i<=N;i++)if(!m[i])++T,D(i);
	sort(v.begin(),v.end());
	for(i=0;i<v.size();i++)printf("%d %d %d\n",v[i].first,v[i].second.first,v[i].second.second);
}

Measured memory_bytes: 1084
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	long double ans = 0;
	for (int i=0; i<n; ++i){
		long double a;
		cin >> a;
		ans += (1.0/a);
	}
	ans = 1.0/ans;
	cout << ans;
	return 0;
}

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

int main() {
int n;
cin >> n;
vector<vector<int>> a(n,vector<int>(2));

rep(i,n){
  cin >> a.at(i).at(0);
  a.at(i).at(1) = i+1;
}
sort(a.begin(),a.end());
rep(i,n){
if(i < n)  cout << a.at(i).at(1) <<" ";
else cout << a.at(i).at(1) << endl;
}
}


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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

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

#define pii pair<int,int>

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

int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i *= 2){
		if(i * 2 >  n){
			ANS(i);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double r;cin>>r;
    cout<<fixed<<setprecision(10)<<r*M_PI*2.00<<endl;
}


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

// 1s = 10 ^ 8 loop

int main() {
  int X;
  cin >> X;
  
  bool r = false;
  vector<int> v = {7, 5, 3};
  if (find(v.begin(), v.end(), X) != v.end()) {
    r = true;
  }

  cout << (r ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n,n){
        int y,ans=0;
        cin>>y;
        double num=0;
        for(int i=0,b,t,r;i<n;i++){
            cin>>b>>r>>t;
            double sum;
            if(t==1)sum=1.0+y*r/100.0;
            else sum=pow(1.0+r/100.0,y);
            if(num<sum)ans=b;
            num=max(sum,num);
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int a[205];
bool rec (int i, int n, int m) {
    if (m == 0) return true;
    if (i >= n) return false;
    bool res = rec (i + 1, n, m) || rec (i + 1, n, m - a[i]);
    return res;
}

int main() {
    int n;
    cin >> n;
    rep (i, 0, n) cin >> a[i];
    int q;
    cin >> q;
    rep (i, 0, q) {
        int m;
        cin >> m;
        if (rec (0, n, m)) cout << "yes\n";
        else
            cout << "no\n";
    }
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> ll size(const T &x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); ++i)
#define iter(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end();++it)
#define MOD 1000000007
#define pb push_back
#define fs first
#define sc second
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const int INF = 2147493647;
const double pi = acos(-1);
const double EPS = 1e-9;

/*vi cnt(64,0);
ll mem[64][2];
ll dp(long long at, bool contr){
    if(at == 64){
        return 0;
    }
    if(mem[at][contr] != -1) return mem[at][contr];
    ll mx = 0;
    if((cnt[at]+contr) % 2){
        mx = max(mx, (1ll<<at)+dp(at+1,false));
    }else if((cnt[at]+contr) % 2 == 0 && (cnt[at]+contr) >= 2){
        mx = max(mx, dp(at+1,false));
        mx = max(mx, dp(at+1,true));
    }
    return mem[at][contr] = mx;
}

bool isKthBitSet(unsigned long long n, long long k)
{
    if ((n >> (k - 1)) & 1)
        return true;
    else
        return false;
}

int main() {
    cin.sync_with_stdio(false);
    memset(mem,-1,sizeof(mem));
    ll n;
    cin >> n;
    rep(i,0,n){
        unsigned long long a;
        cin >> a;
        for(int x = 63; x >= 0; x--){
            if(isKthBitSet(a,x+1)) cnt[x]++;
        }
    }
    rep(i,0,64) cout << cnt[i] << ' '; cout << endl;
    cout << dp(0,0) << endl;
    return 0;
}*/



int main(){
    ll n, m;
    cin >> n >> m;
    vi A(n);

    priority_queue<ll,vector<ll>,less<ll> > pq;
    rep(i,0,n){
        cin >> A[i];
        pq.push(A[i]);
    }
    rep(i,0,m){
        ll cur = pq.top();
        pq.pop();
        pq.push(cur/2);
    }
    ll sm = 0;
    rep(i,0,n){
        sm += pq.top();
        pq.pop();
    }
    cout << sm << endl;
}



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

using namespace std;

int main()
{
    int n,x,y,i,j,k;
    cin>>n>>x>>y;
    int dis,cnt;k=1;
    int ans[n];
    memset(ans,0,sizeof(ans));
    for(i=1;i<=n;i++)
    {
        for(j=i+1;j<=n;j++)
        {
            dis=min(j-i,abs(x-i)+abs(y-j)+1);
            if(dis>=1 && dis<=n-1)
            ans[dis]++;
        }
    }
    for(i=1;i<n;i++) cout<<ans[i]<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	double r,a,b;
	cin>>r;
	a=r*r*3.141592653589;
	b=2*r*3.141592653589;
	printf("%.5lf",a);
	printf(" %.5lf\n",b);
	return 0;
}


Measured memory_bytes: 3288
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<utility>
#include<functional>
#include<cassert>
#include<cmath>
#include<math.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<vint> vvint;
#define PI 3.1415926535;
#define MOD 1000000007;

int main(void) {
	int n;
	cin >> n;
	double bo=0, shi=0;
	for (int i = 1; i <= n; i++){
		if (i % 2 == 0) {
			bo++;
		}
		else {
			bo++;
			shi++;
		}
	}
	printf("%.9f", shi / bo);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int x,y,r,tmp;

    scanf("%d%d",&x,&y);

    if (x<y) {
        tmp=x;
        x=y;
        y=tmp;
    }

    while(1){
        r=x%y;
        if (r == 0) break;
        x=y;
        y=r;
    }
    printf("%d\n",y);

    return 0;
}



Measured memory_bytes: 2136
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define ls st<<1
#define rs st<<1|1
#define pii pair<int,int>
#define rep(z, x, y) for(int z=x;z<=y;++z)
#define com bool operator<(const node &b)
using namespace std;
const int maxn = (ll) 3e5 + 5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
int T = 1;

void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int minnb = (a % d) == 0 ? a / d : a / d + 1;
    int minna = (c % b) == 0 ? c / b : c / b + 1;
    if (minna <= minnb)
        cout << "Yes";
    else
        cout << "No";
}

signed main() {
    start;
    while (T--)
        solve();
    return 0;
}

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


int main(){
    int n,m,l;
    cin >> n >> m >> l;
    vector<vector<int>>A(n,vector<int>(m));
    vector<vector<int>>B(m,vector<int>(l));
    vector<vector<long long>>C(n,vector<long long>(l));
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){           
            cin >> A[i][j];
        }
    }
    for(int i=0; i<m; i++){
        for(int j=0; j<l; j++){           
            cin >> B[i][j];
        }
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<l; j++){
            for(int k=0; k<m; k++){
                C[i][j]+=A[i][k]*B[k][j];              
            }           
            if(j==l-1){
                cout << C[i][j] << endl;
            }
            else{
                cout << C[i][j] << ' ';
            }
        }
    }    
}


Measured memory_bytes: 3264
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main (void) {
    char    s[100001];
    int     ans[100001];
    memset(s, '\0', 100001);
    memset(ans, 0, 100001*sizeof(int));
    scanf("%s", s);

    int i, n_char=strlen(s);
    int r_cnt, l_cnt, r_idx, l_idx;
    while ( i<n_char ) {
        r_cnt = 0;
        l_cnt = 0;

        /* 'R' の個数カウント */
        while ( s[i] == 'R' ) {
            r_cnt++;
            i++;
        }
        /* ここに来たら s[i-1] が 'R', s[i] が 'L' */
        r_idx = i-1;
        l_idx = i;

        /* 'L' の個数カウント */
        while ( s[i] == 'L' ) {
            l_cnt++;
            i++;
        }

        ans[r_idx] += r_cnt/2 + l_cnt/2;
        ans[l_idx] += r_cnt/2 + l_cnt/2;
        if ( r_cnt%2 != 0 )
            ans[r_idx]++;
        if ( l_cnt%2 != 0 )
            ans[l_idx]++;
    }

    for ( i=0; i<n_char; i++ )
        printf("%d ", ans[i]);
    printf("\n");
    return EXIT_SUCCESS;
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main(int argc, char *argv[])
{
	int a, b, c;
	cin >> a >> b >> c;

	if (a == b)
		cout << c;
	else if (b == c)
		cout << a;
	else
		cout << b;

	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#B問題
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

suf = 0
for i in range(N):
    a = A[i]-1
    suf+=B[a]
    if i > 0:
        if A[i] == A[i-1]+1:
            suf+=C[A[i-1]-1]
            
print(suf)

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


int main() {
    int n, minj, count=0;
    std::cin >> n;

    int A[100];
    for (int i = 0; i < n; i++) {
        std::cin >> A[i];
    }
    for (int i = 0; i < n; i++) {
        minj = i;
        for (int j = i; j < n; j++) {
            if (A[j] < A[minj]) {
                minj = j;
            }
        }
        if (i != minj) {
            std::swap(A[i], A[minj]);
            count++;
        }
    }
    for (int k = 0; k < (n-1); k++) std::cout << A[k] << " ";
    std::cout << A[n-1] << std::endl << count << std::endl;


    return 0;
}





Measured memory_bytes: 3120
#include <stdio.h>

int main()
{
    char s[3];
    int cnt = 0;
    int max = 0;

    scanf("%s", s);

    for(int i=0;i<3;i++){
        if(s[i]=='R'){
            cnt++;
        }else{
            if(cnt>max){
                max=cnt;
            }
            cnt = 0;
        }
    }


    if(max>=cnt){
        printf("%d\n", max);
    }else{
        printf("%d\n", cnt);
    }

    return 0;
}

Measured memory_bytes: 2156
#include<bits/stdc++.h>
#include <tr1/unordered_map>

using namespace std::tr1;
using namespace std;

typedef long long ll;

bool isprime[1000000+100];
int n = 1000000;
void sieve(int x)
{
    memset(isprime,true,sizeof(isprime));

    isprime[0]=isprime[1]=false;
    for(int i=2; (long long)i*i<=(long long)x; i++)
    {
        if(isprime[i])
        {
            for(ll j=i*i; j<=x; j+=i)
            {
                isprime[j]=false;
            }
        }
    }

}

long long bigmod(long long a,long long b,long long m)
{
    ll res = 1%m;

    while(b>0)
    {
        if(b&1)
        {
            res = (res * a) %m;
        }

        a = (a * a)%m;
        b>>=1;

    }
    return res;



}

int main(void)
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t;
    cin>>t;
   if(t%1000==0)
   {
       cout<<0<<endl;
   }
   else
   {
       cout<<((t/1000)*1000 + 1000)-t<<endl;
   }
}








Measured memory_bytes: 3636
X,Y,A,B,C=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort()
p.reverse()
q.sort()
q.reverse()
while len(p)>X:
  p.pop()
while len(q)>Y:
  q.pop()
s=p+q+r
s.sort()
s.reverse()
c=0
for i in range(X+Y):
  c+=s[i]
print(c)

Measured memory_bytes: 23328
#include"bits/stdc++.h"
using namespace std;
 
int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
	string s;
    cin >> s;
    if(s.length() > n){
        for(int i = 0; i< n; i++)
            cout << s[i];
        cout <<"...";
    }else
    {
        cout << s;
    }
    
    return 0;
}


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

int main() {
  int N;
  cin>>N;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int countA=0, countB=0;
  
  for(int i=0;i<N;i+=2){
    countA+=vec.at(i);
  }
  for(int i=1;i<N;i+=2){
    countB+=vec.at(i);
  }
  cout<<countA-countB<<endl;
  
    
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.HashSet;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String  N=sc.next();
    String []hairetu = N.split("");
    int sum=0;
    for (int i=0;i<hairetu.length ;i++ ) {
      if(hairetu[i].equals(".")){
        i++;
      }
      if(hairetu[i].equals("E")){
       break;
      }
      sum=sum+Integer.parseInt(hairetu[i]);
    }
    if(sum%9==0){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
}
}


Measured memory_bytes: 64916
n, a, b = map(int, input().split())

if a > b:
  print(0)
elif n == 1 and a != b:
  print(0)
elif n == 1 and a == b:
  print(1)
else:
  print((b*(n-1)+a) - (a*(n-1)+b) + 1)


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


int main()
{
    int n, k ; cin >> n >> k ;
    int h[n] ;
    for(int i = 0; i < n; i++)
         cin >> h[i] ;
    int dp[n] ;
    for(int i = 0; i < n; i++) dp[i] = 2e9;
    dp[0] = 0 ;
    for(int i = 1; i < n; i++)
    {
        if(i > 1)
        {
            for(int j = max(i-k, 0); j < i; j++)
                dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
        else if(i > 0)
            dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
    }
    cout << dp[n-1] ;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    s = [1 if c == "#" else 0 for c in input().strip()] + [1]
    sum_ = sum(s)

    ans = N + 1 - sum_ # 全て黒にするのに必要な数
    for i in range(1, N+1):
        s[i] += s[i-1]
        ans = min(ans, s[i-1]+N+1-i-sum_+s[i-1])
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 11272
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef unsigned long long ll;



int main(){
  int N;
  cin >> N;
  string s;
  if(N== 0){
    cout << 0 << endl;
    return 0;
  }
  
  while(N){
    if((abs(N)%2)){
      s= '1'+s;
      --N;
    }
    else{
      s='0'+s;
    }
    N/=-2;
  }
  cout << s << endl;
  return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (f, s) = readLine()!!.split(" ").map(String::toInt)
    val r = "[0-9]{$f}-[0-9]{$s}".toRegex()
    val a = if(r.matches(readLine()!!)) "Yes" else "No"
    println(a)
}

Measured memory_bytes: 37744
def factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def factorize2(n):
    plist = factorize(n)
    dic = {}
    for n in plist:
        if not n in dic:
            dic[n] = 1
        else:
            dic[n] += 1
    ret = []
    for p,n in dic.items():
        ret.append([p,n])
    return ret

def phi(n):
    plist = factorize2(n)
    ans = 1
    for [p,n] in plist:
        ans *= (pow(p,n)-pow(p,n-1))
    return ans

Q = int(input())
print(phi(Q))



Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;

typedef pair <int, int> pii;
typedef pair <pii, int> piii;

const int INF = 0x3f3f3f3f;

int n;
int a[200010];
int f1[200010][20], f2[200010][20];
int pos[200010];
pii val[200010];
int tot = 0;
priority_queue <piii, vector <piii>, greater <piii> > q;
vector <int> from[200010];

void get_f(){
	for (int i = 0; i < n; i++){
		if (i & 1) f1[i][0] = a[i], f2[i][0] = INF;
		else f2[i][0] = a[i], f1[i][0] = INF;
	}
	for (int j = 1; j < 20; j++){
		for (int i = 0; i < n; i++){
			if (i + (1 << j) - 1 > n) continue;
			f1[i][j] = min(f1[i][j - 1], f1[i + (1 << j - 1)][j - 1]);
			f2[i][j] = min(f2[i][j - 1], f2[i + (1 << j - 1)][j - 1]);
		}
	}
}

int get_min1(int l, int r){
	int k = log(r - l + 1) / log(2);
	return min(f1[l][k], f1[r - (1 << k) + 1][k]);
}

int get_min2(int l, int r){
	int k = log(r - l + 1) / log(2); 
	return min(f2[l][k], f2[r - (1 << k) + 1][k]);
}

int dfs(int l, int r){
	if (l > r) return -1;
	int x, y, m1, m2;
	if (l & 1){
		x = get_min1(l, r), m1 = pos[x];
		y = get_min2(m1, r), m2 = pos[y];
	} else {
		x = get_min2(l, r), m1 = pos[x];
		y = get_min1(m1, r), m2 = pos[y];
	}
	int now = tot++;
	val[now] = mp(x, y);
	from[now].push_back(dfs(l, m1 - 1));
	from[now].push_back(dfs(m1 + 1, m2 - 1));
	from[now].push_back(dfs(m2 + 1, r));
	return now;
}

int main(){
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		pos[a[i]] = i;
	}
	get_f();
	int s = dfs(0, n - 1);
	q.push(mp(val[s], s));
	while (!q.empty()){
		piii t = q.top(); q.pop();
		printf("%d %d ", t.fi.fi, t.fi.se);
		int x = t.se;
		for (int i = 0; i < from[x].size(); i++){
			int v = from[x][i];
			if (v == -1) continue;
			q.push(mp(val[v], v));
		}
	}
	printf("\n");
	return 0;
}


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

int main(){
    int n, m;
    while(1){
        cin >> n >> m;
        if(n == 0)
            break;

        vector<int> taro(n), hana(m);
        int diff = 0;
        for(int i=0; i<n; i++){
            cin >> taro[i];
            diff += taro[i];
        }
        for(int i=0; i<m; i++){
            cin >> hana[i];
            diff -= hana[i];
        }

        int an = -1, am = -1, temp = 1e9;
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                if(2 * (taro[i] - hana[j]) == diff){
                    if(taro[i] + hana[j] < temp){
                        an = i;
                        am = j;
                        temp = taro[i] + hana[j];
                    }
                }
            }
        }

        if(an == -1){
            cout << -1 << endl;
        }else{
            cout << taro[an] << ' ' << hana[am] << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3084
#include<stdio.h>
#include<stdlib.h>
 
typedef struct{
  int parent;
  int left;
  int right;
} Tree;
  
Tree T[1000000];
  
int sibilings(int);
int degree(int);
int depth_c(int);
int hight(int);
void print(int);
 int sibilings(int n){
  if(T[n].parent == -1){
    return -1;
  }
  else if(T[T[n].parent].left == n){
    return T[T[n].parent].right;
  }
  else return T[T[n].parent].left;
}
  
int degree(int m){
  if(T[m].left ==-1 && T[m].right == -1){
    return 0;
  }
  else if(T[m].left !=-1 && T[m].right != -1){
    return 2;
  }
  else
    return 1;
}
  
int depth_c(int l){
  int count = 0;
  if(T[l].parent == -1){
    return 0;
  }
  else{
    count = depth_c(T[l].parent) + 1;
    return count;
  }
}
  
int hight(int i){
  int ah = 0, bh = 0;
  if(T[i].left != -1){
    ah = hight(T[i].left) + 1;
  }
   if(T[i].right != -1){
    bh = hight(T[i].right) + 1;
  }
   if(ah < bh){
     return bh;
   }
   else
     return ah;
}
  
void print(int j){
  printf("node %d: parent = %d, sibling = %d, degree = %d, ",j, T[j].parent, sibilings(j),degree(j));
  printf("depth = %d, height = %d, ",depth_c(j),hight(j));
  if(T[j].parent == -1){
    printf("root\n");
  }
  else if(T[j].left == -1 && T[j].right == -1){
    printf("leaf\n");
  }
  else
    printf("internal node\n");
}
 
main(){
  int i, j, p, l, r, n;
  scanf("%d", &n);
  for(i=0; i<n; i++){
    T[i].parent = -1;
    T[i].left = -1;
    T[i].right = -1;
  }
  for(i=0; i<n; i++){
    scanf("%d%d%d",&p,&l,&r);
    T[l].parent = p;
    T[r].parent = p;
    T[p].left = l;
    T[p].right = r;
   }
  for(i=0; i<n; i++){
    print(i);
   }
  return 0;
}

Measured memory_bytes: 612
import math
from itertools import product
L, R = map(int, input().split())
if R-L >= 2018:
    print(0)
else:
    ans = 2018
    for i, j in product(range(L, R), range(L+1, R+1)):
        ans = min(ans, i * j % 2019)
    print(ans)



Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<set>
//#include<boost/math/common_factor_rt.hpp>
#include <numeric>
using namespace std;

#define ll long long
#define INF 1000000007;

ll a[100050] = {};

int main() {
	ll n;
	ll cnt = 0;
	cin >> n;

	for (ll i = 0; i < n; i++)
	{
		ll x;
		cin >> x;
		if (x < 0) {
			cnt++;
			x *= -1;
		}
		a[i] = x;

	}

	if (cnt % 2 == 0) {
		ll ans = 0;
		for (ll i = 0; i < n; i++)
		{
			ans += a[i];
		}

		cout << ans;
	}
	else {
		sort(a, a + n);

		ll ans = 0;
		for (ll i = 1; i < n; i++)
		{
			ans += a[i];
		}

		cout << ans - a[0];
	}
}




Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


a,b,c,d = MI()
print(max(a*c,a*d,b*c,b*d))


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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int x, n;
    cin >> x >> n;

    vs32 p(n);
    rep (i, n) cin >> p[i];

    int ans = 0;
    for (int i = 0; i <= 101; ++i)
    {
        bool found = false;
        rep (j, n)
        {
            if (p[j] == i)
            {
                found = true;
                break;
            }
        }
        if (!found)
        {
            if (abs(x - i) < abs(x - ans))
            {
                ans = i;
            }
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3648
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<time.h>
#include<cstring>
#include<iomanip>
#include<numeric>
#define ll long long
#define h 0.000000001
#define pf push_front
#define pb push_back
#define ub upper_bound
#define lb lower_bound
using namespace std;
int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll int ans, cnt, flag, i;
  string x;
  cin>>x;
  flag=0;
  cnt=0;
  ans=0;
  for(i=0;i<x.size();i++) 
  {
  	if(x[i]=='R') 
  	{
  		if(flag==0)flag=1;
  		cnt+=1;
  	} 
  	else
  	{
  		if(flag)
  		{
  			ans=max(ans,cnt);
  			cnt=0;
  			flag=0;
  		} 
  	} 
  } 
  if(flag) ans=max(ans,cnt);
  cout<<ans<<endl;
  return 0;
} 


Measured memory_bytes: 3648
// ABC080-D
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

int N, C;
ll chan[32][100010];

int main() {
   cin >> N >> C;
   ll maxTime = 0;
   rep (i, N) {
      ll s, t, c;
      cin >> s >> t >> c;
      chan[c][s]++, chan[c][t+1]--;
      maxTime = max(maxTime, t);
   }

   for (int i = 1; i <= C; i++) {
      for (int j = 1; j < 100009; j++) {
         chan[i][j] += chan[i][j-1];
      }
      for (int j = 1; j < 100009; j++) {
         if (chan[i][j] >= 2) chan[i][j] = 1;
      }
   }

   for (int i = 1; i < 100009; i++) {
      for (int j = 1; j <= C; j++) {
         chan[j][i] += chan[j-1][i];
      }
   }

   ll ans = 0;
   for (int i = 1; i < 100009; i++) {
      ans = max(ans, chan[C][i]);
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 24064
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll a = 1;
  	ll b = 2;
    if(n != 1){
    	for(int i = 2 ; i <= n ; i++){
    		ll tmp = a;
    		a = a + b;
    	  	b = tmp;
    	}
    	cout << a;
  	}
  	else cout << 1;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------

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

    ll n;
    cin >> n;
    vll a(n);
    REP(i,n) cin >> a[i];

    ll ans = 1000;
    ll k = 0;


    for(ll i=0;i<n;i++){
        if(i<=n-2 && a[i]<a[i+1]){
            ll l = ans /a[i];
            k += l;
            ans -= l * a[i];
        }
        else if(i>0 && a[i-1]<a[i]){
            ans += k * a[i];
            k = 0;
        }
        //cout << k <<" " <<ans <<endl;
    }

    cout << ans <<endl;

    
    return 0;
}



Measured memory_bytes: 3600
import sys

sys.setrecursionlimit(100000)
n = int(input())


def dfs(s, max_c):
    if len(s) == n:
        print(s)
        return
    for i in range(ord("a"), max_c+2):
        t = s
        c = chr(i)
        t += c
        dfs(t, max(max_c, i))

dfs("", ord("a")-1)






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

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

  int ans = 0;
  int l = 0, r = s.size() - 1;
  while (l < r) {
    if (s[l] == s[r]) {
      l++, r--;
      continue;
    }

    if (s[l] == 'x') {
      l++;
      ans++;
      continue;
    }

    if (s[r] == 'x') {
      r--;
      ans++;
      continue;
    }

    cout << -1 << endl;
    return 0;
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());

  int ans=0;
  for (int i = 0; i < n; i++)
  {
    if(i%2==0) ans+=a[i];
    else ans-=a[i];
  }

  cout << ans << endl;
   
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>

using namespace std;

void ABC135C()
{
	string str;
	cin >> str;
	int n = stoi(str);
	vector<long long> A(n+1), B(n);
	for (auto& x : A)
	{
		cin >> str;
		x = stoll(str);
	}
	for (auto& x : B)
	{
		cin >> str;
		x = stoll(str);
	}

	long long ct = 0;
	for (int i = 0; i < n; ++i)
	{
		long long x = min(A[i], B[i]);
		ct += x;
		B[i] -= x;
		long long y = min(A[i + 1], B[i]);
		ct += y;
		A[i + 1] -= y;
	}
	cout << ct << endl;
}

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

Measured memory_bytes: 1792
n,t=map(int,input().split())
t_=list(map(int,input().split()))
time=t
for i in range(n-1):
    
    d_time=t_[i+1]-t_[i]
    
    if d_time<t:
        time+=d_time
    else:
        time+=t
print(time)

Measured memory_bytes: 25196
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a; i<b; i++)
#define dep(i,a,b) for(int i=a; i>=b; i--)
#define sq(a) (a)*(a)
#define ms(a,v)	memset(a,v,sizeof a)
#define ALL(x)	(x).begin(), (x).end()
using namespace std;
const long long INF = 1e18 , MAXN =1e5, MOD = 1e9 + 7;
typedef long long ll;
/*
void prime(){
	for(int i=2;i<=(int)sqrt(N);i++)
		if (!seive[i])
			for(int j=i<<1;j<N;j+=i)
				seive[j]=true;
}
*/ 
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
   int n, m;
  cin >> n >> m;

  int ans = 0;
  map<int, int> nos;

  while(m--){
    int s, c;
    cin >> s >> c;
    if((nos.find(s) != nos.end() && nos[s] != c) || (s == 1 && c == 0 && n>1)){
        cout << -1 << endl;
        return 0;
    }
    nos[s] = c;
  }

  rep(i, 1, n + 1){
    if(i == 1){
        if(nos.find(i) == nos.end()){
            if(n == 1)
                ans = 0;
            else
                ans = 1;
        }
        else
            ans = nos[1];
    }
    else{
        if(nos.find(i) == nos.end())
            ans = ans * 10 + 0;
        else
            ans = ans * 10 + nos[i];
    }
  }

  cout << ans << endl;
return 0;
}

 


Measured memory_bytes: 256