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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define F first
#define S second

vector<int> vec, sec, gec;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	if (n == 3)
		cout << "2 5 63\n";
	else{
		for (int i = 2; i <= 30000; i += 2)
			if (i%3 != 0)
				vec.push_back(i);
		for (int i = 3; i <= 30000; i += 6)
			sec.push_back(i);
		for (int i = 6; i <= 30000; i += 6)
			gec.push_back(i);
		
		cout << sec[0] << " " << sec[1] << " ";
		n -= 2;
		for (int i = 2; i < sec.size() && n -2 >= 2; i += 2) {
			cout << sec[i] << " " << sec[i+1] << " ";
			n -= 2;
		}

		for (int i = 0; i < vec.size() && n > 1; i += 2){
			cout << vec[i] << " " << vec[i+1] << " ";
			n -= 2;
		}

		for (int i = 0; i < gec.size() && n; i++){
			cout << gec[i] << " ";
			n--;
		}

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


Measured memory_bytes: 512
def resolve():
    s = int(input())
    ans = [s]
    count = 0
    while True:
        if ans[count]%2 == 0:
            ans.append(ans[count]/2)
        else:
            ans.append(ans[count]*3+1)
        count += 1
        for i in range(count):
            if ans[i] == ans[count]:
                print(count+1)
                exit()
resolve()

Measured memory_bytes: 3060
#include <iostream>
#include <set>
using namespace std;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int CommandNum;
    set<string> List;
    string Command, ss;
    
    List.clear();
    cin >> CommandNum;
    for(int i = 0; i < CommandNum; i++){
        cin >> Command;
        cin >> ss;
        if(Command == "insert"){
            List.insert(ss);
        } else if(Command == "find"){
            set<string>::iterator itr = List.find(ss);
            if(itr != List.end())   cout << "yes" << endl;
            else    cout << "no" << endl;
        }
    }
}

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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' ';
#define PRINT_ENTER() cout << endl;

int main() {
    /* code */
    int n;
    cin >> n;
    vector<int> H(n);
    int max_height = 0;
    REP(i, n) {
        cin >> H[i];
        max_height = max(max_height, H[i]);
    }
    int ans = 0;
    int check_height = 0;
    while (check_height < max_height) {
        check_height++;
        bool is_watering = false;
        for (const auto& h : H) {
            if (is_watering && check_height > h) {
                is_watering = false;
            } else if (!is_watering && check_height <= h) {
                ++ans;
                is_watering = true;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   cin>>n;
   vector<int> a(n);
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
   }
   if(n==1)cout<<0;
   else{
       vector<int> b(n);
       b[0]=0;
       b[1]=abs(a[1]-a[0]);
       for(int i=2;i<n;i++)
       {
           b[i]=min(b[i-1]+abs(a[i]-a[i-1]),b[i-2]+abs(a[i]-a[i-2]));
       }
       cout<<b[n-1];
   }
}

Measured memory_bytes: 1024
# C - Candies

N = int(input())
A_list = []
# input process
for i in range(2):
    A_list.append(list(map(int, input().split())))

search_queue = [] # queue for the path search [x, y]
cost_list = [[0]*N for i in range(2)] # max cost list

# initialization
search_queue.append([0, 0])
cost_list[0][0] = A_list[0][0]

while len(search_queue)>0:
    # visit process
    pos = search_queue.pop(0)
    x = pos[0]
    y = pos[1]

    # right search
    if y+1<N:
        # cost calculation
        cost_list[x][y+1] = max(cost_list[x][y+1], cost_list[x][y]+A_list[x][y+1])
        if not [x, y] in search_queue:
            search_queue.append([x, y+1])

    # down search
    if x+1<2:
        # cost calculation
        cost_list[x+1][y] = max(cost_list[x+1][y], cost_list[x][y]+A_list[x+1][y])
        if not [x, y] in search_queue:
            search_queue.append([x+1, y])

# output process
print(cost_list[1][N-1])


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

typedef long long ll;

const ll N = 55, inf = 1e17;

ll cost[N], n;

string str[N];


bool is_pallindrome(string s) {
	string t = s;
	reverse(t.begin(), t.end());
	return t == s;
}


ll dp[52][21][2][2][10001];




ll go(ll idx, ll len, ll pref, ll suff, ll dep) {
	if (len <= 1)return 0;
	string tm = str[idx].substr(0, len);
	if (pref && is_pallindrome(tm))
		return 0;
	tm = str[idx].substr(str[idx].size() - len, len);
	if (suff && is_pallindrome(tm))
		return 0;
	if (dep > 10000)return inf;
	ll &ret = dp[idx][len][pref][suff][dep];
	if (~ret)return ret;
	ret = inf;
	for (ll i = 1; i <= n; i++) {
		if (pref) {
			ll k = min(len, (ll)str[i].size());
			if (is_pallindrome(str[i].substr(0, k) + str[idx].substr(len - k, k))) {
				if (k < (int) str[i].size()) {
					ret = min(ret, cost[i] + go(i, str[i].size() - k, 0, 1, dep + 1));
				} else {
					ret = min(ret, cost[i] + go(idx, len - k, 1, 0, dep + 1));
				}
			}
		} else {
			ll k = min(len, (ll)str[i].size()), pos = str[idx].size() - len;
			if (is_pallindrome(str[idx].substr(pos, k) + str[i].substr(str[i].size() - k, k))) {
				if (k < (int) str[i].size()) {
					ret = min(ret, cost[i] + go(i, str[i].size() - k, 1, 0, dep + 1));
				} else {
					ret = min(ret, cost[i] + go(idx, len - k, 0, 1, dep + 1));
				}
			}
		}
	}
	return ret;
}

int32_t main() {
	/*
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
	//*/

	cin >> n;
	ll ans = inf;
	for (ll i = 1; i <= n; i++) {
		cin >> str[i] >> cost[i];
		if (is_pallindrome(str[i])) {
			ans = min(ans, cost[i]);
		}
	}
	memset(dp, -1, sizeof dp);
	for (ll i = 1; i <= n; i++) {
		for (ll j = 1; j <= n; j++) {
			ll n = str[i].size(), m = str[j].size();
			if (n <= m) {
				if (is_pallindrome(str[i] + str[j].substr(m - n, n))) {
					ans = min(ans, cost[i] + cost[j] + go(j, m - n, 1, 0, 1));
				}
			} else {
				if (is_pallindrome(str[i].substr(0, m) + str[j])) {
					ans = min(ans, cost[i] + cost[j] + go(i, n - m, 0, 1, 1));
				}
			}
		}
	}
	if (ans >= inf) ans = -1;
	cout << ans << endl;
}

Measured memory_bytes: 348200
n = int(input())
A = list(map(int, input().split()))
cnt = [0]*n
for a in A:
    cnt[a-1] += 1
ans = 0
for i in range(n):
    ans += cnt[i] * (cnt[i]-1) // 2
for a in A:
    print(ans-cnt[a-1]+1)

Measured memory_bytes: 26012
import sys
M,D=map(int,input().split())
res=0
if D<=9:
  print('0')
  sys.exit()

d10=int(D/10)
d1=int(D%10)
for i in range(d10-2):
  i2=i+2
  for j in range(10):
    if i2*j<=M and j>=2:
      #print(i2,j)
      res+=1
for i in range(d1+1):
  if i<=1:
    continue
  if d10*i<=M:
    #print(d10,j)
    res+=1
print(res)

Measured memory_bytes: 3064
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Anti-Adjacency
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, k;
  scanf("%d%d", &n, &k);

  if (2 * k - 1 <= n) puts("YES");
  else puts("NO");
  return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc175/tasks/abc175_b
#include <bits/stdc++.h>
using namespace std ;
#define int long long
#define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ;

void solve() {
    int n , counter = 0 ;
    cin >> n ;
    vector<int> side (n) ;
    for(auto &x : side) cin >> x ;
    for(int i = 0 ; i < n ; i++) {
        for (int j = i + 1 ; j < n ; j++ ) {
            for (int k = j + 1 ; k < n ; k++) {
                vector<int> temp ;
                temp.push_back(side[i]) ;
                temp.push_back(side[j]) ;
                temp.push_back(side[k]) ;
                sort(temp.begin() , temp.end()) ;
                if (temp[0] == temp[1] or temp[1] == temp[2] or temp[0] == temp[2]) continue ;
                else if (temp[1] + temp[0] > temp[2]) {
                    counter++ ;
                    // for(auto x : temp) cout << x << " " ;
                    // cout << endl ;
                }
            }
        }
    }
    cout << counter << endl ;
}

int32_t main() {
    fast;
    int testcases = 1 ;
    //cin >> testcases ;
    while (testcases--) {
        solve() ;
    }
    return 0;
}
/*  CODED BY:-
 ___________________________________
|                       ___         |
|  /\   /\  \ /  |  |  |___   |__|  |        
| /~~\ /~~\  |   |__|   ___|  |  |  |
|___________________________________|
*/

Measured memory_bytes: 3636
/**Hey, What's up?*/

#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<long long>v;
long long x[10][10];
int main()
{
    fastio;
    long long a=0,b=0,c,d,e,f=0,l,g,m,n,k,i,j,t,p,q;
    cin>>n;
    for(i=1;i<=n;i++){
        d=i;
        p=d%10;
        while(d>=10)d/=10;
        q=d;
        x[q][p]++;
    }
    f=0;
    for(i=1;i<10;i++){
        for(j=1;j<10;j++){
            f+=x[i][j]*x[j][i];
        }
    }
    cout<<f<<'\n';
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

N = int(input())
*a, = map(int, input().split())

cnt = defaultdict(int)
pos = defaultdict(lambda :10**12)
ans = defaultdict(int)

for i, j in enumerate(a, start=1):
    pos[j] = min(pos[j], i)
    cnt[j] += 1

target = [list(i) for i in sorted(pos.items())][::-1]
size = len(target)

for i in range(len(target)-1):
    a, b = target[i]
    c, d = target[i+1]
    ans[b] += cnt[a]*(a-c)
    cnt[c] += cnt[a]
    cnt[a] = 0
    target[i+1][1] = min(target[i+1][1], b)

a = target[-1][0]
ans[1] += cnt[a]*a
for i in range(1, N+1):
    print(ans[i])


Measured memory_bytes: 118484
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int n, l;
    int sum = 0;
    cin >> n >> l;
    for (int i = 1; i <= n; i++) {
        sum += l + i - 1;
    }
    if (l + n - 1 >= 0 && l <= 0) {
        cout << sum << endl;
    }
    else if (l <= 0) {
        cout << sum - (l + n - 1) << endl;
    }
    else {
        cout << sum - l << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll int 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;
string s;
ll sz;
ll dp[1000005][2];
#define mod 1000000007
ll recurse(ll pos,ll tight){
  ll ans=0;
  if(pos==sz)return 1;
  if(dp[pos][tight]!=-1)return dp[pos][tight];
  if(tight==1){
    if(s[pos]=='1'){
      ans=recurse(pos+1,0)%mod;
      ans=(ans+(2*recurse(pos+1,tight))%mod)%mod;
    }
    else{
      ans=recurse(pos+1,1)%mod;
    }
  }
  else{
      ans=recurse(pos+1,0)%mod;
      ans=(ans+(2*recurse(pos+1,0))%mod)%mod;
  }
  return dp[pos][tight]=ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    memset(dp,-1,sizeof(dp));
    cin>>s;
    sz=s.size();
    cout<<recurse(0,1);
}

Measured memory_bytes: 16180
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	vector<int>a;
	int tmp=1;
	for (int i = 0; tmp != 0; i++){
		cin >> tmp;
		a.push_back(tmp);
	}

	for (int i = 0; i < a.size()-1; i++)
		cout << "Case "<<i+1<<": " << a[i] << endl;

	return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#include <algorithm>  
#include <unordered_set>

#define ll long long

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll x, y;

	cin >> x >> y;

	if (y % 2 == 0 && y >= 2 * x && y <= 4 * x) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int> > v(n);
    for(int i=0; i<n; ++i){
        int x, y;
        cin >> x >> y;
        v[i].first = min(x, y);
        v[i].second = max(x, y);
    }
    sort(v.begin(), v.end());

    multiset<int> x;
    multiset<int> y;
    multiset<pair<int, int> > p;
    for(int i=0; i<n; ++i){
        x.insert(v[i].first);
        y.insert(v[i].second);
        p.insert(make_pair(v[i].second, v[i].first));
    }

    long long ans = LLONG_MAX;
    for(;;){
        long long tmp = *x.rbegin() - *x.begin();
        tmp *= *y.rbegin() - *y.begin();
        ans = min(ans, tmp);

        if(p.empty())
            break;

        int a, b;
        tie(a, b) = *p.begin();
        p.erase(p.begin());
        x.erase(x.find(b));
        x.insert(a);
        y.erase(y.find(a));
        y.insert(b);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 29952
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, m;
    cin >> n >> m;

    VI l(m), r(m), d(m), from(n);
    VVI to(n), dist(n);
    REP(i,m){
        scanf("%d %d %d", &l[i], &r[i], &d[i]);
        l[i]--;
        r[i]--;

        to[l[i]].push_back(r[i]);
        dist[l[i]].push_back(d[i]);
        from[r[i]]++;
    }

    VI x(n), visit(n);
    queue<int> que;
    REP(i,n){
        if (from[i] == 0){
            que.push(i);
            visit[i] = 1;
        }
    }

    while (!que.empty()){
        int i = que.front();
        que.pop();
        REP(j,to[i].size()){
            int next = to[i][j];
            if (visit[next]) continue;
            x[next] = x[i] + dist[i][j];
            visit[next] = 1;
            que.push(next);
        }
    }

    REP(i,m){
        if (x[l[i]] + d[i] != x[r[i]]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
 
//DEFINE and TYPEDEF--------------------------------------------------------------
 
#define timeKyaHorhaH 1.0 * clock() / CLOCKS_PER_SEC
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

#define FORG(i,a,n) for(lld i=a;i<n;i++) //for - general
#define FORZ(i,n) for(lld i=0;i<n;i++) //for - zero
#define FORGI(i,a,n,inc) for(lld i=a;i<n;i+=inc) //for - general incremental
#define FORZI(i,n,inc) for(lld i=0;i<n;i+=inc) //for - zero incremental
#define DEBUG(x) cerr<<(#x)<<" is "<<(x)<<"\n" //to debug values of variables
#define ZINDA cerr<<"\nIdhar-ich hai apun!!\n"; //to debug if code reached that point
#define SPEEDUP ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
 
#define SORTall(m) sort(m.begin(),m.end());
 
#define st first
#define nd second
#define mkp make_pair
#define pb push_back
#define endl '\n'
#define mod 1000000007
 
typedef long long int lld;
typedef unsigned long long int ulld;
 
lld power(lld b, lld e)
{
    if(e==0)
        return 1;
    if(e%2==1)
        return b*power(b*b,(e-1)/2);
    else
        return power(b*b,e/2);
}
 
lld power(lld b, lld e, lld m)
{
	if(e==0)
		return 1;
	if(e%2==1)
		return b*power(((b%m)*(b%m))%m,(e-1)/2,m)%m;
	else
		return power(((b%m)*(b%m))%m,e/2,m)%m;
}
 
int nDig(lld n)
{
	if(n<0) 
		n*=-1;
	if(n==0)
		return 1;

    return floor(log10(n) + 1);
}

//endl : changed to '\n', to flush comment that definition
//--------------------------------------------------------------------------------

void swagWaalaFunction()
{
	lld n,ans=0,temp=0;
	string s;
	cin>>n>>s;

	lld r[n+1],g[n+1],b[n+1];
	memset(r,0,sizeof(r));
	memset(g,0,sizeof(g));
	memset(b,0,sizeof(b));

	if(s[n-1]=='R')
		r[n-1]=1;
	else if(s[n-1]=='G')
		g[n-1]=1;
	else if(s[n-1]=='B')
		b[n-1]=1;

	FORG(i,1,n)
	{
		r[n-1-i]=r[n-i];
		g[n-1-i]=g[n-i];
		b[n-1-i]=b[n-i];
		
		if(s[n-1-i]=='R')
			r[n-1-i]++;
		if(s[n-1-i]=='G')
			g[n-1-i]++;
		if(s[n-1-i]=='B')
			b[n-1-i]++;
	}

	// FORZ(i,n)
	// cout<<r[i]<<" "<<g[i]<<" "<<b[i]<<endl;

	FORZ(i,n)
	FORG(j,i+1,n)
	{
		if(s[i]==s[j])
			continue;

		char x='R'^'G'^'B'^s[i]^s[j];
		if(x=='G' and g[j+1]!=0)
		{
			{
				if(s[2*j-i]==x)
					ans+=g[j+1]-1;
				else
					ans+=g[j+1];
			}
			// g[j]--;
		}
		else if(x=='B' and b[j+1]!=0)
		{
			if(2*j-i>=0)
			{
				if(s[2*j-i]==x)
					ans+=b[j+1]-1;
				else
					ans+=b[j+1];
			}
			// b[j]--;
		}
		else if(x=='R' and r[j+1]!=0)
		{
			if(2*j-i>=0)
			{
				if(s[2*j-i]==x)
					ans+=r[j+1]-1;
				else
					ans+=r[j+1];
			}
			// r[j]--;
		}
	}

	cout<<ans;
	return;
}

int main()
{
    SPEEDUP;
 	lld t=1;
 	//cin>>t;

 	while(t--)
 		swagWaalaFunction();
	
	// cerr<<"\n"<<timeKyaHorhaH; 	
 	return 0;
}

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

using namespace std;

typedef long long int big;

int main(){
    big n;
    cin>>n;
    big sum=0;
    for(big i=1;i<=n;i++){
        if(i%3!=0 && i%5!=0){
            sum=sum+i;
        }
    }
    cout<<sum<<"\n";
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<queue>
#include<ctime>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m,i,j,x,y,sum,vis[1000005];
priority_queue<pair<int,long long>/**/> pq;
int main()
{
	cin>>n;
	x=n;
	while (x)
	{
		m+=x%10;
		x/=10;
	}
	pq.push(make_pair(-1,1));
	while ((!pq.empty()))
	{
		x=pq.top().second;
		y=-pq.top().first;
		pq.pop();
		if (vis[x]) continue;
		vis[x]=1;
		if (y>=m)
		{
			cout<<m;
			return 0;
		}
		if (!(x%n))
		{
			cout<<y;
			return 0;
		}
		for (i=0;i<=9;i++)
		{
			if (!vis[(x*10+i)%n]) pq.push(make_pair(-y-i,(x*10+i)%n));
		}
	}
	cout<<m;
	return 0;
}

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

const int maxn = 2e5+10;

struct dat{
	int u, o, z;
	bool operator <(const dat &d) const { return 1ll*o*d.z > 1ll*z*d.o; }
}t[maxn];

int f[maxn];
int find(int x) { return f[x]?f[x]=find(f[x]):x; }

int n;
int p[maxn], v[maxn];
priority_queue<dat> pq;

int main() {
	scanf("%d", &n);
	for (int i = 2; i <= n; ++i) {
		scanf("%d", p+i);
//		if (p[i] != i-1) printf("%d %d\n", i, p[i]);
	}
	for (int i = 1; i <= n; ++i) {
		scanf("%d", v+i);
//		if (v[i] != v[i-1]) printf("%d:%d-%d:%d\n", i-1, v[i-1], i, v[i]);
		if (v[i] == 1) t[i] = (dat){i,1,0};
		else t[i] = (dat){i,0,1};
		pq.push(t[i]);
	}
	long long ans = 0;
	while (!pq.empty()) {
		dat tmp = pq.top(); pq.pop();
		int x = tmp.u;
		if (x == 1 || tmp.o != t[x].o || tmp.z != t[x].z) continue;
		int y = find(p[x]); f[x] = y;
		ans += 1ll*t[y].o*t[x].z;
		t[y].o += t[x].o;
		t[y].z += t[x].z;
		pq.push(t[y]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 8308
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define  all(v)            v.begin(), v.end()
#define  sz(x)             (int)x.size()
#define  debug(x)          cout << '>' << #x << ':' << x << endl;
#define  rep(i,n)          for(int i = 0; i <  n ; i++)
#define  reps(i,n)         for(int i = 1; i <= n ; i++)
#define  make_unique(v)    sort(all(v));v.erase(unique(all(v)), v.end());
#define  rot(v)            rotate(v.begin(), v.begin() + k, v.end());
#define  rmv(v,a)          v.erase(remove(v.begin(),v.end(), a), v.end());
#define  pb                push_back
#define  eb                emplace_back
#define  mp                make_pair
#define  endl              '\n'
#define  fi                first
#define  se                second
#define  max(x,y)          ((x>y)?x:y)
#define  min(x,y)          ((x<y)?x:y)
#define  ajs(a)            (a<0)?(-1*a):a


using namespace std;
typedef long long          ll;
typedef vector<long long>  vll;
typedef pair<ll,ll>        pll;
typedef vector<int>        vi;


const ll MOD = 1e9+7;
const double PI  = acos(-1.0);
const double EPS = (1e-10);
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = { -1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = { -1, 0, 1, 1, 1, 0, -1, -1};
bool cmp(int X, int Y) {return X > Y;}
int dcp(double A, double B){return fabs(A-B)<=EPS ? 0 : A<B ? -1:1;}



ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll lcm(ll a, ll b) {return (a / gcd(a, b)) * b;}
ll modpow(ll a, ll b, ll m=MOD){a %= m; ll res = 1; while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){if(b<0){return 0;}ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}





int main(){
ll x;cin>>x;
if(x>=30){
    cout<<"Yes";
}else{
    cout<<"No";
}

}


Measured memory_bytes: 3600
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	vi t(n+1,-inf);
	rep(i,n)t[in[i]-1]=i;
	int out=0;
	int c=1;
	rep(i,n)if(t[i]<t[i+1])c++;
	else{
		out=max(out,c);
		c=1;
	}
	cout<<n-out<<endl;
}







Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

int main(){fastio
    string s;cin>>s;
    ll n=s.size();
    ll ans=0;
    bool flag=false;
    rep(i,0,n-1){
        if(flag&&s[i-1]==s[i]){
            ans++;
            flag=false;
            i++;
            if(i==n)ans--;
        }else{
            ans++;
            flag=true;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll N;
    cin >> N;
    vector<ll> A(N,0);
    for(ll i=0;i<N;i++)cin>>A[i];
    Map M;
    for(ll i=0;i<N;i++)M[A[i]]++;
    ll ans=0;
    for(auto p: M){
        ll x=p.first;
        ll y=p.second;
        if(y<x)ans+=y;
        else ans+=y-x;
    }
    print(ans)
    
    return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
long long int dp[101][100005];
int main()
{
    int n, w;
    cin >> n >> w;
    int weight[n], value[n];
    for (int i = 0; i < n; i++)
    {
        cin >> weight[i] >> value[i];
    }
    for (int i = 0; i < n; i++)
        for (int j = 0; j <= w; j++)
        {
            if (i == 0)
            {
                if (weight[i] <= j)
                    dp[i][j] = value[i];
                continue;
            }
            if (j == 0)
            {
                dp[i][j] = 0;
                continue;
            }
            if (j - weight[i] >= 0)
                dp[i][j] = max(dp[i - 1][j - weight[i]] + value[i], max(dp[i - 1][j], dp[i][j - 1]));
            else
            {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    cout << dp[n - 1][w] << endl;
    return 0;
}

Measured memory_bytes: 78336
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node
{
	int p, l, r;	//parent, left, right
};

Node T[MAX];
int n, D[MAX];

void print(int u)
{
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";

	if (T[u].p == NIL)
	{
		cout << "root, ";
	}
	else if (T[u].l == NIL)
	{
		cout << "leaf, ";
	}
	else
	{
		cout << "internal node, ";
	}
	cout << "[";
	for (i = 0, c = T[u].l; c != NIL; i++, c = T[c].r)
	{
		if (i)
		{
			cout << ", ";
		}
		cout << c;
	}
	cout << "]\n";
}

void rec(int u, int p)
{
	D[u] = p;
	if (T[u].r != NIL)
	{
		rec(T[u].r, p);
	}
	if (T[u].l != NIL)
	{
		rec(T[u].l, p + 1);
	}
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		T[i].p = T[i].l = T[i].r = NIL;
	}
	int v, d, c, l, r;
	for (int i = 0; i < n; i++)
	{
		cin >> v >> d;
		for (int j = 0; j < d; j++)
		{
			cin >> c;
			if (j == 0)
			{
				T[v].l = c;
			}
			else
			{
				T[l].r = c;
			}
			l = c;
			T[c].p = v;
		}
	}

	for (int i = 0; i < n; i++)
	{
		if (T[i].p == NIL)
		{
			r = i;
		}
	}
	rec(r, 0);

	for (int i = 0; i < n; i++)
	{
		print(i);
	}
	return 0;
}


Measured memory_bytes: 7764
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int res = 0;
        for (int i = 0; i < (s.length()-1)/2; i++) {
            StringBuffer t = new StringBuffer();
            t.append(s.substring(0,i+1));
            t.append(s.substring(0,i+1));
            if(s.indexOf(t.toString()) == 0){
                res = t.length();
            }
        }
        System.out.println(res);
        sc.close();
    }
}

class io {
    public static void br() {
        System.out.println("");
    }

    public static void YesNo(boolean f) {
        System.out.println(f ? "Yes" : "No");
    }

    public static void YESNO(boolean f) {
        System.out.println(f ? "YES" : "NO");
    }

}

class Algo {
    public static boolean isOdd(int n) {
        return n % 2 == 1;
    }

    public static boolean isEven(int n) {
        return n % 2 == 0;
    }


}



Measured memory_bytes: 23124
import itertools
n = int(input())
f = [[int(i) for i in input().split()] for  i in range(n)]
p = [[int(i) for i in input().split()] for i in range(n)]
answer = -10**9
for i in itertools.product(range(2),repeat=10):
	if sum(i) != 0:
		num = 0
		for j in range(n):
			num2 = 0
			for k in range(10):
				num2 += i[k]*f[j][k]
			num += p[j][num2]
		if answer < num:
			answer = num
print(answer)

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;


public class Main{
	
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		while(sc.hasNextInt()) {
			System.out.println(prime(sc.nextInt()));
		}
		sc.close();
	}
	
	static int prime(int n) {
		boolean[] result = new boolean[n];
		int count = 0;
		Arrays.fill(result, true);
		result[1-1] = false;
		for(int i = 2; i <= n; i++){
			if(result[i-1]) {
				count++;
				for(int j = 2; i * j <= n; j++) {
					result[i * j - 1] = false;
				}
			}
		}
		return count;
	}
}

Measured memory_bytes: 35292
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};
vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n){
    cin>>a[i];
    res^=a[i];
  }
  rep(i,0,n)a[i]=res^a[i];
  debug(a,n);
  return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define repitr(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int k;
	cin >> k;
	int ans = 0;
	for(int i = 1; i <= k; i += 2){
		for(int j = 2; j <= k; j += 2){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){ll res=1;a%=mod;while(b){if(b&1)res=res*a%mod;a=a*a%mod;b>>=1;}return res;}

int main(){
    ll a,b;cin>>a>>b;
    ll n;cin>>n;
    rep(i,n){
        ll s,t;cin>>s>>t;
        if(s<b&&a<t)dame(1);
    }
    out(0);
}


Measured memory_bytes: 3116
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int a,b,c;
	//string s="error";
	cin >> a; cin >> b; cin >> c;
	if (a<=c&&b>=c)cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

signed main(void)
{
  string s;
  cin >> s;

  int n = s.size();
  for(int i=2; i<=n; i+=2) {
    string t = s.substr(0, n-i);
    if(t.substr(0, t.size()/2) == t.substr(t.size()/2)) {
      cout << t.size() << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n, m, x;
    cin >> n >> m >> x;
    
    int tmp, l = 0, r = 0;
    for (int i = 0; i < m; i++) {
        cin >> tmp;
        if (tmp < x) {
            l++;
        }else{
            r++;
        }
    }
    if (l < r) {
        cout << l << endl;
    }else{
        cout << r << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define MOD 1000000007
#define INF 1 << 30

using namespace std;
typedef long long ll;

int main(void) {
	int h, w, num, i, j = 0, a;
	cin >> h >> w >> num;
	vector<int> d(h * w);
	for (i = 1; i <= num; i++) {
		cin >> a;
		while (a > 0) {
			d[j++] = i;
			a--;
		}
	}
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++)
			printf("%d ", d[i * w + j]);
		printf("\n");
		i++;
		if (i >= h)
			break;
		for (j = w - 1; j >= 0; j--)
			printf("%d ", d[i * w + j]);
		printf("\n");
	}
	return 0;
}

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

using namespace std;

int main()
{
	int a, b, c, a1, b1, c1;
	cin >> a1 >> b1 >> c1;
	c = max(a1, max(b1, c1));
	a = min(a1, min(b1, c1));
	b = a1+b1+c1-a-c;
	
	if ((b-a) % 2 == 0)
		cout << c-b+(b-a)/2;
	else
		cout << 1+c-b+(b+1-a)/2;
}

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

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}
	vector<vector<int>> num(h, vector<int>(w));

	for (int i = 1; i < w; i++) {
		if (a[0][i - 1] == a[0][i])
			num[0][i] = num[0][i - 1];
		else
			num[0][i] = num[0][i - 1] + 1;
	}
	for (int i = 1; i < h; i++) {
		if (a[i - 1][0] == a[i][0])
			num[i][0] = num[i - 1][0];
		else
			num[i][0] = num[i - 1][0] + 1;
	}
	for (int i = 1; i < h; i++) {
		for (int j = 1; j < w; j++) {
			int x, y;
			x = num[i - 1][j] + (a[i - 1][j] == a[i][j] ? 0 : 1);
			y = num[i][j - 1] + (a[i][j - 1] == a[i][j] ? 0 : 1);
			num[i][j] = min(x, y);
		}
	}
	int result = (num[h - 1][w - 1] + 1) / 2;
	if (a[0][0] == '#' && a[h - 1][w - 1] == '#') {
		result++;
	}
	cout << result << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
string s[305];
int a[305][305];
int h,w,k;
int main(){
	scanf("%d%d%d",&h,&w,&k);
	int num=1;
	for(int i=1;i<=h;i++)
	  {
	  cin>>s[i];
	  for(int j=0;j<s[i].size();j++)
	   if(s[i][j]=='#')a[i][j+1]=num++;
	  }
	for(int i=2;i<=h;i++)
	  for(int j=1;j<=w;j++)
	  {
	  	 if(!a[i][j]) a[i][j]=a[i-1][j];
	  }
	for(int i=h-1;i>=1;i--)
	  for(int j=1;j<=w;j++)
	  {
	  	 if(!a[i][j]) a[i][j]=a[i+1][j];
	  }
	  	for(int i=2;i<=w;i++)
	  for(int j=1;j<=h;j++)
	  {
	  	 if(!a[j][i]) a[j][i]=a[j][i-1];
	  }
	for(int i=w-1;i>=1;i--)
	  for(int j=1;j<=h;j++)
	  {
	  	 if(!a[j][i]) a[j][i]=a[j][i+1];
	  }
	  
	  
	  
	for(int i=1;i<=h;i++)
	  {
	  	for(int j=1;j<=w;j++)
	  {
	  	cout<<a[i][j]<<" ";
	  }
	 cout<<endl;
	  }



	return 0;
}


Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main()
{
    int N,mult=false;
    cin>>N;
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            if(N==i*j)
                mult=true;
        }
    }
    if(mult)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  char c = s[0];
  if(s[1] == c){
    if(s[2] != c && s[2] == s[3]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }else if(s[2] == c){
    if(s[1] != c && s[1] == s[3]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }else if(s[3] == c){
    if(s[1] != c && s[2] == s[1]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

const int MAX_N = 10010;
vector<int> prime;
bool isPrime[MAX_N];
int T[MAX_N];

int make() {
  fill(isPrime,isPrime+MAX_N,true);
  isPrime[0] = isPrime[1] = false;
  for(int i = 0; i < MAX_N; ++i) {
    if(!isPrime[i]) continue;
    prime.push_back(i);
    for(int j = i*2; j < MAX_N; j += i) isPrime[j] = false;
  }

  fill(T,T+MAX_N,-1);
  for(int i = 1; i < prime.size(); ++i) {
    if(prime[i]-prime[i-1] == 2)
      T[prime[i]] = i;
  }
  for(int i = 0, j = -1; i < MAX_N; ++i) {
    if(T[i] != -1) j = T[i];
    else T[i] = j;
  }
}

int main() {
  make();
  int n;
  while(cin >> n && n)
    cout << prime[T[n]-1] << " " << prime[T[n]] << endl;
  return 0;
}

Measured memory_bytes: 968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
int N, M;

int main()
{
    cin >> N >> M;
    vector<int> s(M);
    vector<int> c(M);

    rep(i, 0, M)
    {
        cin >> s[i] >> c[i];
    }

    vector<int> flg(N + 1, -1);
    int ans = 0;
    if (M == 0 && N > 1)
    {
        ans += 1 * pow(10, N - 1);
    }
    rep(i, 0, M)
    {
        if (N > 1 && s[i] == 1 && c[i] == 0)
        {
            ans = -1;
            break;
        }
        if (flg[s[i]] == -1)
        {
            ans += c[i] * pow(10, N - s[i]);
            flg[s[i]] = c[i];
        }
        else
        {
            if (flg[s[i]] != c[i])
            {
                ans = -1;
                break;
            }
        }
    }
    if (ans < pow(10, N - 1) && ans != -1 && N > 1)
    {
        ans += 1 * pow(10, N - 1);
    }

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


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

int main(){
    int n;
    cin >> n;
    vector<int> v(n+2);
    for(int i=1; i<=n; i++) cin >> v[i];
    int sum = 0;
    for(int i=0; i<=n; i++) sum += abs(v[i+1] - v[i]);
    for(int i=1; i<=n; i++){
        cout << sum + abs(v[i+1] - v[i-1]) - abs(v[i-1] - v[i]) - abs(v[i+1] - v[i]) << endl;
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define ss second
#define ff first

 using namespace std;
 
 const ll MOD = 1000000007LL;
 
ll ar[500056],br[500056];


vector<ll> pec;
set<ll> st;
map<ll,ll> has,mark;


vector<pair<ll,ll> > vp;
ll maxi;



int main() 
{
	
//freopen("input.in","r",stdin);
//freopen("output.out","w",stdout);
    
    ll n,p,t,j,a,x,y=0,k,l,m,z,b,c,e,f,q,s,flag=0,sum=0,res=0,num,g,h;
	ll i,u,v,w,ans,maxm=-1,r,minm=999999999999;
	bool fl=0;
	ll d;
	string str;
	
	c=0;
	
	cin>>str;
	
	if(str[0]=='1')
	c++;
	
	if(str[1]=='1')
	c++;
	
	if(str[2]=='1')
	c++;
	
	
	cout<<c;
	
	
	
    return 0;
}    




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=1010;
int n,m,x[maxn],y[maxn],mx;
ll w[maxn];
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) {
		read(x[i]),read(y[i]);
		m=max(m,abs(x[i])+abs(y[i]));
		mx=max(mx,abs(x[i]));
		mx=max(mx,abs(y[i]));
	}
	for (int i=2;i<=n;i++)
		if ((abs(x[i])+abs(y[i]))%2!=(abs(x[1])+abs(y[1]))%2) {
			printf("-1\n");
			return 0;
		}
	if (mx<=10) {
		printf("%d\n",m);
		for (int i=1;i<=m;i++)
			printf("1 ");
		printf("\n");
		for (int i=1;i<=n;i++) {
			for (int j=1;j<=abs(x[i]);j++)
				if (x[i]>0) printf("R"); else printf("L");
			for (int j=1;j<=abs(y[i]);j++)
				if (y[i]>0) printf("U"); else printf("D");
			for (int j=abs(x[i])+abs(y[i])+1;j<=m;j+=2)
				printf("RL");
			printf("\n");
		}
	} else {
		m=40;
		w[m]=w[m-1]=w[m-2]=w[m-3]=1;
		for (int i=m-4;i>=1;i--) w[i]=w[i+1]*2;
		if ((abs(x[1])+abs(y[1]))%2==1) m--;
		printf("%d\n",m);
		for (int i=1;i<=m;i++)
			printf("%lld ",w[i]);
		printf("\n");
		for (int i=1;i<=n;i++) {
			ll a=x[i],b=y[i];
			for (int j=1;j<=m;j++) {
				if (b>=abs(a)) printf("U"),b-=w[j];
				else if (b<=-abs(a))
					printf("D"),b+=w[j];
				else if (a>=abs(b))
					printf("R"),a-=w[j];
				else printf("L"),a+=w[j];
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int A, B, C, D;

	cin >> A >> B;

	if (A + B < A - B) {
		if (A - B < A * B) {
			cout << A * B << endl;
		}
		else {
			cout << A - B << endl;
		}
	}
	else if (A + B < A * B){
		cout << A * B << endl;
	}
	else {
		cout << A + B << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
	
	//make it false if Multiple test case is not in the question
	static boolean multipleTC = false;
	
	//for pre processing if needed
	void pre() throws Exception
	{}
		public static void main(String[] args) throws Exception{
			
		new Main().run();
	  }
	  



	// input output handled here
	private String in_out(int tc) throws Exception{
		  //take input here
		  char[] s=n().toCharArray();
		  char[] p=n().toCharArray();

		//  int f1[]=new int[26];
		  //int f2[]=new int[26];
		  int count=0;
		  for(int i=0;i<s.length;i++){
			if(s[i]!=p[i])
			count++;
		  }

		return ""+count;

	}
	

	

	
	
	void run() throws Exception{
	//	long start_time=System.nanoTime();

	//	in = new FastReader("input.txt");  out = new PrintWriter("output.txt");
		in = new FastReader(); out = new PrintWriter(System.out);
		


		StringBuilder print=new StringBuilder("");
		pre();
		int T = (multipleTC)?ni():1;
		for(int t = 1; t<= T; t++){
		print.append(in_out(t)).append("\n");
		}

		p(print);
		//long end_time=System.nanoTime();
		//System.out.println("Running Time in nano sec : "+(end_time-start_time));
		
		out.flush();
		out.close();
	}
	PrintWriter out;
		FastReader in;
		
			void p(Object o)
				{out.print(o);}
			void pln(Object o)
				{out.println(o);}
			void pnf(Object o)
				{out.println(o);
				out.flush();}
		
			String n()throws Exception
				{return in.next();}
		
			String nln()throws Exception
				{return in.nextLine();}
		
			int ni()throws Exception
				{return Integer.parseInt(in.next());}
		
			long nl()throws Exception
				{return Long.parseLong(in.next());}
		
			double nd()throws Exception
				{return Double.parseDouble(in.next());}
	
		class FastReader{
			BufferedReader br;
			StringTokenizer st;
			
			public FastReader(){
				br = new BufferedReader(new InputStreamReader(System.in));
			}
	
			public FastReader(String s) throws Exception{
				br = new BufferedReader(new FileReader(s));
			}
	
			String next() throws Exception{
				while (st == null || !st.hasMoreElements()){
					try{
						st = new StringTokenizer(br.readLine());
					}catch (IOException  e){
						throw new Exception(e.toString());
					}
				}
				return st.nextToken();
			}
	
			String nextLine() throws Exception{
				String str = "";
				try{   
					str = br.readLine();
				}catch (IOException e){
					throw new Exception(e.toString());
				}  
				return str;
			}
		}
}

Measured memory_bytes: 40544