akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int       long long int
#define vi        vector<int>
#define vii       vector<pii>
#define pii       pair<int, int>
#define mii       map<int, int>
#define pb        push_back
#define rev(v)    reverse(v.begin(), v.end())
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define endl      '\n'
#define F         first
#define S         second
#define PI        3.14159265359
#define MAXN      100007

const int mod = 1e9 + 7;

int dp[MAXN], arr[MAXN];
int n, k;

int solve(int idx)
{
   if (idx >= n)
      return INT_MAX;
   if (idx == n - 1)
      return 0;
   if (dp[idx] != -1)
      return dp[idx];

   dp[idx] = INT_MAX;
   for (int i = 1; i <= k; ++i)
   {
      dp[idx] = min(dp[idx], abs(arr[idx] - arr[idx + i]) + solve(idx + i));
   }

   return dp[idx];
}

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

   memset(dp, -1, sizeof dp);
   cin >> n >> k;
   for (int i = 0; i < n; ++i)
   {
      cin >> arr[i];
   }
   cout << solve(0) << endl;
   return 0;
}

Measured memory_bytes: 4992
#define DEBUG 0
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}
int digit(ll n){
    int cnt = 0;
    while(n>0){
        n = n/10;
        cnt++;
    }
    return cnt;
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n; cin>> n;
    ll res = LLINF;
    for(ll a = 1;a*a<=n;a++){
        if(n%a!=0) continue;
        else{
            ll b = n/a;
            ll tmp = max(digit(a),digit(b));
            res = min(tmp,res); 
        } 
    }
    // cout << f << endl;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3612
n, m = map(int, input().split())
X = sorted(list(map(int, input().split())))
Diffs = [0] + [X[i] - X[i-1] for i in range(1, m)]

if n >= m:
  print(0)
elif n == 1:
  Diffs.sort()
  print(sum(Diffs))
else:
  Diffs.sort()
  print(sum(Diffs[:-(n-1)]))


Measured memory_bytes: 58536
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0);
    int a,b,c;
    cin>>a>>b>>c;
    if(a==5 && b==7 && c==5)
    {
        cout<<"YES";
    }
    else if (a==7 && b==5 && c==5){
        cout<<"YES";
    }
    else if (a==5 && b==5 && c==7){
        cout<<"YES";
    }
    else cout<<"NO";
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [int(num) for num in input().split(" ")]
q = int(input())
t = [int(num) for num in input().split(" ")]

def binary_search(s, x):
    left = 0
    right = len(s)
    while right > left:
        middle = int((left + right) / 2)
        if s[middle] == x:
            return middle
        elif s[middle] > x:
            right = middle
        else:
             left = middle + 1
    return -1
        

sum = 0
for i in range(q):
    if (binary_search(s, t[i]) != -1):
        sum += 1

print(sum)


Measured memory_bytes: 16896
#include <bits/stdc++.h>
using namespace std;
int n, arr[110];
int main () {
	cin >> n;
	int ans = 1;
	int m = 1, t;
	for (int j = 0; j < n; j++) {
		ans *= 3;
		cin >> t;
		if (t & 1) m *= 1;
		else m *= 2;
	}
	cout << ans - m;
	return 0;
}

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

#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

//プロトタイプ宣言
void faster(void);
ll gcd(auto , auto);
ll get_digent(auto);
ll POW(auto , auto);
ll vec_max(auto & , string);
ll vec_min(auto & , string);

int main(){
  ll n;
  cin >> n;
  vl a(n);
  rep(i,n) cin >> a[i];
  ll cnt = 1;
  ll cnt1 = 0;
  rep(i,n){
    if(a[i] == cnt){
      cnt++;
    }
  }
  if(cnt != 1)cout << n - cnt + 1 << endl;
  else cout << -1 << endl;
}


























//以下、ライブラリ

//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
ll gcd(auto a, auto b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
ll get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
ll POW(auto x, auto y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//配列内の最大要素の添え字取得or要素取得
ll vec_max(auto &v, string s){
  auto itr = max_element(v.begin(),v.end());
  ll element = *itr;
  ll place = itr - v.begin();
  if(s == "element") return element;
  else if(s == "place") return place;
  else return -1;
}

//配列内の最小要素の添え字取得or要素取得
ll vec_min(auto &v, string s){
  auto itr = min_element(v.begin(),v.end());
  ll element = *itr;
  ll place = itr - v.begin();
  if(s == "element") return element;
  else if(s == "place") return place;
  else return -1;
}

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

int c[27], s[366][27], t[366], last[27];
int main()
{
    int D; cin>>D;
    for(int i=1; i<=26; ++i) cin>>c[i];
    for(int i=1; i<=D; ++i)
        for(int j=1; j<=26; ++j)
            cin>>s[i][j];

    auto calc_score=[&](){
        long score=0;
        for(int i=1; i<=26; ++i) last[i]=0;
        for(int d=1; d<=D; ++d) {
            score+=s[d][t[d]];
            last[t[d]]=d;
            for(int i=1; i<=26; ++i) score-=c[i]*(d-last[i]);
        }
        return score;
    };

    for(int i=1; i<=D; ++i) {
        long bestscore=-(1L<<60), typ=1;
        for(int j=1; j<=26; ++j) {
            t[i]=j;
            auto score=calc_score();
            t[i]=0;
            if (bestscore<score) {
                bestscore=score;
                typ=j;
            }
        }
        t[i]=typ;
    }

    mt19937 engine;
    uniform_int_distribution<> rndT(1, 26), rndD(1, 365);
    auto bestscore=calc_score();

    for(int A=200000; A--; ) {
        int d=rndD(engine);
        int q=rndT(engine);
        int x=t[d];
        t[d]=q;
        auto score=calc_score();
        if (bestscore<score) {
            bestscore=score;
        }
        else {
            t[d]=x;
        }
    }
    for(int i=1; i<=D; ++i) cout<<t[i]<<endl;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  ll a_sum = 0, b_sum = 0;
  for (auto &e : a)
  {
    cin >> e;
    a_sum += e;
  }
  for (auto &e : b)
  {
    cin >> e;
    b_sum += e;
  }
  if (a_sum < b_sum)
  {
    cout << -1 << endl;
    return 0;
  }

  priority_queue<ll> que;
  for (int i = 0; i < n; ++i)
  {
    que.push(a[i] - b[i]);
  }

  ll tmp = 0;
  ll cnt = 0;
  for (int i = 0; i < n; ++i)
  {
    ll dif = a[i] - b[i];
    if (dif < 0)
    {
      cnt++;
      while (tmp + dif < 0)
      {
        tmp += que.top();
        que.pop();
        cnt++;
      }
      tmp += dif;
    }
  }
  cout << cnt << endl;

  return 0;
}


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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define MOD 1000000007

int pow_mod(int n, int m){
	int ans = 1;
	while(m > 0){
		if(m & 1) ans = (ans * n) % MOD;
		n = (n * n) % MOD;
		m >>= 1;
	}
	return ans;
}

vector<int> mi[100010];

signed main(){
	int n, k;
	cin >> n >> k;

	for(int i = 1;i <= k;i++){
		for(int j = i+i;j <= k;j+=i){
			mi[j].push_back(i);
		}
	}

	int tmp[100010] = {};
	int ans = 0;
	for(int i = k;i > 0;i--){
		int num = k/i;
		tmp[i] = (tmp[i] + pow_mod(num, n)) % MOD; 
		for(auto e: mi[i]){
			tmp[e] = (MOD + tmp[e] - tmp[i]) % MOD;
		}
		ans = (ans + tmp[i]*i % MOD) % MOD;
	}

	cout << ans << endl;

	return 0;
}


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


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n;
    int v[n], dp[n];
    for(int &i: v) {
        cin >> i;
    }
    dp[n-1] = 0;
    dp[n-2] = abs(v[n-1]-v[n-2]);
    for(int i=n-3; i>=0; i--) {
        dp[i] = min(abs(v[i+1]-v[i])+dp[i+1], abs(v[i+2]-v[i])+dp[i+2]);
    }
    cout << dp[0] << '\n';
    return 0;
}

Measured memory_bytes: 1024
#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;
typedef long long ll;


int H,W;
vector<vector<char> > A;
queue<pair<int, int> > br;

vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};



int bfs(){
    
    int ans = 0;
    
    queue<pair<int, int> > nbr;
    while (true) {
        while (br.size()) {
            
            int x = br.front().first;
            int y = br.front().second;
            
            br.pop();
            rep(i,4){
                int nx = x + dx[i];
                int ny = y + dy[i];
                
                if (0<=nx && nx<=H-1 && 0<=ny && ny<=W-1 && A[nx][ny]=='.') {
                    nbr.push(pair<int,int>(nx,ny));
                    A[nx][ny] = '#';
                }
            }
        }
        if (nbr.size()) {
            ans += 1;
            while (nbr.size()) {
                br.push(nbr.front());
                nbr.pop();
            }
        }else{
            break;
        }
    }
   
    return ans;
    
    
}



int main(){
    
    cin >> H >> W;
    A.assign(H,vector<char>(W,'.'));
    rep(i,H){
        rep(j,W){
            cin >> A[i][j];
            if (A[i][j] == '#') {
                br.push(pair<int,int>(i,j));
            }
            
        }
    }
    
    cout << bfs() << endl;

    return 0;
    
}


Measured memory_bytes: 9488
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

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

template <typename T>
void make_unique(vector<T>& vec) {
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
}

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    /*rlimit rlim;
    if (getrlimit(RLIMIT_STACK, &rlim)) return 1;
    rlim.rlim_cur = rlim.rlim_max;
    if (setrlimit(RLIMIT_STACK, &rlim)) return 2;*/
    ll n=nxt();
    ll temp=7%n,cnt=1;
    ll vis[n]={0};
    while(temp%n>0)
    {
        vis[temp]=1;
        temp=(temp*10+7)%n;
        if(vis[temp])
        {
            cout<<-1<<endl;
            exit(0);
        }
        cnt++;
    }
    cout<<cnt<<endl;
	return 0;
}

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

inline void up(int &x, int y) { x < y ? x = y : 0; }
inline void down(int &x, int y) { x > y ? x = y : 0; }
inline int max(const int x, const int y) { return x > y ? x : y; }
inline int min(const int x, const int y) { return x < y ? x : y; }

int A, B;
struct game {
	int n, a[105][105];
	game() { n = 100; memset(a, 0, sizeof a); }
	inline void maker(int A, int B) {
		for (int i = 1; i * 2 <= n; ++i) 
			for (int j = 1; j <= n; ++j) a[i][j] = 1;
		--A, --B;
		
		for (int i = 1; i <= 49; i += 2)
			for (int j = 1; j <= n; j += 2) 
				if (A > 0) a[i][j] = 0, --A;
		
		for (int i = 52; i <= n; i += 2)
			for (int j = 1; j <= n; j += 2) 
				if (B > 0) a[i][j] = 1, --B;
	}
	inline void print() {
		std::cout << n << ' ' << n << '\n';
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= n; ++j) 
				if (a[i][j]) std::cout << '#';
				else std::cout << '.';
			std::cout << '\n';
		}
	}
} play;
int main() {
	//freopen("b.in", "r", stdin);freopen("b.out", "w", stdout);
    std::ios::sync_with_stdio(false), std::cin.tie(0);
    std::cin >> A >> B;
	play.maker(A, B);
	play.print();
	return 0;
}


Measured memory_bytes: 3696
import java.util.Scanner;

public class Main{
	public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		int H,W;
		while(true){
			H = sc.nextInt();
			W = sc.nextInt();
			if(H==0&&W==0) break;
			for(int i=0; i<H; i++){
				for(int j=0; j<W; j++){
					if(i%2==j%2)System.out.print("#");
					else System.out.print(".");
				}
				System.out.println();
			}
			System.out.println();
			
		}
	}
}

Measured memory_bytes: 26848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;

int main() {
    ll N, K; cin >> N >> K;
    vector<ll> a(N); vector<ll> f(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    for (int i = 0; i < N; ++i) cin >> f[i];
    sort(f.begin(), f.end(), greater<int>());
    sort(a.begin(), a.end());

    ll b = 0, e = a[a.size()-1] * f[0];
    ll ans = e;
    while (b <= e) {
        ll m = b + ((e-b)>>1);
        ll total = 0;
        for (int i = 0; i < N; ++i) {
            ll r = m / f[i];
            total += max(0ll, a[i] - r);
        }
        if (total <= K) {
            ans = m;
            e = m - 1;
        } else {
            b = m + 1;
        }
    }

    cout << ans;

    return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
const int inf = 1e9;

struct Edge {
  int to, cost;
  Edge(int to, int cost) : to(to), cost(cost) {}
  bool operator<(const Edge& rhs) const {
    if (cost != rhs.cost) return cost > rhs.cost;
    return to < rhs.to;
  }
};
using Graph = vector<vector<Edge>>;

int dist[2048];
vector<int> pre[2048];
bool used[2048];
bool vis[2048];

int dfs(int v) {
  used[v] = vis[v] = true;
  for (int u : pre[v]) {
    if (vis[u]) continue;
    dfs(u);
  }
}

int main() {
  int N, R;
  cin >> N >> R;
  Graph G(N);
  REP(i, R) {
    int s, t, d;
    cin >> s >> t >> d;
    s--;
    t--;
    G[s].emplace_back(t, d);
    G[t].emplace_back(s, d);
  }

  int diag = 0;
  REP(s, N) {
    REP(i, N) {
      dist[i] = inf;
      pre[i].clear();
    }
    dist[s] = 0;
    priority_queue<Edge> pq;
    pq.emplace(s, 0);
    while (not pq.empty()) {
      auto e = pq.top();
      pq.pop();
      auto v = e.to;
      if (e.cost > dist[e.to]) continue;
      for (auto&& ee : G[e.to]) {
        auto u = ee.to;
        auto d = e.cost + ee.cost;
        if (dist[u] < d) continue;
        if (dist[u] > d) {
          dist[u] = d;
          pq.emplace(u, d);
          pre[u].clear();
        }
        pre[u].push_back(v);
      }
    }
    auto maxi = *max_element(dist + s + 1, dist + N);
    if (diag > maxi) continue;
    if (diag < maxi) {
      diag = maxi;
      memset(used, false, sizeof(used));
    }
    FOR(t, s + 1, N) {
      if (dist[t] != diag) continue;
      memset(vis, false, sizeof(vis));
      dfs(t);
    }
  }
  int M = count(used, used + N, false);
  cout << M << endl;
  REP(v, N) {
    if (used[v]) continue;
    cout << v + 1 << endl;
  }
  return 0;
}

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



int main() {
  std::string in;

  std::cin >> in;

  int a = std::stoi(in);


  std::cin >> in;
  if( in.size() <= a) std::cout << in << std::endl;
  else{
    std::string buf(a,'a');
    for(int i=0;i< a;i++) {
      buf[i] = in[i];
    }
    std::cout << buf + "..." << std::endl;
  }

  return 0;

}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
const int signX[8] ={ 1, 1, 1, 1,-1,-1,-1,-1};
const int signY[8] ={ 1, 1,-1,-1, 1, 1,-1,-1}; 
const int signZ[8] ={ 1,-1, 1,-1, 1,-1, 1,-1};
void solve() {
    int i,j,k,l,r; string s;
    bool exit = false;
    int N,M;
    cin>>N;
    cin>>M;
    ll x[N],y[N],z[N];
    FOR(i,N){
        cin>>x[i]>>y[i]>>z[i];
    }
    vector <ll> cand;
    ll v;
    int ite;
    FOR(ite, 8){
        vector <ll> tgt;
        FOR(i,N){
            tgt.push_back(signX[ite]*x[i]+signY[ite]*y[i]+signZ[ite]*z[i]);
        }
        
        //FORR(v,tgt) cout<<v<<endl;
        //cout<<endl;
        sort(ALL(tgt));
        //FORR(v,tgt) cout<<v<<endl;
        //cout<<endl;
        ll sum = 0;
        FOR(i,M){
            sum += tgt[N-1-i];
        }
        if(sum < 0)
            sum *= -1;
        cand.push_back(sum);
    }
    //FORR(v,cand) cout<<v<<endl;
    //cout<<endl;   
    cout<< *max_element(ALL(cand))<<endl; 

    /*cin>>N;
    vector<ll> V;
    FOR(x,N+1) {
            FOR(y,N+1) {
                    ll ret=1;
                    FOR(i,x) ret*=2;
                    FOR(i,y) ret*=5;
                    V.push_back(ret);
            }
    }
    sort(ALL(V));
    FORR(v,V) cout<<v<<endl;*/
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var seqA = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();

        if (seqA.Min() == 0)
        {
            Console.WriteLine(0);
            return;
        }

        var sum = BigInteger.One;
        foreach (var a in seqA)
        {
            sum *= a;
            if (sum > (BigInteger)1e18)
            {
                break;
            }
        }

        Console.WriteLine(sum > (BigInteger)1e18 ? -1 : sum);
    }
}


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

using namespace std;

template<typename T>
long long modpow(const T n,const T p,const T mod);
template<typename T>
long long modinv(const T n,const T mod);
template<typename T>
bool chmax(T &a,const T &b);
template<typename T>
bool chmin(T &a,const T &b);

long long inf=1000000007;

int main(){
	long long n;
	cin>>n;
	long long nax=0;
	long long ans=0;

	for(long long i=0;i<n;i++){
		long long hoge;
		cin>>hoge;
		if(i==0) nax=hoge;

		if(hoge<nax) ans+=nax-hoge;
		chmax(nax,hoge);
	}

	cout<<ans<<endl;

	return 0;
}

template<typename T>
long long modpow(const T n,const T p,const T mod){
	if(p==0) return 1;
	if(p%2==0){
		long long a=modpow(n,p/2,mod);
		return a*a%mod;
	}
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}

template<typename T>
long long modinv(const T n,const T mod){
	return modpow(n,mod-2,mod);
}

template<typename T>
bool chmax(T &a,const T &b){
	if(a<b){
		a=b;
		return 1;
	}
	return 0;
}

template<typename T>
bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return 1;
	}
	return 0;
}


Measured memory_bytes: 3672
// May this submission get accepted
#pragma GCC optimize ("O3")
#pragma GCC target("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// 標準入出力
struct inp {
    size_t sz;
    inp(size_t _sz = 1) : sz(_sz) {}
    template <typename T> operator T () const { T a; cin >> a; return a; }
    template <typename T> operator vector<T> () const { vector<T> a(sz); for (size_t i = 0; i < sz; i++) cin >> a[i]; return a; }
    template <typename T, typename U> operator pair<T, U> () const { T f; U s; cin >> f >> s; return pair<T, U>(f, s); }
};
inp inp1; // input one
template <typename T> void say(T &x, char end = '\n') { cout << x << end; }
template <typename T> void say(vector<T> &x, char sep = ' ', char end = '\n') { for (size_t i = 0, sz = x.size(); i < sz; i++) { cout << x[i] << (i == sz-1 ? end : sep); } }

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false); // stdioを使うときはコメントアウトすること
    cin.tie(nullptr);            // インタラクティブ問題ではコメントアウトすること
    
    ll n = inp1;
    vector<ll> x = inp(n);

    ll sum = accumulate(ALL_OF(x), 0LL);
    ll avg = sum / n;
    ll avg2 = (sum+n-1) / n;
    ll ans = 0;
    ll ans2 = 0;
    for (ll y : x) ans += (y-avg)*(y-avg);
    for (ll y : x) ans2 += (y-avg2)*(y-avg2);
    chmin(ans, ans2);
    say(ans);
    
}

Measured memory_bytes: 256
N,M=map(int,input().split())
grid = []
for i in range(M):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)
nums = []
judge = []
while len(nums)<N:
  nums.append(1)
  judge.append(False)
judge[0] = True
for arrays in grid:
  if judge[arrays[0]-1] == True:
    judge[arrays[1]-1] = True
  nums[arrays[0]-1] += -1
  nums[arrays[1]-1] += 1
  if nums[arrays[0]-1]==0:
    judge[arrays[0]-1] = False
ans = 0
for states in judge:
  if states == True:
    ans += 1
print(ans)

Measured memory_bytes: 29032
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define Sort(a) sort((a).begin(),(a).end())
#define Reverse(a) reverse((a).begin(),(a).end())
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;
void Debug(auto a);

signed main(){
    int a,k;
    cin >> a >> k;
    int n;
    if(a%2==1){
        n = a/2+1;
    }
    else{
        n = a/2;
    }
    (n>=k)?cout << "YES" : cout << "NO";

    return 0;
}



void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    int a,b,c,d;cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d)<<endl;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll X, Y;
  cin >> X >> Y;
  ll temp = X;
  int ans = 0;
  while(temp <= Y) {
    temp *= 2;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = 3.141592653589;
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
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; }
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); }
intl lcm(intl a,intl b){ return a / gcd(a, b) * b; }
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

signed main(){
    cout << fixed << setprecision(10);
    intl n,k;
    cin >> n >> k;
    intl h[n];
    cin(i,h);
    intl dp[n];
    rep(i,n)dp[i] = INF;
    dp[0] = 0;
    rep(i,n){
        repi(j,1,min(k + 1,n - i)){
            chmin(dp[i + j],dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1792
def main():
    l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    #S = input()
    K = int(input())
    return l[K-1]
print(main())


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

typedef long long ll;
int N;
vector<int> xy[100010];
ll dp[100010][2];
const ll MOD = 1e9 + 7;

ll rec(int n, int nb, int b)
{
    if(dp[n][b] != -1) return dp[n][b];
    if(xy[n].size() == 0 || (xy[n].size() == 1 && xy[n][0] == nb)) return dp[n][b] = 1;
    else
    {
        ll res = 1;
        if(b==0)
        {
            for(int y : xy[n])
            {   
                if(y == nb) continue;
                res *= rec(y, n, b^1) + rec(y, n, b);
                res %= MOD;
            }
            
        } 
        else 
        {
            for(int y : xy[n])
            {
                if(y == nb) continue;
                res *= rec(y, n, 0);
                res %= MOD;
            }
        }
        return dp[n][b] = res;
    }
    
}


int main()
{
    cin >> N;
    for(int i = 0; i < N -1; i++)
    {
        int x, y;
        cin >> x >> y;
        xy[x].push_back(y);
        xy[y].push_back(x);
    }
    memset(dp, -1, sizeof(dp));
    xy[0].push_back(1);
    ll result = rec(0,0, 0);


 cout << result % MOD << endl;
}

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

int main(void) {
	string S, T, U;
	int A, B;

	cin >> S >> T;
	cin >> A >> B;
	cin >> U;

	if (U == S)
		--A;
	else
		--B;

	cout << A << ' ' << B << '\n';
	return 0;
}


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

namespace ABC170A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int[] X = new int[5];
            for(int i = 0; i < 5; i++)
            {
                X[i] = int.Parse(input[i]);
            }
            for (int i = 0; i < 5; i++)
            {
                if (X[i] == 0)
                {
                    Console.WriteLine(i+1);
                }
            }
        }
    }
}


Measured memory_bytes: 27240
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int N; cin>>N;
  vi A(N); REP(i,N) cin>>A[i];

  int num = 1;
  vi seq;
  REP(i,N) {
    if (A[i] == num) {
      seq.push_back(A[i]);
      num++;
    }
  }

  if (seq.empty()) {
    cout << -1 << endl;
    return 0;
  }

  int ans = N - seq.size();
  cout << ans << endl;
  

  return 0;
}


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

double arr[3010];
double dp[3010][3010];

int main()
{
    int n; cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];}


    for(int i=0;i<=n;i++)
        for(int j=0;j<=n;j++)
            dp[i][j]=0;


    dp[1][0]=1-arr[1];
    dp[1][1]=arr[1];

    for(int i=2;i<=n;i++)
    {
        for(int k=0;k<=i-1;k++)
            {
                dp[i][k+1]+=dp[i-1][k]*arr[i];
                dp[i][k]+=dp[i-1][k]*(1-arr[i]);
            }

    }



    double ans=0;
    for(int i=n/2+1;i<=n;i++)
        ans+=dp[n][i];

    cout<<setprecision(9)<<fixed<<ans;

    return 0;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair

int mod = 1e9+7;
int inf = 1e18;
const int N = 5e5+999;
int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int n;
       cin>>n;
       vector<vector<int>> dp(n+10,vi(3,0));
       rep(j,1,n+1)
       {
           int xxx[3];
           cin>>xxx[0]>>xxx[1]>>xxx[2];
           for(int i=0;i<3;++i)
           {
               dp[j][i] = max(dp[j-1][(i-1+3)%3],(dp[j-1][(i+1)%3]))+xxx[i];
           }
       }
       cout<<max({dp[n][0],dp[n][1],dp[n][2]})<<el;

    }
   return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using vpii=vector<pair<int,int>>;
using vi=vector<int>; 
int main() {
  int n, m, l;
  bool a=true;
  string s;
  cin>>s;
  n=s.size(); //7
  m=(n-1)/2; //3
  l=(n+3)/2; //5
  //for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      if(s.at(j)!=s.at(n-1-j)){ cout<<"No"<<endl; a=false; break;}
    }
    if(a==true){
    for(int j=0; j<m; j++){
      if(s.at(j)!=s.at(m-1-j)){ cout<<"No"<<endl; a=false; break;}
    }}
    if(a==true){
    for(int j=l-1; j<n; j++){
      if(s.at(j)!=s.at(n-2-j+l)){ cout<<"No"<<endl; a=false; break;}
    }}
  //}
  if(a==true) cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
alphabets = ("a".."z").to_a
l = alphabets.length
h = {}
alphabets.each_with_index{|c, i| h[c] = i}
while true
    n = gets.to_i
    break if n == 0

    message = gets.chomp
    arr = []
    n.times{arr << gets.chomp.split.map(&:to_i)}
    arr.reverse_each{|a, b|
        diff = b - a
        c = alphabets[(h[message[a - 1]] + diff) % l]
        d = alphabets[(h[message[b - 1]] + diff) % l]
        message[a - 1] = d
        message[b - 1] = c
    }
    puts message
end



Measured memory_bytes: 6844
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int cmp(unsigned long long a,unsigned long long b){
	return a>b;
}
unsigned long long a[10001]={0},gcd,n,s=1,t=1;
unsigned long long GCD(unsigned long long a,unsigned long long b){
	while(a!=0&&b!=0){
		if(a<b)swap(a,b);
		a%=b;
	}
	return a+b;
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
	cin>>a[i];
}
sort(a+1,a+n+1,cmp);
s=a[1];
for(int i=2;i<=n;i++){
	long long t=a[i];
	for(int j=i-1;j>=1;j--){
		long long l=GCD(a[i],a[j]);
		s/=l;
		a[i]/=l;
	}
	s*=t;
}
cout<<s;
	return 0;
}

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

#define pb push_back
#define fst first
#define snd second
#define INF 0x7fffffff
#define INFLL 0x7FFFFFFFFFFFFFFF
#define lenA(ar) sizeof(ar)/sizeof(*ar)
#define lenrows(mat) sizeof(mat)/sizeof(*mat)
#define lencols(mat) sizeof(mat)/sizeof(*mat)
#define fill(a,c) memset(&a, c, sizeof(a))
#define fore(i,x,y) for(ll i=x;i<y;i++)
#define foreI(i,x,y) for(ll i=x-1;i>=y;i--)
#define max2(a,b) max(a, b)
#define max3(a,b,c) max2(max2(a,b),c)
#define min2(a,b) min(a, b)
#define min3(a,b,c) min2(min2(a,b),c)
#define MOD 1000000009
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main() {
    
    ll n;
    cin>>n;
    ll dist = n-1;
    fore(i,1,1000001){
        if(n%i==0){
            ll a = n/i;
            if(a+i<dist)
                dist = a+i-2;
        }
    }
    cout<<dist<<"\n";
    return 0;
}

Measured memory_bytes: 384
using System;

namespace AizuOnline
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inp = Console.ReadLine().Split();
            int w = Int32.Parse(inp[0]);
            int h = Int32.Parse(inp[1]);
            int x = Int32.Parse(inp[2]);
            int y = Int32.Parse(inp[3]);
            int r = Int32.Parse(inp[4]);
            string arranged = "Yes";

            if (x < r)
            {
               arranged = "No";
            }
            if (x+r > w)
            {
               arranged = "No";
            }
            if (y < r)
            {
               arranged = "No";
            }
            if (y+r > h)
            {
               arranged = "No";
            }
            //Console.WriteLine("w={0} h={1} x={2} y={3} r={4}", w, h, x, y, r);
            Console.WriteLine(arranged);
        }
    }
}


Measured memory_bytes: 8892
use std::cmp;

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut a_b = s.split_whitespace();
    let a: u32 = a_b.next().unwrap().to_string().parse().unwrap();
    let b: u32 = a_b.next().unwrap().to_string().parse().unwrap();

    if a == b {
        print!("{}", a * 2);
    } else {
        print!("{}", cmp::max(a, b) * 2 - 1);
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void){

  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  if (a <= b && b <= c){
    printf("%d %d %d\n",a,b,c);
  }else if (a <= c && c <= b){
    printf("%d %d %d\n",a,c,b);
  }else if (b <= a && a <= c){
    printf("%d %d %d\n",b,a,c);
  }else if (b <= c && c <= a){
    printf("%d %d %d\n",b,c,a);
  }else if (c <= a && a <= b){
    printf("%d %d %d\n",c,a,b);
  }else if (c <= b && b <= a){
    printf("%d %d %d\n",c,b,a);
  }else{
  }
  return 0;
}

Measured memory_bytes: 596
//
// Created by wulang on 10/10/16.
//

#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
    if (argc == 2) {
        freopen(argv[1], "r", stdin);
    }

    string ss;
    int n,a,b;
    while(cin>>n>>a>>b) {
        cin>>ss;
        int nowA=0, nowB=0;
        for(int i=0;i<ss.size();i++) {
            if(ss[i]=='a') {
                if(nowA+nowB<a+b) puts("Yes"), nowA++;
                else puts("No");
            }else if(ss[i]=='b') {
                if(nowA+nowB<a+b&&nowB<b){
                    puts("Yes");
                    nowB++;
                }else puts("No");
            } else {
                puts("No");
            }

        }
    }
    return 0;
}



Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<int> a(n);
	vector<int> b(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		b[a[i] - 1] = i + 1;
	}
	
	for(int i = 0; i < n; ++i) {
		cout << b[i] << " ";
	}
	
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int h, w;
int c[15][15];
int dp[15];
int a[205][205];
LL ans = 0;
/**********************************************/

int main(){
    cin >> h >> w;
    REP(i, 10){
        REP(j, 10){
            cin >> c[i][j];
        }
    }

    REP(i, h){
        REP(j, w){
            cin >> a[i][j];
        }
    }

    REP(i, 10){ dp[i] = INF; }
    
    dp[1] = 0;
    
    vector<int> v(10);
    REP(i, 10){
        v[i] = i;
    }
    do{ 
        int sum = 0;
        int pre = -1;
        int firstnum;
        for(auto x: v){
            if(pre == -1){
                pre = x;
                firstnum = x;
                continue;
            }
            if(x != 1){
                sum += c[pre][x];
                pre = x;
            }else{
                sum += c[pre][x];
                dp[firstnum] = min(dp[firstnum], sum);
                break;
            }
        }
    }while(next_permutation(v.begin(), v.end()));

    REP(i, h){
        REP(j, w){
            if(a[i][j] == -1) continue;
            else{
                ans += dp[a[i][j]];
            }
        }
    }
    

    cout << ans << endl;
}   


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int MAXN = 100000;
typedef long long LL;

vector<int> accumulated(MAXN);
vector<int> temp(MAXN);
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;

	for (int i = 1; i <= n; i++){
		cin >> accumulated[i];
	}
	//int diffsum = 0;
	int lo = 0; int hi = accumulated[1];

	while(lo <= hi){
		int i = (lo + hi) / 2;
		temp[0] = i;
		temp[1] = accumulated[1] - i;
		for (int j = 2; j <= n; j++){
			temp[j] = accumulated[j] - temp[j - 1];
		}
		if (temp[n] == temp[0]){
			for (int i = 0; i < n; i++){
				cout << temp[i] * 2 << ' ';
			}
			cerr << "solved" << endl;
			return 0;
		}
		else if (temp[n] > temp[0]){
			lo = i + 1;
		}
		else{
			hi = i - 1;
		}
	}
	return 0;
}


Measured memory_bytes: 2176
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

typedef long long ll;
typedef pair<ll, ll> pint;

template <class T>
std::vector<std::vector<T>> Imos2D(const std::vector<std::vector<T>> &a)
{
    int h = a.size(), w = a[0].size();
    std::vector<std::vector<T>> s(h + 1, std::vector<T>(w + 1, 0));
    rep(i, h) rep(j, w) s[i + 1][j + 1] = a[i][j];
    rep(i, h + 1) rep(j, w) s[i][j + 1] += s[i][j];
    rep(i, h) rep(j, w + 1) s[i + 1][j] += s[i][j];
    return s;
}

//(i, j)を始点とし、そこからi,j含めてh,wこの点を含む長方形内の累積和
template <class T>
int sum(const std::vector<std::vector<T>> &s, int i, int j, int h, int w)
{
    return s[i + h][j + w] - s[i][j + w] + s[i][j] - s[i + h][j];
}

signed main()
{
    int n, k;
    cin >> n >> k;
    pint tmp_x[n], tmp_y[n];
    rep(i, n)
    {
        int x, y;
        cin >> x >> y;
        tmp_x[i] = pint(x, i);
        tmp_y[i] = pint(y, i);
    }
    sort(tmp_x, tmp_x + n);
    sort(tmp_y, tmp_y + n);

    vector<vector<int>> is_exist(n, vector<int>(n, 0));
    int nx[n], ny[n];
    rep(i, n)
    {
        rep(j, n)
        {
            if (tmp_x[i].second == tmp_y[j].second)
            {
                is_exist[i][j] = 1;
                nx[i] = tmp_x[i].first;
                ny[j] = tmp_y[j].first;
            }
        }
    }

    auto imos = Imos2D(is_exist);
    int ans = (int)1e19;
    rep(i, n)
    {
        rep(j, n)
        {
            for (int p = 1; p + i <= n; p++)
            {
                for (int q = 1; q + j <= n; q++)
                {
                    if (sum(imos, i, j, p, q) >= k)
                    {
                        ans = min(ans, (nx[p + i - 1] - nx[i]) * (ny[q + j - 1] - ny[j]));
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
class BRI{
	public:
	int N;
	vi used;
	vvi G;
	vp bridge;
	void add_edge(int s,int t){
		G[s].pb(t);
		G[t].pb(s);
	}
	BRI(int size){
		N=size;
		G=vvi(N);
	}
	int dfs(int i,int prev,int &n){
		if(used[i])return used[i];
		int m=n;
		used[i]=n++;
		rep(j,G[i].size()){
			if(prev==G[i][j])continue;
			if(used[i]<used[G[i][j]])continue;
			int res=dfs(G[i][j],i,n);
			m=min(m,res);
			if(used[i]<res)bridge.pb(pii(min(i,G[i][j]),max(i,G[i][j])));
		}
		return m;
	}
	void bri(){
		used=vi(N);
		bridge=vp(0);
		int n=1;
		rep(i,N)if(!used[i])dfs(i,-1,n);
		sort(all(bridge));
		rep(i,bridge.size())cout<<bridge[i].first<<" "<<bridge[i].second<<endl;
	}
};
int main(){
	int n,m;
	cin>>n>>m;
	BRI bri(n);
	while(m--){
		int a,b;
		cin>>a>>b;
		bri.add_edge(a,b);
	}
	bri.bri();
}

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

string getS(ll a){
  string res;
  while(a) res=(char)(a%10+'0')+res,a/=10;
  return res;
}

int main(){
  while(1){
    ll n,k;
    cin>>n>>k;
    if(!n&&!k) break;
    ll sum=0,d=1,c=9;
    while(sum+c*d<n){
      sum+=c*d;
      c*=10;
      d++;
    }
    
    ll num=(10*(c/10)/9)+(n-sum-(d!=1))/d;
    ll idx=(n-sum-(d!=1))%d;
    string ans,str=getS(num);
    for(int i=idx;i<str.size()&&ans.size()<k;i++)ans+=str[i];
  
    while(ans.size()<k){
      str=getS(++num);
      for(int i=0;i<str.size()&&ans.size()<k;i++)ans+=str[i];
    }
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3172
integer :: n,k
integer,allocatable :: p(:)
integer :: i,j, buffer


read*,n,k
allocate( p(n) )
read*,p

do i = 1,n-1
do j = i+1,n
  if( p(i)>p(j) )then
    buffer = p(i)
    p(i) = p(j)
    p(j) = buffer
  end if
end do
end do

print*,sum(p(1:k))
end program

    

Measured memory_bytes: 2872