akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}




int main(){
    int n,m; cin >> n >> m;
    vector<vector<Pll>> graph(n);
    ll INF = INT_MAX;
    vector<ll> dp(n,INF);
    rep(i,m){
        ll l,r; cin >> l >> r;
        ll c; cin >> c;
        l--;r--;
        graph[l].emplace_back(Pll(r,c));
    }
    dp[0] = 0;
    // ll mi = INF;
    bool ok = true;
    priority_queue<Pll, vector<Pll>, greater<Pll> > pq;
    rep(i,n){
        Pll temp = Pll(INF, -1);
        if(pq.size() > 0)temp = pq.top();
        while(temp.second < i && pq.size() > 0){
            pq.pop();
            temp = pq.top();
        }
        // print(i,temp.first,temp.second);
        // print(dp);
        if(i == 0 || temp.second >= i)dp[i] = temp.first;
        else{
            ok = false;
            break;
        }
        if(i == 0)dp[i] = 0;
        for(auto j : graph[i]){
            // dp[j.first] = min(dp[j.first], dp[i] + j.second);
            pq.push(Pll(dp[i] + j.second,j.first));
        }
    }
    // print(dp);
    cout << (ok ? dp[n-1] : -1) << endl;
}

Measured memory_bytes: 7800
#include<iostream>
#include<vector>

using namespace std;

int n, m;
vector<vector<int> > path(8);

int solve(int x,vector<int> ls) {
	int ans = 0;
	int flag = 1;
	vector<int> lsls(8, 0);
	for (int j = 0; j < n; j++) {
		lsls[j] = ls[j];
	}
	lsls[x] = 1;
	for (int i = 0; i < n; i++)
		flag*=lsls[i];
	if (flag == 1)
		return 1;
	for (int i = 0; i < path[x].size(); i++) {
		if (ls[path[x][i]] == 0) {
			ans += solve(path[x][i], lsls);
		}
	}
	return ans;
}

int main() {
	vector<int> list(8,0);
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		path[a-1].push_back(b-1);
		path[b-1].push_back(a-1);
	}
	list[0] = 1;
	cout << solve(0, list) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}
static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}

#define POS(i, j) ((i) * (m + 1) + (j))

i32 find (i32 a, i32 b, i32 c, i32 d, i32 *dp, i32 m) {
  return dp[POS(c, d)] - dp[POS(c, b - 1)] - dp[POS(a - 1, d)] + dp[POS(a - 1, b - 1)];
}

void run (void) {
  i32 n = read_int();
  i32 m = read_int();
  i32 q = read_int();
  i32 *v = (i32 *) calloc ((n + 1) * (m + 1), sizeof (i32));
  i32 *ex = (i32 *) calloc ((n + 1) * (m + 1), sizeof (i32));
  i32 *ey = (i32 *) calloc ((n + 1) * (m + 1), sizeof (i32));
  for (i32 i = 1; i <= n; ++i) {
    for (i32 j = 1; j <= m; ++j) {
      v[POS(i, j)] = getchar() - '0';
      ex[POS(i, j)] = v[POS(i, j)] & v[POS(i - 1, j)];
      ey[POS(i, j)] = v[POS(i, j)] & v[POS(i, j - 1)];
    }
    getchar();
  }
  for (i32 i = 1; i <= n; ++i) {
    for (i32 j = 1; j <= m; ++j) {
      v[POS(i, j)] += v[POS(i - 1, j)] + v[POS(i, j - 1)] - v[POS(i - 1, j - 1)];
      ex[POS(i, j)] += ex[POS(i - 1, j)] + ex[POS(i, j - 1)] - ex[POS(i - 1, j - 1)];
      ey[POS(i, j)] += ey[POS(i - 1, j)] + ey[POS(i, j - 1)] - ey[POS(i - 1, j - 1)];
    }
  }
  while (q--) {
    i32 a = read_int();
    i32 b = read_int();
    i32 c = read_int();
    i32 d = read_int();
    i32 ans = find (a, b, c, d, v, m) - find (a + 1, b, c, d, ex, m) - find (a, b + 1, c, d, ey, m);
    print_int (ans);
    putchar ('\n');
  }
}

int main (void) {
  run();
  return 0;
}


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

int main(void){
    string n;
    cin >> n;
    
    for(int i = 0; i < n.size(); i++){
        if(n[i] == n[i+1]){
            cout << "Bad" << endl;
            return 0;
        }
    }

    cout << "Good" << endl;
    return 0;
}

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#else
#define db(...) true
#endif
template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c; return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;

int n, m;

int main() {
	#ifdef LOCAL
	auto stTime = clock();
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	cin >> n >> m;
	vii ba(n);
	for (int i = 0; i < n; ++i) {
		cin >> ba[i].sc >> ba[i].fs;
	}
	sort(ba.rbegin(), ba.rend());
	db(ba);
	si s;
	for (int i = 0; i <= m; ++i) {
		s.insert(i);
	}
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		if (!sz(s))
			break;
		auto it = s.lower_bound(m - ba[i].sc);
		if (it == s.end())
			--it;
		db(*it);
		if (*it > m - ba[i].sc && it != s.begin())
			--it;
		if (*it <= m - ba[i].sc)
			ans += ba[i].fs, s.erase(it);
		db(s);
	}
	cout << ans << '\n';
	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms\n";
	#endif
    return 0;
}


Measured memory_bytes: 5760
#include <stdio.h>

int main (void) {
    
    int x, y;

    for (;;) {
        scanf ("%d %d", &x, &y);
        if (x==0 && y==0) break;
        if (x < y) printf ("%d %d\n", x, y);
        else printf ("%d %d\n", y, x);
    }
    
    return 0;
}


Measured memory_bytes: 1976
#include <stdio.h>
int main()
{
  int H,W,i, j;
  while(1)
    {
      scanf("%d %d",&H,&W);
      if(H==0 && W==0)break;
      
      for ( i = 0; i < H; i++ ){
	for ( j = 0; j < W; j++ ){
	  if((i+j)%2==1){
            printf(".");
	  } else {
            printf("#");
	  }
	}
	printf("\n");
      }
      printf("\n");
    }
  
  return 0;
}

Measured memory_bytes: 572
from itertools import permutations

N, M, R = map(int, input().split())
r = list(map(int, input().split()))
ARSP = [[float('inf')] * (N+1) for i in range(N+1)]
for i in range(M):
    a, b, c = map(int, input().split())
    ARSP[a][b] = c
    ARSP[b][a] = c


def warshall_floyd(adj_array):
    for k in range(len(adj_array)):
        for i in range(len(adj_array)):
            for j in range(len(adj_array)):
                if adj_array[i][k] + adj_array[k][j] < adj_array[i][j]:
                    adj_array[i][j] = min(adj_array[i][j], adj_array[i][k] + adj_array[k][j])
    return adj_array


ARSP = warshall_floyd(ARSP)

# 訪れ方の全列挙(max 8! = 40320)
journey = list(permutations(r))

ans = float('inf')
for j in journey:
    cost = 0
    for i in range(1, R):
        if ARSP[j[i]][j[i-1]] == float('inf'):
            break
        cost += ARSP[j[i]][j[i-1]]
        if cost >= ans:
            break
    else:
        ans = cost

print(ans)

Measured memory_bytes: 9696
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(void){
  int num = 0;
  int num1=0;
  int i = 0;
  
  int ten = 10;
  int NUM[10] ={0};
  
  
  scanf("%d",&num);
  num1 = num;
  
  for (i=0;;i++){
  NUM[i] = num % ten; 
  num = num/10;
//  ten = ten * 10;
//  printf("%d\n",NUM[i]);
  if(num == 0) break;
  }
  
  int sum = 0;
  for (i = 0;i<10;i++)
		sum += NUM[i];
  
 // printf("%d",sum);
  
  if(num1 % sum == 0) printf("Yes");
  else printf("No");
  
  return 0;
  
//	  
  
}

Measured memory_bytes: 128
N, M, X = map(int, input().split())
A_list = list(map(int, input().split()))
min1 = 10000
cnt = 0
for i in range(X-1, 0, -1):
    for j in range(len(A_list)):
        if A_list[j] == i:
            cnt+=1
if cnt < min1:
    min1 = cnt
cnt= 0
for i in range(X+1, N):
    for j in range(len(A_list)):
        if A_list[j] == i:
            cnt+=1
if cnt < min1:
    min1 = cnt
print(min1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000
#define infll 1000000000000000000ll
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define mpr make_pair
#define fi first
#define se second
#define pq priority_queue<int>
#define pqll priority_queue<ll>
#define up(x,y) (x<(y)?x=(y):0)
#define dn(x,y) (x>(y)?x=(y):0)
#define ad(x,y) (x=(x+(y))%mod)
#define mod 1000000007
#define N 2000009
using namespace std;

int n,x,y,num[N];
void solve(int n,int x,int y){
	if (num[n]==1){ printf("%d %d ",x,y); return; }
	int i,j;
	for (i=0; ; i++) if ((n>>i&1) && ((x^y)>>i&1)){
		n^=1<<i;
		for (j=n; j; j&=j-1){
			if ((x^j^1<<i)!=y && (num[j]&1)){
				solve(n,x,x^j);
				solve(n,x^j^1<<i,y);
				return;	
			}
		}
		n^=1<<i;
	}
}
int main(){
	scanf("%d%d%d",&n,&x,&y);
	int k=x^y,tmp=0;
	for (; k; k^=k&-k) tmp++;
	if (!(tmp&1)){ puts("NO"); return 0; }
	puts("YES");
	int i;
	for (i=1; i<(1<<n); i++) num[i]=num[i&i-1]+1;
	solve((1<<n)-1,x,y); puts("");
	return 0;
}


Measured memory_bytes: 1536
#include "bits/stdc++.h"
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
#define ri register int
#define Max(x, y) (((x) > (y)) ? (x) : (y))
#define Min(x, y) (((x) < (y)) ? (x) : (y))
#define Abs(x) ((x) < 0 ? (-(x)) : (x))
#define int long long
const int maxn = 1e3 + 10;
inline int read()
{
    int f = 1, r = 0;
    char c = getchar();
    while (!isdigit(c)) {
        if (c == '-') {
            f = -1;
        }
        c = getchar();
    }
    while (isdigit(c)) {
        r = 10 * r + c - '0';
        c = getchar();
    }
    return f * r;
}
inline void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline void writesp(int x) { write(x), putchar(' '); }
inline void writeln(int x) { write(x), puts(""); }
int N, A, arr[maxn], f[55][55][55 * 55];
signed main()
{
    N = read(), A = read();
    int sum = 0;
    for (ri i = 1; i <= N; ++i) {
        arr[i] = read();
        sum += arr[i];
    }
    for (ri i = 0; i <= N; ++i) {
        f[i][0][0] = 1;
    }
    for (ri i = 1; i <= N; ++i) {
        for (ri j = 1; j <= N; ++j) {
            for (ri k = 1; k <= sum; ++k) {
                f[i][j][k] += f[i - 1][j][k];
                if (k >= arr[i]) {
                    f[i][j][k] += f[i - 1][j - 1][k - arr[i]];
                }
            }
        }
    }
    int ans = 0;
    for (ri i = 1; i <= N; ++i) {
        ans += f[N][i][i * A];
    }
    writeln(ans);
    return 0;
}

Measured memory_bytes: 66560
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
   FAST/**/
   
   ld n;
   cin>>n;
   
   ll ans = ceil(n/1.08);
   ll temp = (ld)ans*1.08;
   if(temp!=n)
       cout<<":(";
   
   else cout<<ans;
   
   return 0;
}  
   

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <random>
#include <chrono>
using namespace std;

int N, Q;

typedef long long LL;

int A, B;
const int maxn = 2e5 + 5;
int x[maxn];

LL maxv[3][maxn << 2], addv[maxn << 2];
const LL INF = 1e12;

#define lson o*2,l,mid
#define rson o*2+1,mid+1,r

void pushup(int o){
    for(int i = 0;i < 3;i++){
        maxv[i][o] = min(maxv[i][o*2], maxv[i][o*2+1]);
    }
}

void pushdown(int o){
    if(addv[o]){
        addv[o*2] += addv[o];
        addv[o*2+1] += addv[o];
        for(int i = 0;i < 3;i++){
            maxv[i][o*2] += addv[o];
            maxv[i][o*2+1] += addv[o];
        }
        addv[o] = 0;
    }
}

void build(int o, int l, int r){
    addv[o] = 0;
    if(l == r){
        maxv[0][o] = INF - l;
        maxv[1][o] = INF;
        maxv[2][o] = INF + l;
        return;
    }
    int mid = (l + r) / 2;
    build(lson);
    build(rson);
    pushup(o);
}

void update(int o, int l, int r, int ql, int qr, LL v){
    if(ql <= l && r <= qr){
        for(int i = 0;i < 3;i++){
            maxv[i][o] += v;
        }
        addv[o] += v;
        return;
    }
    int mid = (l + r) / 2;
    pushdown(o);
    if(ql <= mid)
        update(lson, ql, qr, v);
    if(qr > mid)
        update(rson, ql, qr, v);
    pushup(o);
}

LL querymax(int o, int l, int r, int ql, int qr, int id){
    if(ql <= l && r <= qr){
        return maxv[id][o];
    }
    int mid = (l + r) / 2;
    pushdown(o);
    if(qr <= mid)
        return querymax(lson, ql, qr, id);
    if(ql > mid)
        return querymax(rson, ql, qr, id);
    return min(querymax(lson, ql, qr, id), querymax(rson, ql, qr, id));
}

void Set(int p, LL v){
    LL tmp = querymax(1, 1, N, p, p, 1);
    LL delta = v - tmp;
    update(1, 1, N, p, p, delta);
}

int main(){
    cin >> N >> Q >> A >> B;
    build(1, 1, N);
    int pre = A;
    Set(B, 0); 
    for(int i = 1;i <= Q;i++){
        int x;
        scanf("%d", &x);
        LL val1 = querymax(1, 1, N, 1, x, 0);
        LL val2 = querymax(1, 1, N, x, N, 2);
        LL val = min(x + val1, val2 - x);
        //cout << val << endl;
        LL delta = abs(x - pre);
        update(1, 1, N, 1, N, delta);
        Set(pre, val);
        pre = x;
    } 
    cout << querymax(1, 1, N, 1, N, 1) << endl;
    return 0;
}


Measured memory_bytes: 24064
/*      ░░█ ▄▀█ █   █▀ █░█ █▀█ █▀▀ █▀▀   █▀█ ▄▀█ █▀▄▀█
        █▄█ █▀█ █   ▄█ █▀█ █▀▄ ██▄ ██▄   █▀▄ █▀█ █░▀░█     */

// Author : Udit "luctivud" Gupta @ (https://www.linkedin.com/in/udit-gupta-1b7863135/)


#include <bits/stdc++.h>
#pragma GCC optimize "trapv"

using namespace std;

typedef long long int lld;
typedef unsigned long long int llu;


#define       TESTCASES()  cin >> (T3X0); T353 = T3X0; while(T3X0--)
#define       _input(V3C)  for(auto &V3C_I7 : (V3C)) cin >> (V3C_I7)
#define mems(A77AY, V4LU)  memset((A77AY), (V4LU), sizeof((A77AY)))
#define  CH3K(I7, E4, S7)  (((S7)<0) ? (I7)>(E4) : (I7)<(E4))
#define for4(I7,S4,E4,S7)  for(auto I7=(S4); CH3K(I7,E4,S7); (I7)+=(S7))




void solveEachTest(lld T35TC453N = 1) {

	lld n, m; cin >> n >> m ;
	vector <lld> arr(n+1, 0ll);

	for4 (i, 0ll, m , 1ll) {
		lld a, b; cin >> a >> b;
		arr[a]++; arr[b]++;
	}

	for4(i, 1ll, n+1ll, 1ll) {
		cout << arr[i] << "\n";
	}
	return;
}


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

	lld T3X0 = 0, T353 = 1;

	// TESTCASES()
	solveEachTest(T353 - T3X0);
	return 0;
}
// Random Thought :  null

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

int count(const int n, const int m) {
	std::vector<std::vector<int>> count(2, std::vector<int>(m + 1, 0));
	count[0][0] = n;
	int result = 0;
	while (count[result % 2][m] == 0) {
		for (auto& c : count[(result + 1) % 2]) c = 0;
		for (auto i = 0; i < m; ++i) {
			count[(result + 1) % 2][i + 1] += count[result % 2][i] / 2;
			count[(result + 1) % 2][0] += count[result % 2][i] / 2;
			count[(result + 1) % 2][i] += count[result % 2][i] % 2;
		}
		++result;
	}
	return result;
}
int main() {
	std::cin.tie(0); std::cin.sync_with_stdio(false);
	std::vector<std::vector<int>> result(21, std::vector<int>(21));
	for (auto i = 2; i <= 20; ++i) {
		for (auto j = 1; j < i; ++j) {
			result[i][j] = count(i, j);
		}
	}
	for (auto t = 1;true; ++t) {
		int n, m; std::cin >> n >> m; if (n == 0 && m == 0) break;
		std::cout << "Case " << t << ": " << result[n][m] << '\n';
	}
}



Measured memory_bytes: 3144
fn read_ls<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main(){
    let mut lst : Vec<i32> = read_ls();
    lst.sort();
    println!("{} {} {}", lst[0], lst[1], lst[2]);
}



Measured memory_bytes: 5028
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
vector<bool>is_prime(100005, true);
ll factors(ll n){
    ll c=0;
    if(n%2==0) ++c;
    while(n%2==0){
        n/=2;
    }
    for(ll i=3;i*i<=n;++i){
        if(n%i==0)
            ++c;
        while(n%i==0) n/=i;
    }
    if(n!=1) ++c;
    return c;
}
int main()
{
    fastio;
    ll n=0,m=0;
    cin>>n>>m;
    ll g=__gcd(m,n);
    cout<<factors(g)+1;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
T = []

for i in range(n):
    t = [x for x in input().split()]
    t[0] = int(t[0])
    t[1] = int(t[1])
    t[3] = int(t[3])
    T.append(t)

T.sort()

for t in T:
    print(' '.join(str(x) for x in t))



Measured memory_bytes: 35320
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define int long long
    #define lb long double
    #define f(i,a,b) for(int i=a;i<=b;i++)
    #define fd(i,a,b) for(int i=a;i>=b;i--)
    #define vi vector<int>
    #define mii map<int,int>
    #define pii pair<int,int>
    #define si set<int>
    #define pb push_back
    #define mk make_pair
    #define fi first
    #define se second
    #define fv(i,v) for(auto i=v.begin();i!=v.end();++i)
    #define fdv(i,v) for(auto i=v.rbegin();i!=v.rend();++i)
    #define print(a,n) f(i,1,n) cout<<a[i]<<" "; cout<<endl;
    #define printv(v) for(auto iv: v) cout<<iv<<" "; cout<<endl;
    #define all(v) v.begin(),v.end()
    #define r(a,n) ll a[n+1]; f(i,1,n) cin>>a[i];
    #define pi 3.141592653589793238
    const int mod=998244353;
    const int inf=1e18;
    //bool vis[1000+1]={};
    const int MAXN=1e5+1;
    int spf[MAXN];
    map<pii,int> m1,m2;

    ll power(ll x, unsigned ll y)
    {
        ll res = 1;
        while (y > 0)
        {
            if (y & 1)
                res = res*x;
            y = y>>1;
            x = x*x;
        }
        return res;
    }

    bool isPrime(int n)
    {
        if (n <= 1)
            return false;
        if (n <= 3)
            return true;

        if (n % 2 == 0 || n % 3 == 0)
            return false;

        for (int i = 5; i * i <= n; i = i + 6)
            if (n % i == 0 || n % (i + 2) == 0)
                return false;

        return true;
    }
        void sieve()
    {
        spf[1] = 1;
        for (int i=2; i<MAXN; i++)
            spf[i] = i;
        for (int i=4; i<MAXN; i+=2)
            spf[i] = 2;
        for (int i=3; i*i<MAXN; i++)
        {
            if (spf[i] == i)
            {
                for (int j=i*i; j<MAXN; j+=i)
                    if (spf[j]==j)
                        spf[j] = i;
            }
        }
    }

    int lcm(int a, int b)
    {
        return (a*b)/__gcd(a,b);
    }
    signed main()
    {
        int t=1;
        //cin>>t;
        while(t--)
        {
            int x[5];
            f(i,0,4)
            cin>>x[i];
            f(i,0,4)
            if(x[i]==0){cout<<i+1<<endl;break;}
        }
    }


Measured memory_bytes: 3520
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

int main(void) {
	int n,m; cin >> n >> m;
	if(m==0){
		if(n==1){
			cout << 0;
		}else{
			cout << 1;
			rep(i,n-1) cout << 0;
		}
		cout << endl;
		return 0;
	}
	vp sc(m);
	rep(i,m){
		int s,c; cin >> s >> c;
		s--;
		sc[i].fi = s;
		sc[i].se = c;
	}
	SORT(sc);
	rep(i,m-1){
		if(sc[i].fi==sc[i+1].fi){
			if(sc[i].se!=sc[i+1].se){
				cout << -1 << endl;
				return 0;
			}
		}
	}
	vi ans(n,0);
	rep(i,m) ans[sc[i].fi] = sc[i].se;
	if(sc[0].fi==0&&sc[0].se==0){
		if(n==1){
			cout << 0 << endl;
			return 0;
		}else{
			cout << -1 << endl;
			return 0;				
		}
	}
	if(ans[0]==0) ans[0]=1;
	rep(i,n) cout << ans[i];
	cout << endl;
}




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

int main() {

  string a,b ;
  cin >> a >> b ; 
  //cout << a+b << endl ;
  //std::printf("%s",b.c_str());
  //cout << stoi(a+b) << endl ;
  int tmp = stoi(a+b) ;
  int tmp2 = sqrt(tmp) ;

  if(tmp2*tmp2==tmp)
   printf("%s\n","Yes") ;
  else
   printf("%s\n","No") ;
  
 return 0 ;
}  


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <vector>

using namespace std;
int ans;
int n;
string ID;
vector<int> a;
int aster_count;
bool isEven[8];

void DFS(int pos, int sum)
{
	if(pos == aster_count)
	{
		if(sum % 10 == 0)
		{
			++ans;
		}
		return;
	}
	for(int i = 0; i < a.size(); ++i)
	{
		int sum2 = sum;
		if(isEven[pos])
		{
			if(2 * a[i] < 10)
			{
				sum2 += 2 * a[i];
			}
			else
			{
				sum2 += (2 * a[i]) % 10 + 1;
			}
			DFS(pos + 1, sum2);
		}
		else
		{
			sum2 += (a[i]);
			DFS(pos + 1, sum2);
		}
	}
}

void solve()
{
	cin >> n;
	cin >> ID;
	int m;
	cin >> m;
	for(int i = 0; i < m; ++i)
	{
		int input;
		cin >> input;
		a.push_back(input);
	}
	memset(isEven, 0, sizeof(isEven));
	int sum = 0;
	bool multiple_flag = false;
	for(int i = ID.size() - 1; i >= 0; --i)
	{
		if(ID[i] != '*')
		{
			if(multiple_flag)
			{
				int t = 2 * (ID[i] - '0');
				if(t < 10)
				{
					sum += t;
				}
				else
				{
					sum += t % 10 + 1;
				}
			}
			else
			{
				sum += (ID[i] - '0');
			}
		}
		else
		{
			if(multiple_flag)
			{
				isEven[aster_count] = true;
			}
			else
			{
				isEven[aster_count] = false;
			}
			++aster_count;
		}
		multiple_flag = !multiple_flag;
	}
	DFS(0, sum);	
	cout << ans << endl;
}

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

Measured memory_bytes: 1356
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, l; cin >> n >> l;
    ll res = 0;
    ll mn = INF;
    rep(i, n){
        res += l + i;
        chmin(mn, abs(l + i));
    }
    cout << (abs(res - mn) < abs(res + mn) ? (res - mn) : (res + mn));
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
int W,H,x,y,r;
scanf("%d %d %d %d %d",&W ,&H ,&x ,&y ,&r);
if (x+r > W || x-r < 0){
printf("No\n");
}else if (y+r > H || y-r < 0){
printf("No\n");
}else{
printf("Yes\n");
}
return 0;
}

Measured memory_bytes: 580
dp=[[0]*1001 for i in range(11)]
dp[0][0]=1
for i in range(101):
    for j in range(10)[::-1]:
        for k in range(1001-i):
            dp[j+1][k+i]+=dp[j][k]
while True:
    n,s=map(int,raw_input().split())
    if n==s==0:break
    print dp[n][s]

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

int N;
long long dp[1001][10001];
std::pair<long long, int> a[1000];
int w[1000];
int s[1000];
long long v[1000];

int main(){
  
  std::cin>>N;
  for(int i=0;i<N;++i){
    std::cin>>w[i]>>s[i]>>v[i];
    a[i]={w[i]+s[i],i};
  }
  std::sort(a,a+N);
  long long ans=0;
  for(int i=0;i<N;++i){
    int pos=a[i].second;
    for(int j=0;j<=s[pos];++j){
      long long ne=std::max((i>0?dp[i-1][j]:0)+v[pos],dp[i][j+w[pos]]);
      if(j+w[pos]<=10000){
		dp[i][j+w[pos]]=ne;
      }
      ans=std::max(ans,ne);
    }
    for(int j=0;i>0&&j<=10000;++j){
      dp[i][j]=std::max(dp[i][j],dp[i-1][j]);
    }
  }
  std::cout<<ans<<std::endl;
  return 0;
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

bool check(int x,int y,int n){
    rep(i,n/x+1){
        rep(j,n/y+1){
            if(i*x+j*y==n) return true;
        }
    }
    return false;
}

int main(){
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    double per=0;
    pair<int,int> ans;
    ans.first=a*100;
    repi(i,1,f/100){
        if(check(a,b,i)){
            for(int j=e*i;j>=0;j--){
                if(check(c,d,j)){
                    if(100*i+j<=f){
                        if(per<(double)j/(double)i){
                            per=(double)j/(double)i;
                            ans.first=i*100+j;
                            ans.second=j;
                        }
                    break;
                    }
                }
            }
        }
    }
    cout<<ans.first<<" "<<ans.second<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const int MAXN = 101024;

ll a[MAXN];

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

    if(N == 1) {
        if(a[0] == 1) {
            cout << 0 << endl;
        }
        else {
            cout << 1 << endl;
        }
        return 0;
    }

    sort(a, a + N);

    ll cur = a[0];
    ll res = 0;
    ll cnt = 1;

    for(ll i = 1; i < N; ++i) {
        if(a[i] != cur) {
            if(cnt >= cur) {
                res += cnt - cur;
            }
            else {
                res += cnt;
            }
            cur = a[i];
            cnt = 1;
            continue;
        }
        ++cnt;
    }

    if(cnt >= cur) {
        res += cnt - cur;
    }
    else {
        res += cnt;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long 
#define LL long long 
#define LD long double
#define PI 3.14159265358979323846
#define MOD ((LL)1e9+7)
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

			
int32_t main()
{
	IOS
	int n;cin>>n;
	vector<int>A(5),T(5);
	for(int i=0;i<5;i++)cin>>A[i];
	
	for(int i=0;i<5;i++)
	{
		T[i]=n/A[i]+(n%A[i]?1:0);
	}
	int t=0;
	for(int i=0;i<5;i++)
	{
		t=max(T[i]+i,t+1);
	}
	cout<<t<<endl;
}
	

	
		


Measured memory_bytes: 256
#include<stdio.h>
int R=1,C=1,H[2000010],N[2000010];
//評価関数（いまはMIN）
int hyouka(int a,int b){
  if(C<b)return 1;
  if(C<a||b==0)return 0;
  return N[H[a]]<N[H[b]]?1:0;
}
//挿入関数
void hin(int a){
  int i=C++;
  for(N[H[0]=R]=a;hyouka(0,i/2);i/=2)H[i]=H[i/2];
  H[i]=R++;
}
//取り出す関数
int hout(){
  int rt=H[1],i,j=2,k=H[--C];
  for(i=1;hyouka(i,C);i=j)H[i]=H[j=i*2+1-hyouka(i*2,i*2+1)];
  H[j/2]=k;
  return rt;
}
int main(){
  int n,a,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    hin(a);
  }
  for(i=0;i<n;i++)printf("%d%c",hout(),i+1-n?' ':'\n');
  return 0;
}
							 


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
const ll mod = 1e9+7;

ll power(ll a, ll b, ll m = mod) {
    ll x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}

const int N = 5e5;
// ll a[N];

signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);    
    
    ll n, m, v, p; cin >> n >> m >> v >> p;
    vector<int> a(n+1);
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    sort(a.begin()+1, a.end(), greater<int>());
    int ans = p-1;
    ll sum = 0;
    for(int i = p; i <= n; i++) {
        ll atmax = n*m + a[i] * (i-p) - sum;
        if(atmax >= m*v && a[i] + m >= a[p]) {
            ans++;
            // cout << "atmx=" << atmax << " ";
            // cout << a[i] << "\n";
        }
        sum += a[i];
    }
    cout << ans << "\n";
 
    return 0;
    
}
    


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	int n;
	cin >> n;
	string str;
	for (int i = 0; i < n; ++i) {
		int outcount = 0;
		int runner = 0;
		int point = 0;
		while (outcount < 3) {
			cin >> str;
			if (str == "OUT") {
				outcount++;
			}
			if (str == "HIT") {
				if (runner == 3) {
					point++;
				}
				else {
					runner++;
				}
			}
			if (str == "HOMERUN") {
				point++;
				point += runner;
				runner = 0;
			}
		}
		cout << point << endl;
	}
	return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N;
	cin >> N;
	ll cnt = 0;
	for (int i = 1; i <= N; i++) {
		if (i % 15 == 0) {
		} else if (i % 3 == 0) {
		} else if (i % 5 == 0) {
		} else {
			cnt += i;
		}
	}
	cout << cnt << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


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

int main() {
  int n, q;
  string s;
  
  cin >> n >> q;
  cin >> s;
  
  vector<int> l(q), r(q);
  for (int i=0; i<q; i++) {
    cin >> l[i] >> r[i];
  }
  
  vector<int> sum(n+1, 0);
  
  for (int i=0; i<n-1; i++){
    sum[i+1] = sum[i];
    if(s[i] == 'A' && s[i+1] == 'C'){
      sum[i+1]++;
    }
  }
  
  for (int i=0; i<q; i++){
    int ans = sum[r[i]-1] - sum[l[i]-1];
    cout << ans << endl;
  }
}
  
  
      

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

typedef long long ll;
#define MAX_N 100

// int N = 3;
// int X = 1000;
// int m[MAX_N] = {120, 100, 140};

int N, X;
int m[MAX_N];

int main() {
    cin >> N >> X;
    for (int i = 0; i < N; i++) {
        cin >> m[i];
    }

    int sum_one = accumulate(m, m + N, 0);
    int ans = 0;
    // cout << sum_one;

    X -= sum_one;
    ans += N;

    sort(m, m + N);
    ans += (X / m[0]);
    cout << ans << endl;
}

Measured memory_bytes: 256
using System.Linq;
using static System.Math;
using System.Collections.Generic;
using System;

public class P
{
    public int p { get; set; }
    public int h { get; set; }
}

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        var a = new bool[h, w];
        for (int i = 0; i < h; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            for (int j = 0; j < w; j++)
                if (line[j] == "1") a[i, j] = true;
        }
        var b = new int[h, w];
        for (int i = 0; i < w; i++) b[0, i] = a[0, i] ? 0 : 1;
        if (h == 1)
        {
            var t = new int[w + 1];
            for (int i = 0; i < w; i++) t[i] = b[0, i];
            Console.WriteLine(getRect(t, w + 1));
            goto exit;
        }
        for (int i = 1; i < h; i++)
            for (int j = 0; j < w; j++) b[i, j] = a[i, j] ? 0 : b[i - 1, j] + 1;
        var ans = getAns(b, h, w);
        Console.WriteLine(ans);
        exit:;
    }
    static long getAns(int[,] b, int h, int w)
    {
        var ans = 0L;
        var a = new int[w + 1];
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++) a[j] = b[i, j];
            ans = Max(ans, getRect(a, w + 1));
        }
        return ans;
    }
    static long getRect(int[] a, int n)
    {
        var ans = 0L; var lastp = 0;
        var st = new Stack<P>();
        for (int i = 0; i < n; i++)
        {
            if (st.Count() == 0) st.Push(new P { p = i, h = a[i] });
            else
            {
                var w = st.Peek();
                if (a[i] > w.h) st.Push(new P { p = i, h = a[i] });
                else if (a[i] < w.h)
                {
                    while (true)
                    {
                        ans = Max(ans, (long)(i - w.p) * w.h);
                        lastp = w.p;
                        st.Pop();
                        if (st.Count() == 0) break;
                        w = st.Peek();
                        if (a[i] <= w.h) continue;
                        else break;
                    }
                    st.Push(new P { p = lastp, h = a[i] });
                }
            }
        }
        return ans;
    }
}




Measured memory_bytes: 43716
input_str = input()

str_len = len(input_str)
index = 0

while index < str_len:
    if input_str[index:].startswith('apple'):
        print('peach', end='')
        index += 5
    elif input_str[index:].startswith('peach'):
        print('apple', end='')
        index += 5
    else:
        print(input_str[index], end='')
        index += 1

    if (index == str_len):
        print('')


Measured memory_bytes: 5596
#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;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 1e6 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
vector <int> dv[N];
int a[N];
void solve(){
    int n;
    cin >> n;
    mset <int> s;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
        s.ins(a[i]);
    }
    int ans = 0;
    for(int i = 1; i <= n; ++i) {
        s.erase(s.find(a[i]));
        bool ok = 0;
        for(int g : dv[a[i]]) {
            if(s.find(g) != s.end()) {
                ok = 1;
                break;
            }
        }
        ans += !ok;
        s.ins(a[i]);
    }
    cout << ans << "\n";
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= N; ++i) {
        for(int j = i; j < N; j += i) {
            dv[j].pb(i);
        }
    }
    while(t--)solve();
}

Measured memory_bytes: 125852
#include <iostream>

using namespace std;
int main(void)
{
	int a, b, c;
	int data[3];
	int temp = 0;

	cin >> data[0] >> data[1] >> data[2];

	do {
		temp = 0;
		for (int i = 0; i < 2; i++) {
			if (data[i] > data[i + 1]) {
				temp = data[i];
				data[i] = data[i + 1];
				data[i + 1] = temp;
			}
		}
	} while (temp != 0);
	cout << data[0] <<" "<< data[1] <<" "<< data[2]<<"\n";

	return 0;
}





Measured memory_bytes: 3108
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a,b,c;
	int absa, absb;
	cin >> a >> b >> c;
	absa = a.length();
	absb = b.length();
	if (a[absa -1] == b[0]) {
		if (b[absb - 1] == c[0]) {
			cout << "YES";
		}
		else cout << "NO";
	}else cout << "NO";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}


int mx = 0;
int px=0;

vi vx;
vi modcp;
vi modcm;
int n;

void f(int count,int j) {
  if(count==1) {
    if(vx.at(n - j)) {
      cout << 0 << endl;
      return;
    }
  }
  int ans = 0;
  int x = 0;
  if(vx.at(n - j)) {
    x = mx - modcm.at(n-j);
    x%=count-1;
    if(x<0) x+= count-1;
  }
  else {
    x = px + modcp.at(n-j);
    x %= count+1;
  }
  ans++;

  while(x!=0) {
    x = x % __builtin_popcount(x);
    ans++;
  }
 cout << ans << endl;
}


int main() {
  cin >> n;
  string s; cin >> s;
  int count = 0;
  rep(i,n) {
    if(s.at(i)=='1') {
      vx.eb(1);
      count++;
    } else vx.eb(0);
  }
  if(count == 0) {
    rep(i,n) cout << 1 << endl;
    return 0;
  }
  reverse(rng(vx));

  int t = 1 % (count+1);

  rep(i,n) {
    modcp.eb(t);
    t = t << 1;
    t %= count+1;
  }
  rep(i,n) {
    if(vx.at(i)) {
      px+=modcp.at(i)%(count+1);
      px%=count+1;
    }
  }

  if(count!=1) {
    t = 1 % (count -1);
    rep(i,n) {
      modcm.eb(t);
      t = t << 1;
      t %= count-1;
    }
    rep(i,n) {
      if(vx.at(i)) {
        mx+=modcm.at(i)%(count-1);
        mx%=(count-1);
      }
    }
  }

  rep(i,n) f(count,i+1);

  return 0;
}


Measured memory_bytes: 6556
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(int argc, char** argv) {
  ios::sync_with_stdio(false), cin.tie(0);
  
  int n;
  cin >> n;
  
  vector<vector<int>> tree;
  tree.resize(n);
  for (int i = 1; i < n; i++) {
    int j;
    cin >> j;
    --j;
    tree[i].push_back(j);
    tree[j].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    int ans = tree[i].size();
    if (i) --ans;
    cout << ans << '\n';
  }
  
  return 0;
}

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

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

  int ans = 1;
  for ( int i = 1; i < n; i++ ) {
    ans += ( s[i] != s[i-1] ) ? 1 : 0;
  }
  cout << ans << endl;
  return 0;
}


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

int main(int argc, char const *argv[])
{	
	int a,b,k;
	int p = 0;
	vector<int> v(101);
	cin >> a >> b >> k;
	for (int i = 1; i <= max(a,b); ++i)
	{
    // この表現は読みづらいかも
    // if(!(a % i) && !(b % i)){
		if(a % i ==0 && b % i == 0){
      // どっちでも割り切れたときにvの前からi番目に格納する
			v[p] = i;
			++p;
		}	
	}
	cout << v[p - k] << endl;
	return 0;
}


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

using namespace std;

int main(void) {
  int A;cin>>A;
  int B;cin>>B;
  for(int i=0;i<10000;i++){
    if(int(i*0.08)==A&&int(i*0.10)==B){
      cout<<i<<endl;
      return 0;
      }
    }
  cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void Check(int A, int B, int X){
  if(A > X || A + B < X) printf("NO\n");
  else printf("YES\n");
}

int main(void){
  int A, B, X;
  scanf("%d %d %d", &A, &B, &X);
  Check(A, B, X);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
/*    #include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;       */
using namespace std;

#define ll long long
#define ull unsigned long long
#define f(a, b) for (ll i = a; i < b; i++)
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pl pair<ll, ll>
#define vll vector<ll>
#define pll vector<pair<ll, ll>>
#define ld long double
#define fr(a, b) for (ll j = a; j >= b; j--)
#define fi(a, b) for (ll j = a; j < b; j++)
#define fii(a, b) for (ll k = a; k < b; k++)
#define print(x) cout << #x << " is " << x << endl;
//      typedef tree<ll ,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

ll dp[3005][3005], a[3005], n;

ll rec(ll l, ll r)
{
    if (r < l)
        return 0;
    if (dp[l][r] != -1e18)
        return dp[l][r];
    ll t, k = 0;
    if (((r - l) & 1) == (n & 1))
        t = 0;
    else
        t = 1;
    if (t == 0)
        dp[l][r] = max(dp[l][r], max(a[l] - rec(l + 1, r), a[r] - rec(l, r - 1)));
    else
        dp[l][r] = max(dp[l][r], max(a[l] - rec(l + 1, r), a[r] - rec(l, r - 1)));
    return dp[l][r];
}

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

    f(1, 3005) fi(1, 3005) dp[i][j] = -1e18;
    cin >> n;
    f(1, n + 1) cin >> a[i];
    ll ans = rec(1, n);
    cout << ans;

    return 0;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

string S; cin >> S;

int cnt = 0;
rep(i, 0, S.size()){
    if (S[i] != S[S.size() - 1 - i]) ++cnt;
}
cout << cnt / 2 << endl;

}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256