akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const long long infi = 1e18;
long long dp[100][100001];
int main()
{
    int n,w;
    cin>>n>>w;
    long long val[n],wei[n];
    for (int i=0;i<n;i++)
    cin>>wei[i]>>val[i];

    for (int i=0;i<100;i++)
    {
        for (int j=0;j<=100000;j++)
        dp[i][j]=infi;
    }
    dp[0][0]=0;
    dp[0][val[0]]=wei[0];
    for (int id = 1;id<n;id++)
    {
        dp[id][0]=0;
        for (int j=1;j<=100000;j++)
        {
            dp[id][j]=dp[id-1][j];
            if (j>=val[id])
            {
                dp[id][j]=min(dp[id][j],wei[id]+dp[id-1][j-val[id]]);
            }
        }
    }
    long long ans=0;
    for (int i=100000;i>=0;i--)
    {
        if (dp[n-1][i]<=w)
        {
            ans = i;
            break;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 81748
//#pragma warning(disable:4996)
//#pragma comment(linker, "/STACK:336777216")
//#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000000;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };

const int N=200005;

void solve()
{

    int n,m;
    cin>>n>>m;
    int s=0,x;
    for(int i=0;i<m;i++)
    {
        cin>>x;
        s+=x;
    }
    if(s>n)
    {
        cout<<-1<<endl;
    }
    else
        cout<<n-s<<endl;
}


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


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = a; i >= (b); --i)
#define trav(a, x) for(auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;



int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  
  int n, w; cin >> n >> w;

  vector<vector<ll> > dp(n + 1, vector<ll>(w + 1, 0));
  vector<ll> W(n), V(n);
  rep(i,0,n) 
    cin >>W[i] >> V[i];
  
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 1; j <= w; j++) {
      dp[i][j] = dp[i + 1][j];
      if (j - W[i] >= 0) {
        dp[i][j] = max(dp[i][j], dp[i + 1][j - W[i]] + V[i]);
      }
    }
  }
  cout << dp[0][w];
}

Measured memory_bytes: 83112
#include <bits/stdc++.h> // Tomasz Nowak
using namespace std;     // XIII LO Szczecin
using LL = long long;    // Poland
#define FOR(i, l, r) for(int i = (l); i <= (r); ++i)
#define REP(i, n) FOR(i, 0, (n) - 1)
template<class T> int size(T &&x) {
	return int(x.size());
}
template<class A, class B> ostream& operator<<(ostream &out, const pair<A, B> &p) {
	return out << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
	out << '{';
	for(auto it = x.begin(); it != x.end(); ++it)
		out << *it << (it == prev(x.end()) ? "" : ", ");
	return out << '}';
}
void dump() {}
template<class T, class... Args> void dump(T &&x, Args... args) {
	cerr << x << ";  ";
	dump(args...);
}
#ifdef DEBUG
  struct Nl{~Nl(){cerr << '\n';}};
# define debug(x...) cerr << (strcmp(#x, "") ? #x ":  " : ""), dump(x), Nl(), cerr << ""
#else
# define debug(...) 0 && cerr
#endif
mt19937_64 rng(0);
int rd(int l, int r) {
	return uniform_int_distribution<int>(l, r)(rng);
}
// end of templates

vector<LL> divisors(LL n) {
	vector<LL> ret;
	for(int i = 1; i * LL(i) <= n; ++i)
		if(n % i == 0) {
			ret.emplace_back(i);
			if(i * LL(i) != n)
				ret.emplace_back(n / i);
		}
	return ret;
}

bool try_k(LL n, LL k) {
	while(n % k == 0 and k != 1)
		n /= k;
	return (n - 1) % k == 0;
}

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

	LL n;
	cin >> n;
	set<LL> good;
	vector<LL> can1 = divisors(n), can2 = divisors(n - 1);
	for(LL k : can1)
		if(try_k(n, k))
			good.emplace(k);
	for(LL k : can2)
		if(try_k(n, k))
			good.emplace(k);
	debug(good);
	cout << (size(good) - 1) << '\n';
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll s, t = (ll)1e9; cin >> s;
    cout << "0 0 1 " << (s + t - 1LL) / t << " " << t << " " << (t - s % t) % t << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000009;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-4;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;

int main() {
	int x; cin >> x;
	if (x == 3 || x == 5 || x == 7)cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

struct C1 {
    ll M_{};
    ll D_{};
    explicit C1(ll M, ll D) : M_(M), D_(D) {}
    ll resolve() {
        ll count = 0;
        for(ll m = 1; m <= M_; ++m) {
            for(ll d = 22; d <= D_; ++d) {
                ll d1 = d % 10;
                ll d10 = d / 10;
                if (d1 <= 1) {
                   continue;
                }
                if  (d1 * d10 == m) {
                    count++;
                }
            }
        }
        return count;
    }
};

int main() {
    ll M, D;
    cin >>  M >> D;
    C1 c{M, D};
    cout << c.resolve() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <map>
#include <queue>
#include <bitset>

using namespace std;

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

	int* P = new int[N];
	for (int i = 0; i < N; i++) { cin >> P[i]; }

	set<int> st;
	for (int i = 0; i < K; i++) {
		st.insert(P[i]);
	}

	int count = 1;
	for (int i = K; i < N; i++) {
		if (*st.begin() != P[i - K]) {
			count++;
		}
		else {
			auto itr = st.end();
			itr--;
			if (*itr > P[i]) {
				count++;
			}
		}
		st.erase(P[i-K]);
		st.insert(P[i]);
	}

	bool* flag = new bool[N - 1];
	for (int i = 0; i < N - 1; i++) {
		flag[i] = (P[i] < P[i + 1]);
	}

	{
		int sum = 0;
		int k = 0;
		for (int i = 0; i < N; i++) {
			if (i == N - 1 || flag[i] == false) {
				if (k >= K - 1) {
					sum++;
				}
				k = 0;
			}
			else {
				k++;
			}
		}
		if (sum >= 2) {
			count -= sum - 1;
		}
	}
	
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, t;
    cin >> n >> t;
    vector<int> a(n), b(n);
    rep(i, n)cin >> a[i] >> b[i];
    vector<vector<int>> dp1(n+1, vector<int>(t+1, 0));
    vector<vector<int>> dp2(n+1, vector<int>(t+1, 0));
    rep(i, n){
        rep(j, t+1){
            if(j >= a[i]) dp1[i+1][j] = max(dp1[i][j-a[i]] + b[i], dp1[i][j]);
            else dp1[i+1][j] = dp1[i][j];
        }
    }
    reverse(all(a)); reverse(all(b));
    rep(i, n){
        rep(j, t+1){
            if(j >= a[i]) dp2[i+1][j] = max(dp2[i][j-a[i]] + b[i], dp2[i][j]);
            else dp2[i+1][j] = dp2[i][j];
        }
    }
    reverse(all(dp2));
    reverse(all(a)); reverse(all(b));
    int ans = 0;
    rep(i, n){
        rep(j, t){
            ans = max(ans, dp1[i][j] + dp2[i+1][t-j-1] + b[i]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 70912
/**
 * @author derrick20
 */
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] amt = new int[N];
        for (int i = 0; i < N; i++) {
            amt[i] = sc.nextInt();
        }

        boolean[] canWin = new boolean[K + 1];
        // canWin[x] stores whether this is a winning state or not

        canWin[0] = false; // Can't play = lose
        // Transition is trying all N steps and seeing if we can win from one
        // A winning state is one that can reach AT LEAST 1 losing state
        // A losing state is one that reaches ONLY winning states, or can't take any
        // O(K states * N per transition) = 10^7
        for (int stones = 1; stones <= K; stones++) {
            boolean poss = false;
            // We want to disprove the question of being a losing state,
            // just by finding one counterexample
            for (int take : amt) {
                if (take > stones) break;
                if (!canWin[stones - take]) {
                    // We can reach a losing state and set up the opponent
                    // for failure, so we win!
                    poss = true;
                    break;
                }
            }
            canWin[stones] = poss;
        }
        out.println(canWin[K] ? "First" : "Second");
        out.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        FastScanner(FileReader s) {
            br = new BufferedReader(s);
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        String nextLine() throws IOException { return br.readLine(); }

        double nextDouble() throws IOException { return Double.parseDouble(next()); }

        int nextInt() throws IOException { return Integer.parseInt(next()); }

        long nextLong() throws IOException { return Long.parseLong(next()); }
    }
}

Measured memory_bytes: 24020
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

#define MAX 100

using Weight = int;
struct Edge {
	int s; //source
	int d; //destination
	Weight w; //weight
	Edge(int s = 0, int d = 0, int w = INF) : s(s), d(d), w(w) {};
};
using Edges = vector<Edge>;
//???????????\???
//g[u].push_back(Edge(u, v, c));
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

//?????¢?´¢, ??¢?´¢???, ??¢?´¢???
enum { WHITE, GRAY, BLACK };

//???????§????????????? (Dijkstra)
//?????????: ??????????????§????????¢
vector<Weight> dijkstra(Graph g, int s) {
	typedef pair<Weight, int> State; //?§?????????????????°?????????? ??????id
	priority_queue<State, vector<State>, greater<State> >PQ;
	vector<int> color(g.size(), WHITE);
	vector<Weight> dist(g.size(), INF); //distance
	dist[s] = 0; PQ.push(State(0, s)); color[s] = GRAY; //?§????
	while (!PQ.empty()) {
		Weight d; int v;
		tie(d, v) = PQ.top(); PQ.pop(); //dist???????°??????¨??????????´????????????????	
		if (dist[v] < d) continue; //?????§???????????§???????????°??????
		color[v] = BLACK;
		for (auto e : g[v]) { //??£??\????????????????????¨????????????		
			if (color[e.d] == BLACK)continue; //??¢?´¢????????????
			if (dist[e.d] > dist[v] + e.w) {
				dist[e.d] = dist[v] + e.w;
				PQ.push(State(dist[e.d], e.d));
				color[e.d] = GRAY;
			}
		}
	}
	return dist;
}

int main() {
	int n; cin >> n;
	Graph g(n);
	for (int i = 0; i < n; i++) {
		int u, k; cin >> u >> k;
		for (int j = 0; j < k; j++) {
			int v, c; cin >> v >> c;
			g[u].push_back(Edge(u, v, c));
		}
	}
	vector<Weight> ans = dijkstra(g, 0);
	for (int i = 0; i < n; i++) {
		cout << i << " " << ans[i] << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
  string A,B,C; cin >> A >> B >> C;
  char x = A[0];
  while(true){
    if(x == 'a'){ 
      if(A.size() == 0){ cout << 'A'<< endl; return 0;}
       else{ x = A[0];A = A.substr(1,A.size() - 1);}}
         
    else if(x == 'b'){
      if(B.size() == 0){ cout << 'B' << endl; return 0;}
      else{x = B[0]; B = B.substr(1,B.size() - 1);}}
   
    else if( x == 'c'){
      if(C.size() == 0){ cout << 'C' << endl; return 0;}
      else{x = C[0]; C = C.substr(1,C.size() - 1);}}}

   }
      


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    string s;cin >> s;
    string ans = "NO";
    if(s == "AKIHABARA") ans = "YES";
    if(s == "AKIHABAR") ans = "YES";
    if(s == "AKIHABRA") ans = "YES";
    if(s == "AKIHABR") ans = "YES";
    if(s == "AKIHBARA") ans = "YES";
    if(s == "AKIHBAR") ans = "YES";
    if(s == "AKIHBRA") ans = "YES";
    if(s == "AKIHBR") ans = "YES";

    if(s == "KIHABARA") ans = "YES";
    if(s == "KIHABAR") ans = "YES";
    if(s == "KIHABRA") ans = "YES";
    if(s == "KIHABR") ans = "YES";
    if(s == "KIHBARA") ans = "YES";
    if(s == "KIHBAR") ans = "YES";
    if(s == "KIHBRA") ans = "YES";
    if(s == "KIHBR") ans = "YES";

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


Measured memory_bytes: 256
function Main(input) {
  var PQR = input
    .trim()
    .split(/\s/)
    .map(val => parseInt(val, 10));
  var P = PQR[0];
  var Q = PQR[1];
  var R = PQR[2];
  var sumAry = [];

  for(var i=0;i<PQR.length;i++){
    var copyAry = PQR.concat();
    copyAry.splice(i,1);

    for(var j=0;j<copyAry.length;j++){
      sumAry.push(PQR[i]+copyAry[j]);
    }
  }
  
  console.log(Math.min(...sumAry));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;
#define  ll  long long
#define f first
#define s second
#define matrix vector<vector<ll>>
#define zero(n,m) matrix(n , vector<ll>(m,0))
#define one(n,m) matrix(n , vector<ll>(m,1))
#define pii pair<ll,ll>
const int N = 2e5+5;

ll n , m , c;
vector<ll> adj[N];
bool vis[N];

void dfs(int node)
{
    vis[node] = 1 , c++;

    for(auto ch : adj[node])
    {
        if (!vis[ch]) dfs(ch);
    }
    return;
}

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

    cin >> n >> m;
    for(int i=1; i<=m; i++)
    {
        int x,y;
        cin >> x >> y;
        adj[x].push_back(y) , adj[y].push_back(x);
    }

    ll ans=0;
    for(int i=1; i<=n; i++)
    {
        if (!vis[i])
        {
            c=0;
            dfs(i);
            ans = max(ans , c);
        }
    }

    cout << ans << '\n';

    return 0;
}



Measured memory_bytes: 20872
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007


int s[110],n;
int main() {
	cin >> n;
	REP(I, n) {
		int a;
		cin >> a;
		s[a]++;
	}
	int ans = 0;
	REP(i, 110) {
		if (s[i] > 0)ans++;

	}
	cout << ans << endl;
}



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

int main()
{
	int A, B, ans = 0;

	cin >> A >> B;

	for (int a = A; a <= B; a++) {
		string s = to_string(a);
		int t = 1;

		for (int i = 0, k = s.size() - 1; i < s.size() && k >= 0; i++, k--) {
			if (s[i] != s[k]) {
				t = 0;
				break;
			}
		}

		ans += t;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sf1(n) scanf("%d",&n)
#define sf2(n,q) scanf("%d %d",&n,&q)
#define f first
#define ss second
#define pb push_back
#define lli long long
#define mem(ar,false) memset(ar,false,sizeof(ar))
#define mpr make_pair
#define endl "\n"
#define mod 1000000007
#define inf 9000000000000000000LL
using namespace std;

int ar[105][5];
int n,w;
lli dp[102][100005];
lli func(int i,int j)
{

    if(i==n || j==w)
        return 0LL;
    if(dp[i][j]!=-1)
        return dp[i][j];
    lli ret1 = 0 ,ret2 = 0;

    if(j+ar[i][1]<=w)
        ret1 = ar[i][2] + func(i+1,j+ar[i][1]);
    ret2 = func(i+1,j);
    return dp[i][j] = max(ret1,ret2);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    mem(dp,-1);
    cin >> n >> w ;
    for(int i=0; i<n; i++)
        cin >> ar[i][1] >> ar[i][2];


    lli ans = func(0,0);


    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 83304
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);


int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll H,W,K; cin>>H>>W>>K;
    //0:なし 1:イチゴ
    vector<vector<ll> > field(H+1,vector<ll>(W+1));
    vector<ll> row(H+1);
    ll cnt=0;
    rep1(i,H){
        string tmp; cin>>tmp;
        bool c=false;
        rep1(j,W){
            field[i][j]=((tmp[j-1]=='#')?1:0);
            if(field[i][j]==1) c=true;
        }
        
        if(c) cnt=i;
        row[i]=cnt;
    }
    rrep(i,H){
        if(row[i]==0) row[i]=row[i+1];
    }
    set<ll> se;
    rep1(i,H) se.insert(row[i]);
    
    /*
        3 . . . .   x }無視
        3 . . . .   x }無視
        3 # . # .   o }
        4 # # # .   o
        4 . . . .   x
        4 . . . .   x
     */
    
    vector<vector<ll> > ans(H+1,vector<ll>(W+1));
    ll now=1;
    for(auto x:se){
        //x行を決めていく
        bool c=true;
        rep1(i,W){
            if(field[x][i]==1){
                if(c){
                    c=false;
                    rep1(j,i-1){
                        ans[x][j]=now;
                    }
                    ans[x][i]=now;
                }
                else{
                    ans[x][i]=++now;
                }
            }
            else ans[x][i]=now;
        }
        now++;
    }
    rep1(i,H){
        rep1(j,W){
            ans[i][j]=ans[row[i]][j];
        }
    }
    
    rep1(i,H){
        rep1(j,W){
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }
}



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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

int expr(string& s,int& i);//テ・ツシツ?
//<expr>::=<term>[('+'|'-')<term>]
int term(string& s,int& i);//テゥツ??
//<term>::=<factor> [(テ「ツ??テ「ツ?處テ「ツ??テ「ツ??<factor>]*
int factor (string& s,int& i);//テ・ツ崢?ヲツ閉ー
//<factor>::=<number>|テ「ツ??テ「ツ??expr>テ「ツ??テ「ツ??
int number(string& s,int& i);//テヲツ閉ー
//<number>::=テ」ツ?ェテ」ツつ禿」ツ??

int number(string& s,int& i){
  int num = s[i]-'0';
  i++;
  while(isdigit(s[i])){
    num = num*10+s[i]-'0';
    i++;
  }
  return num;
}

int factor(string& s,int& i){
  if(isdigit(s[i])) return number(s,i);

  i++;
  int res=expr(s,i);
  i++;
  return res;
}

int term(string& s,int& i){
  int val1=factor(s,i);
  while(s[i]=='*'||s[i]=='/'){
    char op=s[i];
    i++;
    int val2=factor(s,i);
    if(op=='*'){
      val1 =val1*val2;
    }
    else{
      val1=val1/val2;
    }
  }
  return val1;
}

int expr(string& s,int& i){
  int val1=term(s,i);
  while(s[i]=='+'||s[i]=='-'){
    char op=s[i];
    i++;
    int val2=term(s,i);
    if(op=='+'){
      val1 =val1+val2;
    }
    else{
      val1=val1-val2;
    }
  }
  return val1;
}

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

  int n;
  cin >> n;
  for(int k=0;k<n;k++){
    string s;
    cin >> s;
    int i=0;
    cout << expr(s,i) << endl;
  }
}

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

int main(void){
    int n[3];
    scanf("%d%d%d",&n[0],&n[1],&n[2]);
    int temp = 0;
    for(int i = 0;i < 3;i++){
        for(int j = 0;j < 3;j++){
            if (i != j){
                int k = 2;
                if((i == 0 && j == 1) || (i == 1 && j == 0)){
                    k = 2;
                } else if((i == 0 && j == 2) || (i == 2 && j == 0)){
                    k = 1;
                } else {
                    k = 0;
                }

                if (((10 * n[i]) + n[j]) + n[k] > temp){
                    temp = ((10 * n[i]) + n[j] )+ n[k];
                }
            }
        }
    }
    printf("%d",temp);
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int var;
	static char[] str;
	static int pos;

	public static void main(String[] arg) {
		while (true) {
			str = sc.next().toCharArray();
			if (str[0] == '#') break;
			pos = 0;
			Formula l = parse();
			++pos;
			Formula r = parse();
			boolean res = true;
			for (var = 0; var < (1 << 11); ++var) {
				if (l.eval() != r.eval()) {
					res = false;
					break;
				}
			}
			System.out.println(res ? "YES" : "NO");
		}
	}

	static Formula parse() {
		char c = str[pos++];
		if (c == 'T') return new Constant(true);
		if (c == 'F') return new Constant(false);
		if ('a' <= c && c <= 'z') return new Var(c - 'a');
		if (c == '-') return new Not(parse());
		Formula l = parse();
		char op = str[pos++];
		if (op == '*') {
			Formula r = parse();
			++pos;
			return new And(l, r);
		} else if (op == '+') {
			Formula r = parse();
			++pos;
			return new Or(l, r);
		} else {
			++pos;
			Formula r = parse();
			++pos;
			return new Imp(l, r);
		}
	}

	static abstract class Formula {
		abstract boolean eval();
	}

	static class Constant extends Formula {
		boolean v;

		Constant(boolean v) {
			this.v = v;
		}

		boolean eval() {
			return this.v;
		}
	}

	static class Var extends Formula {
		int p;

		Var(int p) {
			this.p = p;
		}

		boolean eval() {
			return (var & (1 << p)) != 0;
		}
	}

	static class Not extends Formula {
		Formula f;

		Not(Formula f) {
			this.f = f;
		}

		boolean eval() {
			return !f.eval();
		}
	}

	static class And extends Formula {
		Formula left, right;

		And(Formula l, Formula r) {
			this.left = l;
			this.right = r;
		}

		boolean eval() {
			return left.eval() && right.eval();
		}
	}

	static class Or extends Formula {
		Formula left, right;

		Or(Formula l, Formula r) {
			this.left = l;
			this.right = r;
		}

		boolean eval() {
			return left.eval() || right.eval();
		}
	}

	static class Imp extends Formula {
		Formula left, right;

		Imp(Formula l, Formula r) {
			this.left = l;
			this.right = r;
		}

		boolean eval() {
			return !left.eval() || right.eval();
		}
	}

}

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

int x[222222], ord[222222], rnk[222222];

int main(){
    int n; scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",x+i);
    for(int i=0;i<n;i++) ord[i] = i;
    sort(ord,ord+n,[&](int i,int j){
        return x[i] < x[j];
    });

    for(int i=0;i<n;i++) rnk[ord[i]] = i;
    for(int i=0;i<n;i++){
        if(rnk[i] < n/2) printf("%d\n", x[ord[n/2]]);
        else printf("%d\n", x[ord[n/2-1]]);
    }
}


Measured memory_bytes: 4480
#include <iostream>
#include <climits>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>
#include <algorithm>

#define ll long long
#define pii pair<int, int>
#define pll pair<long, long>

using namespace std;

int main(){
	int n; cin >> n;
	vector<int> h(n); 

	for(int i = 0; i < n; i++){
		cin >> h[i];
	}	

	vector<int> dp(n);

	for(int i = n-2; i >= 0; i--){
		int costOneJump = i+1 < n ? abs(h[i+1] - h[i]) + dp[i+1] : INT_MAX;
		int costTwoJump = i+2 < n ? abs(h[i+2] - h[i]) + dp[i+2] : INT_MAX;

		dp[i] = min(costOneJump, costTwoJump);
	}

	cout << dp[0] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

using R = long double;
constexpr R pi = acos((R)-1), eps = 1e-10;

int sgn(R a) { return (a > eps) - (a < -eps); }
int sgn(R a, R b) { return sgn(a - b); }
using P = complex<R>;
istream& operator>>(istream& i, P& p) { R x, y; i >> x >> y; p = P(x, y); return i; }
ostream& operator<<(ostream& o, P p) { return o << fixed << setprecision(15) << real(p) << ' ' << imag(p); }
bool cmp(P p, P q) { return 2 * sgn(real(p), real(q)) + sgn(imag(p), imag(q)) < 0; }
bool eql(P p, P q) { return !cmp(p, q) and !cmp(q, p); }
R dot(P p, P q) { return real(conj(p) * q); }
R crs(P p, P q) { return imag(conj(p) * q); }
// -2: back, -1: cw, 0: on, 1: ccw, 2: front
int ccw(P p, P q) {
  int s = sgn(crs(p, q));
  if (s) return s;
  if (dot(p, q) < 0) return -2;
  if (dot(p, q - p) > 0) return 2;
  return 0;
}
int ccw(P o, P p, P q) { return ccw(p - o, q - o); }
struct L {
  P s, t;
  P vec() const { return t - s; }
  R abs() const { return std::abs(vec()); }
  R arg() const { return std::arg(vec()); }
};
int ccw(L s, P p) { return ccw(s.s, s.t, p); }

P proj(P p, L l) {
  P e = l.vec() / l.abs();
  return l.s + dot(p - l.s, e) * e;
}
P refl(P p, L l) { return (R)2 * proj(p, l) - p; }
R distPP(P p, P q) { return abs(q - p); }
R distPL(P p, L l) { return distPP(p, proj(p, l)); }
R distPS(P p, L s) {
  P q = proj(p, s);
  if (!ccw(s, q)) return distPP(p, q);
  return min(distPP(p, s.s), distPP(p, s.t));
}
R distLL(L l, L m) {
  if (sgn(crs(l.vec(), m.vec()))) return 0;
  return distPL(l.s, m);
}
R distLS(L l, L s) {
  if (ccw(l, s.s) * ccw(l, s.t) != 1) return 0;
  return min(distPL(s.s, l), distPL(s.t, l));
}
R distSS(L s, L t) {
  if (ccw(s, t.s) * ccw(s, t.t) <= 0 and ccw(t, s.s) * ccw(t, s.t) <= 0) return 0;
  return min({distPS(s.s, t), distPS(s.t, t), distPS(t.s, s), distPS(t.t, s)});
}
P intxn(L l, L m) {
  assert(sgn(crs(l.vec(), m.vec())));
  return l.s + crs(m.s - l.s, m.vec()) / crs(l.vec(), m.vec()) * l.vec();
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  while (true) {
    int n, si, ti; cin >> n >> si >> ti, --si, --ti;
    if (!n) break;
    VV<L> ss(n);
    for (int i = 0; i < n; ++i) {
      P o; cin >> o;
      R th; cin >> th, th = pi / 180 * (th + 90);
      R r; cin >> r;
      for (int j = 0; j < 5; ++j) {
        auto p = o + r * polar<R>(1, th + 0.4 * pi * j);
        auto q = o + r * polar<R>(1, th + 0.4 * pi * (j + 2));
        ss[i].emplace_back(L{p, q});
      }
    }
    VV<R> d(n, V<R>(n, 1e10));
    for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) {
      for (int ki = 0; ki < 5; ++ki) for (int kj = 0; kj < 5; ++kj) {
        d[i][j] = min(d[i][j], distSS(ss[i][ki], ss[j][kj]));
      }
    }
    for (int k = 0; k < n; ++k) for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) {
      d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
    cout << fixed << setprecision(15) << d[si][ti] << '\n';
  }
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

vector<int>G[100050];
ll h[100050];
bool dfs(int v,int p=-1){
  for(int nv:G[v]){
    if(nv==p)continue;
    if(h[nv]>=h[v])return false;
    return true;
  }
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll x;
  cin >> x;
  exrep(a,-2000,2000){
    exrep(b,-2000,2000){
      if(pow(a,5)-pow(b,5)==x){
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return 0;     
}


Measured memory_bytes: 6556
grid = []
F = dict()
for i in range(3):
    row = [int(s) for s in input().split()]
    for j in range(3):
        F[row[j]] = [i, j]
    grid.append(row)
N = int(input())
for i in range(N):
    num = int(input())
    if num in F:
        grid[F[num][0]][F[num][1]] = -1

found = False
for i in range(3):
    if grid[i][0] == -1 and grid[i][1] == -1 and grid[i][2] == -1:
        print("Yes")
        found = True
        break
if not found:
    for j in range(3):
        if grid[0][j] == -1 and grid[1][j] == -1 and grid[2][j] == -1:
            print("Yes")
            found = True
            break
if not found:
    if grid[0][0] == -1 and grid[1][1] == -1 and grid[2][2] == -1:
        print("Yes")
        found = True
if not found:
    if grid[0][2] == -1 and grid[1][1] == -1 and grid[2][0] == -1:
        print("Yes")
        found = True
if not found:
    print("No")


Measured memory_bytes: 3064
import sys
s = input()
n = len(s)
if n % 2 == 1:
    if s == s[::-1]:
        if s[:(n-1)//2] == s[:(n-1)//2][::-1]:
            if s[(n+1)//2:] == s[(n+1)//2:][::-1]:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3064
N=int(input())
print(0)
a=input()
m=-1
if a=="Vacant":
  exit()
elif a=="Male":
  m=0
elif a=="Female":
  m=1
l,r=1,N-1
while r-l>1:
  mid=(l+r)//2
  print(mid)
  a=input()
  if a=="Vacant":
    exit()
  elif a=="Male" and (mid-m)%2==0:
    l=mid
  elif a=="Female" and (mid-m)%2==1:
    l=mid
  else:
    r=mid
print(l)
if input()=="Vacant":
  exit()
print(r)
if input()=="Vacant":
  exit()

Measured memory_bytes: 38852
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
#define enl << endl
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*(b/gcd(a, b)); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n;
    unsigned long long t, res;

    cin >> n;
    rep(i, n){
        cin >> t;
        if(i == 0){
            res = t;
            continue;
        }
        res = lcm(res, t);
    }

    cout << res << endl;

    return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1000000007;

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,c,k;
	cin >> n >> c >> k;
	int cnt = 0,sum = 0,now = 0;
	int tmp = 0;
	bool flg = true;
	vector<int> t(n);
	rep(i,n){
		cin >> t[i];
	}
	sort(all(t));
	rep(i,n){
		if(cnt == c){
			sum++;
			cnt = 0;
			flg = true;
		}
		if(flg){
			tmp = t[i];
			now = t[i];
			++cnt;
			flg = false;
		}
		else{
			now = t[i];
			if(now - tmp > k){
				sum++;
				cnt = 0;
				tmp = t[i];
			}
			++cnt;
		}
	}
	cout << sum + (cnt + 1000000 - 1) / 1000000 << '\n';
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
map<ll, int>cnt;
int main(){
	fast;
	int n; cin>>n;
	long long ans=0ll;
	for(int i=1; i<=n; i++){
		int x; cin>>x;
		ans+=cnt[i-x];
		cnt[i+x]++;
	}
	cout<<ans<<endl; return 0;
}

Measured memory_bytes: 26400
#include<iostream>
#include<math.h>
using namespace std;
int main() {
	int n,x;
	int count=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x;
			if (int(sqrt(x)) != 1) {
				for (int j = 2; j < sqrt(x); j++) {
					if (x%j == 0) {
						break;
					}
					if (j == int(sqrt(x)))count++;
				}
			}
			else count++;
	}
	cout << count << endl;
}


Measured memory_bytes: 3080
#include <set>
#include <queue>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

int n,m,c,d,ans[1010][1010],cnt1[1010],cnt2[1010],opt = 0;

void solve(){
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(cnt2[j] && cnt1[i]){
				ans[i][j] = 1;
				cnt2[j]--;
				cnt1[i]--;
			}else{
				ans[i][j] = 0;
			}
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++)cout<<ans[i][j];
		cout<<endl;
	}
}

int main() {
	read(n);read(m);read(c);read(d);
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			if(i*c+(n-i)*(m-c) == j*d+(m-j)*(n-d)){
				for(int k=0;k<n;k++){
					if(k<i) cnt1[k] = c;
					else cnt1[k] = m-c;
				}
				for(int k=0;k<m;k++){
					if(k<j) cnt2[k] = d;
					else cnt2[k] = n-d;
				}
				solve();
				return 0;
			}
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 5120
N, A, B = list(map(int, input().split()))

diff = B - A

if diff % 2 == 0:
    ans = diff // 2
else:
    # 左端で会う
    d1 = A - 1  # Aが左に到達するまでにd戦する
    ans1 = d1 + (diff + 1) // 2

    # 右端で会う
    d2 = N - B  # Bが右端まで到達するのにd戦必要
    ans2 = d2 + (diff + 1) // 2

    ans = min(ans1, ans2)

print(ans)


Measured memory_bytes: 3060
s = input()
i = 0
start = 0
pre = ""
ans = 0
while i < len(s):
    if i < len(s) and s[start: i + 1] != pre:
        pre = s[start: i + 1]
        start = i + 1
        ans += 1
    i += 1
print(ans)


Measured memory_bytes: 3500
import sys;sys.setrecursionlimit(10**9)
class UnionFind:
  def __init__(self,n):
    self.n=[-1]*n
    self.r=[0]*n
    self.siz=n
  def find_root(self,x):
    if self.n[x]<0:
      return x
    else:
      self.n[x]=self.find_root(self.n[x])
      return self.n[x]
  def unite(self,x,y):
    x=self.find_root(x)
    y=self.find_root(y)
    if x==y:return
    elif self.r[x]>self.r[y]:
      self.n[x]+=self.n[y]
      self.n[y]=x
    else:
      self.n[y]+=self.n[x]
      self.n[x]=y
      if self.r[x]==self.r[y]:
        self.r[y]+=1
    self.siz-=1
  def root_same(self,x,y):
    return self.find_root(x)==self.find_root(y)
  def count(self,x):
    return -self.n[self.find_root(x)]
  def size(self):
    return self.siz

n,m=map(int,input().split())
uf=UnionFind(n)
for i in range(m):
  x,y,z=map(int,input().split())
  uf.unite(x-1,y-1)
print(uf.size())

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<set<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

// int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const int INF = 100000000;


int n, m, q;
ll ans = 0;
vector<int> a, b, c, d;



int main() {

  int X, Y;
  cin >> X >> Y;
  cout << X + Y/2;


}


/*
みんな、くるくるぱーにな〜れ
　∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/


Measured memory_bytes: 256
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI 3.14159265358979323846264338327950L

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define int long long
#define Graph vector<vector<int> >
#define PII pair<int,int>
#define VI vector<int>
#define VVI vecotor<vector<int> >
#define VPII vector<pair<int,int> >

template<typename A, size_t N, typename T>

void Fill(A (&array)[N], const T &val) {
	std::fill( (T*)array, (T*)(array + N), val );
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここにグローバル変数宣言
int H, W, sh, sw, gh, gw;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};//BFS関連







//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数宣言
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}










//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main() {
	//入力の高速化用のコード
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	int N;
	cin>>N;
	VI A(N+1,0);
	FOR(i,2,N){
		int j;
		cin>>j;
		A[j]++;
	}
	FOR(i,1,N){cout<<A[i]<<endl;}


	return 0;

}







Measured memory_bytes: 4784
package main

import (
	"bufio"
		"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	dp := make([]int , 30)
	dp[0] = 1 // 1段の階段の登り方
	dp[1] = 2 // 2段の階段の登り方
	dp[2] = 4 // 3段の階段の登り方
	for i := 3; i < 30; i++ {
		// n段の階段の登り方は
		// n-1段の階段の登り方+n-2段の階段の登り方+n-3段の階段の登り方
		dp[i] = dp[i-1]+dp[i-2]+dp[i-3] 
	}
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}
		fmt.Println(((dp[n-1]+9)/10+364)/365)
	}
}



Measured memory_bytes: 1084
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        Console.ReadLine();
        var input = Console.ReadLine().Split(' ');

        var hash = new HashSet<int>();

        foreach (var n in input) 
        {
            if (!hash.Add(int.Parse(n)))
            {
                Console.WriteLine("NO");
                return;
            }
        }
        Console.WriteLine("YES");
        Console.ReadLine();
        return;
    }
}


Measured memory_bytes: 33360
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <string>
#include <set>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
	int A;
	int B;
	int C;
	int X;
	cin >> A >> B >> C >> X;
	int ans = 0;
	for (int a = 0; a * 500 <= X && a <= A; a++) {
		for (int b = 0; a * 500 + b * 100 <= X && b <= B; b++) {
			if ((X - a * 500 - b * 100) % 50 == 0 && (X - a * 500 - b * 100) / 50 <= C)
				ans++;
		}
	}

	cout << ans;

	return 0;
}



Measured memory_bytes: 256