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

//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long double db;

#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

template<typename T> void print(const T& a, ostream& out){	
	for(auto i: a) out << i << ' ';
	out << endl;
}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	string s; cin >> s;
	int ans = 0, cur = 0;
	for(auto i: s){
		if (i == 'R') cur++;
		else{
			setmax(ans, cur);
			cur = 0;
		}
	}
	cout << max(ans, cur) << endl;
	
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);

    int n,k;cin >> n >> k;
    vi x(n);
    rep(i,n) cin >> x[i];

    int ans = 0;
    rep(i,n){
        ans += min(x[i]-0,k-x[i]);
    }
    ans *= 2;
    cout << ans << endl;
    return 0;
}

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

int	main()
{
	string	cards;
	int	m;
	while (cin >> cards) {
		if (cards == "-") break;
		cin >> m;
		int	num_cards = cards.size();
		int	idx = 0;
		int	h;
		for (int i = 0; i < m; ++i) {
			cin >> h;
			idx = (idx + h) % num_cards;
		}
		cout << cards.substr(idx, num_cards - idx);
   		cout << cards.substr(0, idx) << endl;
	}
}



Measured memory_bytes: 3216
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#define ll long long
using namespace std;
int main(){
	ll N,M;
	cin >> N >> M;
	ll ans=0;
	if(N<M/2){
		ans = ans + N;
		M = M-(N*2);
		ans = ans + M/4;
	}else{
		ans = M/2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <utility>
#include <string>

#define loop(n) for(ll i=0;i<n;i++)

using namespace std;

typedef long long int ll;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int r = 0;
    for(int i = 0;i < n;i++) {
        int cnt = 0;
        for(char c = 'a';c <= 'z';c++) {
            bool r = false;
            bool l = false;
            for(int j = 0;j < i;j++) if(s[j] == c) r = true;
            for(int j = i;j < n;j++) if(s[j] == c) l = true;
            if(r && l) cnt++;
        }
        r = max(r,cnt);
    }
    cout << r << endl;
}

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD =   1000000007;

using Graph = vector<vector<int>>;

int N, M;
Graph G;
int s, t;

ll bfs() {
    vector<vector<ll>> dist(N, vector<ll>(3, -1));
    dist[s][0] = 0;
    queue<P> que;
    que.push({s, 0});
    while (!que.empty()) {
        P cur = que.front(); que.pop();
        int v = cur.first;
        int parity = cur.second;
        for (auto nv : G[v]) {
            int np = (parity + 1) % 3;
            if (dist[nv][np] == -1) {
                dist[nv][np] = dist[v][parity] + 1;
                que.push({nv, np});
            }
        }
    }
    if (dist[t][0] == -1){
        return -1;
    }
    else{
        return dist[t][0] / 3;
    }
}

int main()
{
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    cin >> N >> M;

    G.assign(N, vector<int>());
    for (int i = 0; i < M; ++i) {
        int u, v; cin >> u >> v;
        --u, --v;
        G[u].push_back(v);
    }

    cin >> s >> t;
    --s, --t;
    cout << bfs() << endl;
    return 0;
}


Measured memory_bytes: 11136
n = int(input())
b = list(map(int, input().split()))
a = []
judge = 0

while len(a) < n and judge != 1:
    c = 0
    for i in range(len(b)):
        if b[i] == i+1:
            c = b[i]
    if c == 0:
        judge = 1
        break
    else:
        a.append(c)
        b.remove(c)

a = a[::-1]
if judge == 1:
    print(-1)
else:
    for i in range(n):
        print(a[i])

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

int main(void) {
    int A,B,C,K;cin>>A>>B>>C>>K;
    if (A > B) swap(A, B);
    if (A > C) swap(A, C);
    if (B > C) swap(B, C);
    cout << A + B + C * pow(2, K) << endl;
    return 0;
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  string s,t;
  cin >> s >> t;
  int ans = 0;
  rep(i,sz(s)) {
    if(s[i] != t[i]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3916
s = gets.chomp.split("")


def switch_tile(n)
    n == 0 ? 1 : 0
end

def diff_cnt(left_array, right_array)
    raise RuntimeError.new("size not match #{left_array}:#{right_array}") unless left_array.size == right_array.size
    res = 0
    left_array.size.times do |i|
        res += 1 if left_array[i] != right_array[i]
    end
    return res
end

def generate_tiles(l, first_zero = true)
    current = 1
    current = 0 if first_zero
    res = ""
    l.times do 
        res += current.to_s
        current = switch_tile(current)
    end
    return res
end

cand_a = generate_tiles(s.size, false).split("")
cand_b = generate_tiles(s.size, true).split("")

diff_a = diff_cnt(cand_a, s)
diff_b = diff_cnt(cand_b, s)

puts [diff_a, diff_b].min


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

int main(){
    int n;
    cin >> n;
    int b[n-1];
    for(int i=0; i<n-1; i++){
        cin >> b[i];

    }
    int a[n];
    for(int i=1; i<n-1; i++){
        a[i]=min(b[i],b[i-1]);
    }
    a[0]=b[0];
    a[n-1]=b[n-2];
    int sum=0;
    for(int i=0; i<n; i++){
        //cout << a[i] << endl;
        sum+=a[i];
    }
    cout << sum << endl;
}

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

int main(){
  int n;
  cin >> n;
  int l, i=0, a[n];
    while(cin>>l){
        a[i] = l;
        i++;
    }
  int ans=1;
  int max=a[0];
  for (int k = 1; k < n; ++k) {
  	if(a[k] >= max){
  		ans = ans +1;
      	max = a[k];
    }
  }
  
      cout << ans << endl;
  
}

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

using std::cin;
using std::cout;
using std::endl;

using ll = long long;

int main() {
  int a[10001], b[10001], N;

  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < N; ++i) {
    cin >> b[i];
  }

  ll cnt_a = 0, cnt_b = 0;

  for (int i = 0; i < N; ++i) {
    if (a[i] > b[i]) {
      cnt_b += (a[i] - b[i]);
    }
    else if (a[i] < b[i]) {
      cnt_a += (b[i] - a[i]) / 2;
      if ((b[i] ^ a[i]) & 1) {
        cnt_a++;
        cnt_b++;
      }
    }
  }


  if (cnt_a >= cnt_b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int N,i,mini,c=1;
    cin>>N;
    long long int a[N];
    for(i=0;i<N;i++)
    {
        cin>>a[i];
    }
    mini=a[0];
    for(i=1;i<N;i++)
    {
        if(mini>a[i])
        {
            c++;
            mini=a[i];
        }
    }
    cout<<c<<endl;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  int count = 0;
  int m, s, j,i;
  int num;

  for (int x = a; x <= b; x++) {
    num = x;
    i = num % 10;
    num /= 10;
    j = num % 10;
    num /= 100;
    s = num % 10;
    num /= 10;
    m = num % 10;

    if (m == i) {
      if (s == j) {
        count++;
      }
    }
  }
  cout << count << endl;
}


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

typedef long long LL;
const int N = 1e5;

int n;
int li[N+5];

inline LL itung(LL x){
	return ((1LL+x)*x)/2;
}

int main(){
	scanf("%d",&n);
	LL tot = 0LL;
	int idm = 1e9+7;
	int idM = -1;
	for(int i=1;i<=n;i++){
		scanf("%lld",&li[i]);
		tot+=li[i];
		idm = min(idm,li[i]);
		idM = max(idM,li[i]);
	}
	LL bisa = itung(n);
	if(tot%bisa != 0){
		printf("NO\n");
		return 0;
	}
	int l = -1;
	int r = -1;
	int tmp = n;
	for(int i=1;i<=n;i++){
		if(idm == li[i]){
			l = i;
		}
		if(idM == li[i]){
			r = i;
			if(l!=-1)tmp = min(tmp,r-l+1);
		}
	}
	for(int i=1;i<=n;i++){
		if(idM == li[i]){
			if(l!=-1) tmp = min(tmp,n-(r-l-1));
		}
	}
	sort(li+1,li+n+1);
	if(li[1]*(LL)(tmp) < li[n]){
		printf("NO\n");
	} else {
		printf("YES\n");
	}
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int n;
int roll[6][6][2]=
{
{{0,0},{2,3},{1,2},{3,0},{0,1},{0,0}},
{{2,1},{0,0},{3,2},{1,0},{0,0},{0,3}},
{{2,3},{1,2},{0,0},{0,0},{3,0},{0,1}},
{{2,1},{3,2},{0,0},{0,0},{1,0},{0,3}},
{{2,3},{0,0},{1,2},{3,0},{0,0},{0,1}},
{{0,0},{2,1},{3,2},{1,0},{0,3},{0,0}}
};
int dy[4]={1,0,-1,0},dx[4]={0,1,0,-1};

int height[64][64],val[64][64];

void fall(int top,int front,int y,int x){
	int fst=roll[top-1][front-1][0];
	int snd=roll[top-1][front-1][1];
	int turn=-1;
	if(height[y][x]>height[y+dy[snd]][x+dx[snd]]) turn=snd;
	if(height[y][x]>height[y+dy[fst]][x+dx[fst]]) turn=fst;
	if(turn==-1){
		++height[y][x];
		val[y][x]=top;
		return;
	}
	int nexttop,nextfront;
	if(turn==0){
		nexttop=7-front;
		nextfront=top;
	}
	if(turn==1){
		nexttop=3;
		if(top!=1&&top!=6&&front!=1&&front!=6) nexttop=1;
		if(top!=2&&top!=5&&front!=2&&front!=5) nexttop=2;
		nextfront=front;
	}
	if(turn==2){
		nexttop=front;
		nextfront=7-top;
	}
	if(turn==3){
		nexttop=3;
		if(top!=1&&top!=6&&front!=1&&front!=6) nexttop=1;
		if(top!=2&&top!=5&&front!=2&&front!=5) nexttop=2;
		nextfront=front;
	}
	return fall(nexttop,nextfront,y+dy[turn],x+dx[turn]);
}
int main() {
	for(;;){
		cin >> n;
		if(!n) break;
		for(int i=0;i<64;++i)
			for(int j=0;j<64;++j){
				height[i][j]=0;
				val[i][j]=0;
			}
		for(int i=0;i<n;++i){
			int top,front;
			cin >> top >> front;
			fall(top,front,32,32);
		}
		int count[8]={};
		for(int i=0;i<64;++i)
			for(int j=0;j<64;++j){
				++count[val[i][j]];
			}
		for(int i=0;i<6;++i){
			if(i) cout << ' ';
			cout << count[i+1];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
using namespace __gnu_pbds;
using namespace std;

#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define int               long long
#define INF               1e18
#define ff                first
#define ss                second
#define vi                vector<int>
#define pii               pair<int,int>
#define mii               map<int,int>
#define endl              "\n"
#define GCD(x,y)          (__gcd((x), (y)))
#define LCM(x,y)          (((x)/__gcd((x), (y)))*(y))
#define debug(x)          cout<<#x<<" is "<<(x)<<endl
#define mem(a,x)          memset(a,x,sizeof(a))
#define rep(i,a,b)        for(long long i=a;i<b;i++)
#define sp(ans,p)         fixed <<setprecision(p)<<ans;
#define IOS ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);

typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

constexpr int N = 5e5 + 5;
constexpr int BLOCK = 710;

struct query
{
    int l;
    int r;
    int i;
};

query Q[N];
int ar[N] , ans[N];
int fre[N];
int cntdist = 0;
mii m;

//enhanced comparator
bool comp(query a, query b)
{
    if (a.l / BLOCK != b.l / BLOCK)
    {
        return a.l < b.l;
    }
    if ((a.l / BLOCK) & 1)
    {
        return a.r < b.r;
    }
    return a.r > b.r;
}

void add(int pos)
{
    if (fre[ar[pos]] == 0)
    {
        cntdist++;
    }
    fre[ar[pos]]++;
}

void remove(int pos)
{
    if (fre[ar[pos]] == 1)
    {
        cntdist--;
    }
    fre[ar[pos]]--;
}


void solve()
{
    int n , q;
    cin >> n >> q;
    for (int i = 0; i < n; i++)
        cin >> ar[i];


    for (int i = 0; i < q; i++) {
        cin >> Q[i].l >> Q[i].r;
        Q[i].i = i , Q[i].l-- , Q[i].r--;
    }

    sort(Q , Q + q , comp);

    //why ML = 0 , and MR = -1?
    int ML = 0 , MR = -1;
    for (int i = 0; i < q; i++)
    {
        int L = Q[i].l;
        int R = Q[i].r;

        while (ML > L)
            ML-- , add(ML);

        while (MR < R)
            MR++ , add(MR);

        while (ML < L)
            remove(ML) , ML++;

        while (MR > R)
            remove(MR) , MR--;

        ans[Q[i].i] = cntdist;
    }

    for (int i = 0; i < q; i++)
        cout << ans[i] << '\n';
    return;
}


signed main()
{
    IOS;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    // sieve();
    int t = 1;
    // cin >> t;
    while (t--)   solve();
    return 0;
}

Measured memory_bytes: 27156
/*
	@・ω・@ <だれだろうね
*/

/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<long long>;
using pll = pair<long long, long long>;
template<class T> using pr = pair<T, T>;
template<class T> using vec = vector<T>;

#define debug(x) (std::cerr << x << "\n")
#define debug_tab(n, x) (std::cerr << strMulti("\t",n) << (x) << "\n")
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define str(n)	(n.toString())

#define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(ll i=(n)-1; i >= 0; --i)
#define rrep1(i, n) for(ll i=(n); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b)
constexpr int INF = 2000000100;
constexpr ll MOD = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = math_P(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool cmp_2nd(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T mod_pow(T x, T n, const T& p) { T ret = 1; while (n > 0) { if (n & 1) { (ret *= x) %= p; } (x *= x) %= p; n >>= 1; } return ret; }

/*****/

using graph = vec<vecll>;

ll N, X, Y;

void Main()
{
	cin >> N >> X >> Y;
	X--;
	Y--;

	graph G(N, vecll(N));

	rep(x, N)
	{
		rep(y, N)
		{
			G[x][y] = min(min(abs(x - y), abs(X - x) + abs(Y - y) + 1), abs(Y - x) + abs(X - y) + 1);
		}
	}

	vecll cnt(N);
	rep(x, N)
	{
		for (ll y = x + 1; y < N; ++y)
		{
			cnt[G[x][y]]++;
		}
	}

	rep1(i, N - 1)
	{
		cout << cnt[i] << "\n";
	}
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);

	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/

	Main();
	cout << /** endl /*/ flush /**/;

	return 0;
}


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

string str;
ll ans = 0;

void solve(ll sum, int l, int r){
    if(r == str.size()-1){
        ans += sum + stoll(str.substr(l, r-l+1));
        return;
    }
    solve(sum, l, r+1);
    solve(sum + stoll(str.substr(l, r-l+1)), r+1, r+1);
    return;
}

int main(){
    cin >> str;
    solve(0, 0, 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
P=[int(i) for i in input().split()]

uf=[i for i in range(n+1)]
def ufuf(x):
    while x!=uf[x]:
        x=uf[x]
    return x

for i in range(m):
    x,y=map(int,input().split())
    if ufuf(x)<ufuf(y):
        uf[ufuf(y)]=ufuf(x)
    else:
        uf[ufuf(x)]=ufuf(y)

ans=0
for i in range(1,n+1):
    if ufuf(i)==ufuf(P[i-1]):
        ans+=1
print(ans)

Measured memory_bytes: 20468
#include<bits/stdc++.h>
using namespace std;
long mod = 1e9+7;
int main(){
  long n;
  cin >> n;
  vector<long> a(n),t(n);
  for(long i = 0; i < n; i++) cin >> t[i];
  for(long i = 0; i < n; i++) cin >> a[i];
  if(a[0] != t[n-1]){
    cout << 0 << endl;
  }else{
    long ans = 1;
    for(long i = 1; i < n-1; i++){
      if(t[i] == t[i-1] && a[i] == a[i+1]){
        ans*=min(t[i],a[i]);
        ans%=mod;
      }else if(t[i] > t[i-1] && a[i] == a[i+1] && a[i] < t[i]){  //h[i] == t[i]
        ans = 0;
        break;
      }else if(t[i] == t[i-1] && a[i] > a[i+1] && a[i] > t[i]){  //h[i] == a[i]
        ans = 0;
        break;
      }else if(t[i] > t[i-1] && a[i] > a[i+1] && a[i] != t[i]){   //h[i] == t[i] == a[i]
        ans = 0;
        break;
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
x,n = map(int,input().split())
if n != 0:
    p = list(map(int,input().split()))

if n==0 or x not in p:
    print(x)
else:
    i = 1
    while True:
        if (x-i) not in p:
            print(x-i)
            break
        if (x+i) not in p:
            print(x+i)
            break
        i += 1

Measured memory_bytes: 9192
import java.util.*

fun main(args: Array<String>) {
    val (N, D, A) = readLine()!!.split(" ").map(String::toInt)
    val XH = (1..N).map { readLine()!!.split(" ")}.map { e -> MutablePair(e[0].toInt(), e[1].toLong()) }.sortedBy { it.x }
    var ans = 0L
    var totalDamage = 0L
    val que = ArrayDeque<Pair<Int, Long>>()
    for (enemy in XH) {
        while (que.isNotEmpty() && que.last.first <= enemy.x) {
            totalDamage -= que.removeLast().second
        }
        enemy.h -= totalDamage
        if (enemy.h > 0) {
            val num = (enemy.h + A - 1) / A
            val damage = A * num
            que.addFirst(Pair(enemy.x + D * 2 + 1, damage))
            totalDamage += damage
            ans += num
        }
    }
    println(ans)
}

class MutablePair(val x: Int, var h: Long)

Measured memory_bytes: 164064
N, M = gets.split.map(&:to_i)
P = Array.new(M)
Y = Array.new(M)

p_hash = Hash.new{|hash, key| hash[key] = []}
M.times do |i|
  P[i], Y[i] = gets.split.map(&:to_i)
  p_hash[P[i]] << [Y[i], i]
end

answers = Array.new(M)
p_hash.each do |key, ary|
  ary.sort!
  leftStr = key.to_s.rjust(6, "0")
  ary.size.times do |i|
    rightStr = (i+1).to_s.rjust(6, "0")
    answers[ary[i][1]] = leftStr + rightStr
  end
end

answers.each do |ans|
  puts ans
end


Measured memory_bytes: 34428
N,M=gets.split.map(&:to_i)
abs = []
N.times do
    abs<<gets.split.map(&:to_i)
end

cds = []
M.times do
    cds<<gets.split.map(&:to_i)
end

abs.each do |a,b|
    min = 10**9
    idx = 1
    cds.each.with_index(1) do |cd,i|
        c,d=cd
        x = (a-c).abs + (b-d).abs
        if x < min
            min = x
            idx = i
        end
    end
    puts idx
end



Measured memory_bytes: 1788
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
int n;
vector<int> h;
void solve() {
    cin >> n;
    h.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    int ans = 1;
    for (int i = 1; i < n; ++i) {
        bool flg = true;
        for (int j = i - 1; j > -1; --j) {
            if (h[j] > h[i]) {
                flg = false;
            }
        }
        if (flg == true) {
            ans++;
        }
    }
    cout << ans << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}

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

using namespace std;

const int N_CONTEST = 26;

struct Contest {
    int day;
    vector<int> complain;
    vector<vector<int>> satisfy;

    Contest() {
        cin >> day;

        complain.resize(N_CONTEST+1);
        for ( int c = 1; c <= N_CONTEST; c++ )
            cin >> complain.at(c);

        satisfy.resize(day+1);
        for ( int d = 1; d <= day; d++ ) {
            satisfy.at(d).resize(N_CONTEST+1);
            for ( int c = 1; c <= N_CONTEST; c++ )
                cin >> satisfy.at(d).at(c);
        }
    }

    void dump() {
        printf("----- Dump contents of struct Contest -----\n"
               "%d\n", day);
        for ( int c = 1; c <= N_CONTEST; c++ )
            printf("%d ", complain.at(c));
        printf("\n");
        for ( int d = 1; d <= day; d++ ) {
            for ( int c = 1; c <= N_CONTEST; c++ )
                printf("%d ", satisfy.at(d).at(c));
            printf("\n");
        }
        printf("----- Dump done -----\n");
    }
};

static long long calc_score (Contest contests, int day, vector<int> &last, int contest) {
    long long score = contests.satisfy.at(day).at(contest);
    int tmp = last.at(contest);

    last.at(contest) = day;
    for ( int c = 1; c <= N_CONTEST; c++ ) {
        if ( c == contest ) {
            continue;
        }
        score -= (long long)contests.complain.at(c) * (day - last.at(c));
    }

    /* 13 日後までコンテストを開催しない場合のスコアで比較する */
    for ( int d = day+1; d <= min(day+13, contests.day); d++ ) {
        for ( int c = 1; c <= N_CONTEST; c++ ) {
            score -= (long long)contests.complain.at(c) * (d - last.at(c));
        }
    }

    last.at(contest) = tmp;
    return score;
}

static int calc_greedy_ans (Contest contests, int day, vector<int> &last) {
    long long max_score = INT_MIN;
    int ans_c = 1;

    for ( int c = 1; c <= N_CONTEST; c++ ) {
        long long score = calc_score(contests, day, last, c);

        if ( score > max_score ) {
            max_score = score;
            ans_c = c;
        }
    }
    last.at(ans_c) = day;

    return ans_c;
}

static void dump_ans (Contest contests) {
    vector<int> last(N_CONTEST+1, 0);

    for ( int d = 1; d <= contests.day; d++ ) {
        int c = calc_greedy_ans(contests, d, last);
        cout << c << endl;
    }
}

int main (void) {
    Contest contests;

    dump_ans(contests);

    return 0;
}



Measured memory_bytes: 3784
void main()
{
    long[] nda = rdRow;
    long n = nda[0], d = nda[1], a = nda[2];
    long[] x = new long[n], h = new long[n];
    foreach (i; 0 .. n)
    {
        long[] tmp = rdRow;
        x[i] = tmp[0], h[i] = tmp[1];
    }

    zip(x, h).sort!((u, v) => u[0] < v[0]);
    Info[] bomb;
    long damage;
    long result;
    foreach (i; 0 .. n)
    {
        while (!bomb.empty && bomb[0].x + d < x[i])
        {
            damage -= bomb[0].h;
            bomb.popFront;
        }
        h[i] -= damage;
        if (h[i] > 0)
        {
            long cnt = (h[i] + a - 1) / a;
            result += cnt;
            damage += a * cnt;
            bomb ~= Info(x[i]+d, a*cnt);
        }
    }

    result.writeln;
}

struct Info
{
    long x, h;
}

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 8956
n = int(input())
h = list(map(int, input().split()))

for i in range(n-1):
    if h[i] <= h[i+1]:
        pass
    elif h[i] <= h[i+1]+1:
        h[i+1] = h[i+1]+1
    else:
        print("No")
        exit()

print("Yes")

Measured memory_bytes: 14396
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

const int N = (int) 1e6 + 5, mod = (int) 0;
int mark[N], p[N];
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, x;
    cin >> n >> x;
    if (x == 2 * n - 1 || x == 1) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    if (n == 2) {
        for (int i = 1; i <= 3; ++i)
            cout << i << endl;
        return 0;
    }
    p[n - 1] = x;
    p[n - 2] = x - 1;
    p[n - 0] = x + 1;
    if (x - 2 >= 1) {
        p[n + 1] = x - 2;
    } else {
        p[n - 3] = x + 2;
    }
    for (int i = 0; i < 2 * n - 1; ++i)
        mark[p[i]] = 1;
    int m = 0;
    mark[0] = 1;
    for (int i = 0; i < 2 * n - 1; ++i) {
        if (p[i] == 0) {
            while (mark[m]) m++;
            p[i] = m;
            mark[p[i]] = 1;
        }
        cout << p[i] << endl;
    }
}



Measured memory_bytes: 3072
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>

const int INF = 0x3f3f3f3f;
const int DOWN = 1;
const int LEFT = 2;
const int DIAG = 3;

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

	string s, t;
	cin >> s >> t;

	int m = s.size();
	int n = t.size();
	int c[m+1][n+1];  // c[i][j] is length of LCS of s_i and t_j
	int b[m][n];      // b[i-1][j+1] tells us what choice we made for c[i][j]
	for (int i = 0; i < m+1; i++) {
	  c[i][0] = 0;
	}
	for (int j = 0; j < n+1; j++) {
	  c[0][j] = 0;
	}
	for (int i = 1; i < m+1; i++) {
	  for (int j = 1; j < n+1; j++) {
	    if (s[i-1]  == t[j-1]) {
	      c[i][j] = c[i-1][j-1] + 1;
	      b[i-1][j-1] = DIAG;
	    } else {
	      int left = c[i][j-1];
	      int down = c[i-1][j];
	      if (left > down) {
		c[i][j] = left;
		b[i-1][j-1] = LEFT;
	      } else {
		c[i][j] = down;
		b[i-1][j-1] = DOWN;
	      }
	    }
	  }
	}

	// Now read off the answer backwards.
	string ans;
	while (m > 0 && n > 0) {
	  int cur = b[m-1][n-1];
	  if (cur == DIAG) {
	    ans.push_back(s[m-1]);
	    m -= 1;
	    n -= 1;
	  } else if (cur == DOWN) {
	    m -= 1;
	  } else {
	    n -= 1;
	  }
	}
	std::reverse(ans.begin(), ans.end());
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 70656
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;

const ll mod197 = 1000000007LL;
const ll INF = 200LL * 200 * 100000 + 10;

const double PI11 = 3.14159265359;

// (a ^ b) % mod
ll powMod(ll x, ll k, ll m) {
	if (k == 0)     return 1;
	if (k % 2 == 0) return powMod(x*x % m, k / 2, m);
	else            return x*powMod(x, k - 1, m) % m;
}

int main() {

	int n, m, k;
	cin >> n >> m >> k;

	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= m; j++) {
			//cout << i*m + j*n - i*j*2 << endl;
			if (k == i*m + j*n - i*j*2) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;

	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <stdlib.h>
using namespace std;

int main(){

    int a ,b;
    scanf("%d%d",&a,&b);
    int l = 10,temp = b;
    while(true){
        if(b < 10) break;
        l *= 10;
        temp = temp /10;
        if(temp < 10) break;
    }

    int add = a * l + b;
    bool flag = false;
    for(int i = 1;i<add;i++){
        if(i*i == add){
            flag = true;
            break;
        }
    }

    if(flag) printf("Yes\n");
    else printf("No\n");


    return 0;
}

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

int main()
{
long long int a,b,c,d;
cin>>a>>b>>c>>d;
long long int k=max(a*c,b*d);
long long int k2=max(a*d,b*c);
cout<<max(k,k2);
return 0;
}

Measured memory_bytes: 3644
// D - Coloring Edges on Tree
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int N; cin>>N;
	vector<int> G(N), C(N-1);
	rp(i, 0, N-1){
		int p; cin>>p>>C[i];
		C[i]--;
		G[C[i]] = p-1;
	}

	vector<int> colors(N), pre_colors(N);
	rp(c, 1, N){
		int p = G[c];
		int color = pre_colors[p] + 1;
		colors[c] = color==colors[p]? ++color: color;
		pre_colors[p] = colors[c];
	}

	int K = 1;
	for(int k:pre_colors) K = max(K, k);
	cout<< K <<endl;
	for(int c:C) cout<< colors[c] <<endl;
}

Measured memory_bytes: 2048
#include <iostream>//cout
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <functional>
#include <list>
#include <utility>//swap
using namespace std;
static const int MAX = 200000;
#define rep(i,n) for(int i=0;i<n;i++)
#define GET_ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
 
int main() {
  long long int n, h;
  cin >> n >> h;
  if (n%2 && h%2) {
    cout << "Odd" << endl;
    return 0;
  }
  cout << "Even" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
  
int main() {
long long int n,res=0;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
	cin>>a[i];
}
int p=0;
sort(a,a+n,greater<int>());
for(int i=0;i<n-1;i++){
		res=res+(long long)(a[p]);
	if(i%2==0){
		p++;
	}
		

}

cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 4384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
using namespace std;

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

    int64_t k;
    cin >> k;

    for (int i = 0; i < s.length(); i++) {
        int need = ('z' + 1 - s[i]) % 26;
        if (k >= need) {
            k -= need;
            s[i] = 'a';
        }
    }

    if (k > 0) {
        s[s.length() - 1] = 'a' + (s[s.length() - 1] - 'a' + k) % 26;
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main implements Closeable {

  private InputReader in = new InputReader(System.in);
  private PrintWriter out = new PrintWriter(System.out);

  public void solve() {
    n = in.ni();
    joy = new int[n][3];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 3; j++) {
        joy[i][j] = in.ni();
      }
    }
    dp = new Integer[n][3];
    int ans = 0;
    for (int i = 0; i < 3; i++) {
      ans = Math.max(joy[0][i] + recurse(1, i), ans);
    }
    out.println(ans);
  }
  
  private int n;
  private int[][] joy;
  private Integer[][] dp;
  
  private int recurse(int idx, int last) {
    if (idx == n) return 0;
    
    if (dp[idx][last] != null) return dp[idx][last];
    
    int ans = 0;
    for (int i = 0; i < 3; i++) {
      if (i != last) {
        ans = Math.max(joy[idx][i] + recurse(idx + 1, i), ans);
      }
    }
    return dp[idx][last] = ans;
  }

  @Override
  public void close() throws IOException {
    in.close();
    out.close();
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int ni() {
      return Integer.parseInt(next());
    }

    public long nl() {
      return Long.parseLong(next());
    }

    public void close() throws IOException {
      reader.close();
    }
  }

  public static void main(String[] args) throws IOException {
    try (Main instance = new Main()) {
      instance.solve();
    }
  }
}


Measured memory_bytes: 66468
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    fast;
    long long x,p,q;
    cin>>x;
    p=x/500;
    x=x%500;
    q=x/5;
    cout<<p*1000+q*5;
}


Measured memory_bytes: 256
h,w,n=map(int,input().split())
sr,sc=map(lambda x:int(x)-1,input().split())
s=input()
t=input()
answ,ansh=[0,w-1],[0,h-1]
for i in range(n):
    if s[-i-1]=='R':
        answ[1]-=1
    if s[-i-1]=='L':
        answ[0]+=1
    if s[-i-1]=='D':
        ansh[1]-=1
    if s[-i-1]=='U':
        ansh[0]+=1
    if answ[0]>answ[1] or ansh[0]>ansh[1]:
        print('NO')
        exit()
    if i==n-1:
        break
    if t[-i-2]=='R':
        answ[0]=max(0,answ[0]-1)
    if t[-i-2]=='L':
        answ[1]=min(w-1,answ[1]+1)
    if t[-i-2]=='D':
        ansh[0]=max(0,ansh[0]-1)
    if t[-i-2]=='U':
        ansh[1]=min(h-1,ansh[1]+1)
if answ[0]<=sc<=answ[1] and ansh[0]<=sr<=ansh[1]:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3888
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>

typedef long long ll;
using namespace std;
 
ll K;
string s("19");
 
int main(void){
    
    cin >> K;
    
    int i = 1;
    for(; i <= K && i <= 9; ++i) cout << i << "\n";
    int j = 1;
    for(; i <= K && j <= 9; ++i) cout << j++ << "9" << "\n";
    j = 1;
    for(; i <= K && j <= 19; ++i) cout << j++ << "99" << "\n";
    j = 2;
    for(; i <= K && j <= 29; ++i) cout << j++ << "999" << "\n";
    j = 3;
    for(; i <= K && j <= 39; ++i) cout << j++ << "9999" << "\n";
    j = 4;
    for(; i <= K && j <= 49; ++i) cout << j++ << "99999" << "\n";
    j = 5;
    for(; i <= K && j <= 59; ++i) cout << j++ << "999999" << "\n";
    j = 6;
    for(; i <= K && j <= 69; ++i) cout << j++ << "9999999" << "\n";
    j = 7;
    for(; i <= K && j <= 79; ++i) cout << j++ << "99999999" << "\n";
    j = 8;
    for(; i <= K && j <= 89; ++i) cout << j++ << "999999999" << "\n";
    j = 9;
    for(; i <= K && j <= 99; ++i) cout << j++ << "9999999999" << "\n";
	j = 10;
	for (; i <= K and j <= 99; i++) cout << j++ << "99999999999" << "\n";
	j = 10;
	for (; i <= K and j <= 109; i++) cout << j++ << "999999999999" << "\n";
	j = 11;
	for (; i <= K and j <= 109; i++) cout << j++ << "9999999999999" << "\n";
	j = 11;
	for (; i <= K and j <= 99; i++) printf("%d99999999999999a\n", j++);
    j = 10;
    for(; i <= K && j <= 109; ++i) cout << j++ << "99999999999" << "\n";
    j = 11;
    for(; i <= K && j <= 119; ++i) cout << j++ << "999999999999" << "\n";
    j = 12;
    for(; i <= K && j <= 129; ++i) cout << j++ << "9999999999999" << "\n";
    j = 13;
    for(; i <= K && j <= 139; ++i) cout << j++ << "99999999999999" << "\n";
    
    return 0;
}

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

#define LEN 100005
int head, tail, n;

typedef struct {
	char name[100];
	int time;
} Data;

Data data[LEN];
void enqueue(Data x)
{
	data[tail] = x;
	tail = (tail + 1) % LEN;
}

Data dequeue()
{
	Data x = data[head];
	head = (head + 1) % LEN;
	return x;
}

int min(int a, int b)
{
	return a < b ? a : b;
}


int isEmpty()
{
	return head == tail;
}
int main()
{
	int i,q,c;
	int sum_time = 0;
	Data temp;
	scanf("%d %d", &n, &q);
	head = 0;
	tail = n;
	for (i = 0; i < n; i++) {
		scanf("%s %d", &data[i].name, &data[i].time);
	}
	while (!isEmpty()) {
		temp = dequeue();
		c = min(temp.time, q);
		temp.time -= c;
		sum_time += c;
		if (temp.time > 0) {
			enqueue(temp);
		}
		else {
			printf("%s %d\n", temp.name, sum_time);
		}
	}

	return 0;
}



Measured memory_bytes: 11900
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n-1)]
pq=[list(map(int,input().split())) for _ in range(m)]
ab2=sorted(ab, key=lambda x:x[0])
pq2=sorted(pq, key=lambda x:x[0])

res=[0 for _ in range(n)]
for p,q in pq2:
	res[p-1]+=q
for a,b in ab2:
	res[b-1]+=res[a-1]
ans=str(res[0])
for i in range(1,n):
	ans+=" "+(str(res[i]))
print(ans)

Measured memory_bytes: 117232
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    ll n,a,ans = 0;
    cin >> n;
    rep(i, n){
        cin >> a;
        for (; a % 2 == 0; ) {
            ++ans;
            a /= 2;
        }
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxn= 5e5+5;
#define mod 1000000007
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    rishabh();
    int n,k,q;
    cin>>n>>k>>q;
    int arr[n]={};
    for(int i=0;i<q;i++){
        int x;
        cin>>x;
        arr[--x]++;
    }
    for(int i=0;i<n;i++){
        if(k-q+arr[i]>0){
            cout<<"Yes"<<endl;
        }
        else cout<<"No"<<endl;
    }
}



Measured memory_bytes: 4020
n, q = map(int, input().split())
s = input()
lst = [0 for _ in range(n)]
cnt = 0

for i in range(1, n):
    p = s[i-1:i+1]
    if p == 'AC':
        cnt += 1
    lst[i] = cnt
for _ in range(q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    #print(l-1, lst[l-1])
    #print(r, lst[r])
    print(lst[r] - lst[l])

Measured memory_bytes: 6184
#include<iostream>
#include<cstdio>
#include<cstring>
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==b)printf("%d\n",c);
	else if(a==c)printf("%d\n",b);
	else printf("%d\n",a);
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

ll mod = 1000000007;

template<class Type> inline bool chmax(Type& a, Type b) { if (a < b) { a = b; return 1; } return 0; }
template<class Type> inline bool chmin(Type& a, Type b) { if (a > b) { a = b; return 1; } return 0; }

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	ll n;
	cin >> n;
	int count = 0;
	if (n % 2 == 0)
	{
		ll ans = 0;
		ll x = 10;
		while (n / x != 0)
		{
			ans += n / x;
			x *= 5;
		}
		cout << ans << endl;
	}
	else
	{
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> vi;
int n, k, no;
const int MAX=1e5+3;
bool dp[MAX];
int main(){
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&no);
        vi.push_back(no);
        dp[no]=1;
    }

    dp[0]=0;

    for(int i=1;i<=k;i++){
        for(int j=0;j<n;j++){
            if(i-vi[j]>0&&!dp[ i-vi[j] ]){
                dp[i]=1;
                break;
            }
        }
    }

    if(dp[k]) printf("First\n");
    else printf("Second\n");



    return 0;
}


Measured memory_bytes: 3852
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var a = int.Parse(_[0]);
            var b = int.Parse(_[1]);

            for(var i = 0; i < 16; i++){
                if(a <= 0 && b <= 0){
                    break;
                }
                if(i % 2 == 0){
                    a--;
                }else{
                    b--;
                }
            }

            Console.WriteLine(a <= 0 && b <= 0 ? "Yay!" : ":(");
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N;
  cin>>N;
  vi dp(N+1);
  REP(i,1,N){
    dp[i]=dp[i-1]+1;
    int X=6;
    while(X<=i){
      dp[i]=min(dp[i],dp[i-X]+1);
      X*=6;
    }
    X=9;
    while(X<=i){
      dp[i]=min(dp[i],dp[i-X]+1);
      X*=9;
    }
  }
  cout<<dp[N]<<endl;
  }



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

int main()
{
    unordered_map<string,int> u;

    int n;
    cin>>n;

    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        if(u.count(s)==0)
            u[s]=1;
    }

    cout<<u.size();

    return 0;
}


Measured memory_bytes: 17796
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        solve();
    }

    private static void solve() {
        Scanner input = new Scanner(System.in);

        int n = input.nextInt();

        int sum = 0;
        int[] nums = new int[n];
        int min = 0;

        for (int i = 0; i < n; i++) {
        	nums[i] = input.nextInt();
        	sum += nums[i];
        }

        min = sum;

        for (int num: nums) {
        	sum = sum - num * 2;
        	if (sum < 0) {
        		min = Math.min(min, sum * (-1));
        	} else {
        		min = Math.min(min, sum);
        	}
        }

        System.out.println(min);
    }
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

int main(){

  ll n;cin>>n;
  ll p[n],q[n];
  rep(i,0,n)cin>>p[i];
  rep(i,0,n)cin>>q[i];

  ll per[n];rep(i,0,n)per[i]=i+1;

  ll pn,qn;
  ll count=0;
  do{
    count++;
    bool pe=true,qe=true;
    rep(i,0,n){
      if(p[i]!=per[i])pe=false;
      if(q[i]!=per[i])qe=false;
    }

    if(pe)pn=count;
    if(qe)qn=count;


  }while(next_permutation(per,per+n));

  out(abs(pn-qn));

  return 0;
}


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

int main(){
  string s;
  cin >> s;
  bool a=1;
  while(a==1){
    for(int i=0;i<s.size();i++){
      if(s[i]=='B'){
        if(i==0){
          s.erase(s.begin());
          break;
        }
        else{
          s.erase(s.begin()+i-1);
          s.erase(s.begin()+i-1);
          break;
        }
      }
      bool c=0;
      for(int j=0;j<s.size();j++){
        if(s[j]=='B'){
          c=1;
        }
        else{
          continue;
        }
      }
      if(c==0){
        a=0;
      }
    }
  }
  cout << s << endl;
}
      
      

Measured memory_bytes: 256