akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>
#include <map>
#include <deque>
#include <vector>
#include <assert.h>
#include <cstdio>
#include <iomanip>
#include <stack>
#include <bitset>
#include <queue>
#include <stdio.h>


using namespace std;



#define mp make_pair
#define pb push_back
#define ll long long
#define fi first
#define sc second
#define y1 stupid_cmath



ll  n,k,d,x,y,r, cnt, a[1001001], p[1001001], F[1001000];
ll const INF = 100000001;
vector<ll> v1,v2;
string s;

int main(){
    //ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
    cin>>n;
    for(int i = 0;i < n;i++){
        cin>>x;
        a[x]++;
        a[x - 1]++;
        a[x + 1]++;
    }
    ll mx = -1e9;
    for(int i = 0;i < 100100;i++){
        mx = max(mx,a[i]);

    }
    cout<<mx;

    return 0;
}
/*
5
1 3 7 12 32
40
*/


Measured memory_bytes: 4352
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define ii insert
#define ld long double
#define ppb pop_back
#define nuenxfiu ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define TT int testcases;cin>>testcases;while(testcases--)
#define mk make_pair
#define MAX ((int)2e9+17)
#define N 200005
#define mod ((int)1e9+7)
#define MOD 1000003
//int fact[1000007]={0};
int fpow(int n, int k, int p = mod) {int r = 1; while(k > 0) {if (k & 1) r = r * n%p; n = n * n%p; k = k >> 1;} return r;}
int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
int inv(int x) {return expo(x, mod-2);}
using namespace std;





void solve()
{
	int n;
	cin>>n;
	
	int sum=0;
	
	map<int,int>mp;
	
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		sum+=a;
		mp[a]++;
	}
	
	int q;
	cin>>q;
	while(q--)
	{
		int b,c;
		cin>>b>>c;
		if(mp[b]>0)
		{
			sum-=b*mp[b];
			sum+=c*mp[b];
			
			mp[c]+=mp[b];
			mp[b]=0;
		}
		cout<<sum<<endl;
	}
	
	
}
signed main()
{
    
	nuenxfiu
	//TT
	solve();
     return 0;
}

Measured memory_bytes: 9324
#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define pi 3.14159265358979323846264338327950L
using namespace std;

int main() {
  string S;
  cin >> S;
  int N=S.size(), R=0, B=0, ans;
  for (int i=0; i<N; i++) {
    if (S[i]=='0') {
      R++;
    }
    else {
      B++;
    }
  }
  ans=2*min(R,B);
  cout << ans << endl;
}

Measured memory_bytes: 3756
#include<stdio.h>
#include<math.h>
int main(){
int a,b,c,d,e,g,i;
long int f;
while(1){
scanf("%d %d %d\n",&a,&b,&c);
if(a==0 && b==0 && c==0){
break;
}
else{
if(a>b){
e=a;
a=b;
b=e;
}
if(b>c){
e=b;
b=c;
c=e;
}
if(a>b){
e=a;
a=b;
b=e;
}
f=a*a+b*b;
scanf("%d\n",&g);
for(i=0;i<g;i++){
scanf("%d\n",&d);
if(d>sqrt(f)/2){
printf("OK\n");
}
else{
printf("NA\n");
}
}
}
}
return 0;
}




Measured memory_bytes: 1996
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#define rep( i, a, n ) for( int i = a; i < n; i++ )
#define per( i, a, n ) for( int i = n - 1; i >= a; i-- )
#define mem( f, x ) memset( f, x, sizeof( f ) )
#define ll long long
#define pii pair<int, int>
#define fi first
#define se second
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define e 2.71828
using namespace std;
const int N = 2*1e5 + 5;
const int M = 1e6+5;
const int MAX = 5;
const ll inv = 500000004;
const double g = 9.80;
const double PI = acos( -1.0 );
ll a, b, c;

int main( ){
    while( scanf( "%lld %lld %lld", &a, &b, &c ) != EOF ){
        ll tmp1 = a * 10 + b;
        tmp1 += c;
        ll tmp2 = b * 10 + c;
        tmp2 += a;
        ll tmp3 = c * 10 + a;
        tmp3 += b;
        printf( "%lld\n", max( max( tmp1, tmp2 ), tmp3 ) );
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const int INF = 1e9;
const int EPS = 1e-9; 
const int SEARCH_MAX = 6e3;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> ans(N, 0);
  for (int i = 1; i < N; ++i) {
    cin >> A.at(i);
    ans.at(A.at(i)-1)++;
  }
  
  for (int i = 0; i < N; ++i) cout << ans.at(i) << endl;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std; void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); solve(); }
template <typename Type> void print_collection(Type coll) { cout << "{ "; for (auto e : coll) cout << e << ' '; cout << "}\n"; }
void solve() {
    int N;
    cin >> N;
    vector<int> hs(N);
    for (int i=0; i<N; ++i) cin >> hs[i];
    int mxh = 0;
    int res = 0;
    for (int h : hs) {
        if (h >= mxh) {
            ++res;
            mxh = h;
        }
    }
    cout << res << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <numeric>
#include <iterator>
using namespace std;

typedef pair<int, int> P;
int N;
P A[300000];
multiset<int> os;

bool f(long long X) {
  multiset<int> s(os);
  multiset<int> g;
  long long t = 0;
  for (int i=0; i<X-1; i++) {
    int x = A[i].second;
    s.erase(s.find(x));
    g.insert(x);
    t += x;
  }

  for (int i=0; i<N-X+1; i++) {
    int x = A[i].second;
    long long b = (long long)A[i].first * X - x;
    auto it = g.find(x);
    if (it != g.end()) {
      g.erase(g.find(x));
      long long d = *s.begin();
      s.erase(s.begin());
      g.insert(d);
      t += d - x;
    }
    else s.erase(s.find(x));
    if (t <= b) return true;
  }
  return false;
}

int main() {
  cin >> N;
  for (int i=0; i<N; i++) {
    int a, b;
    cin >> a >> b;
    A[i] = P(b, a);
  }
  sort(A, A+N);
  for (int i=0; i<N; i++) os.insert(A[i].second);

  int lo = 0, hi = N+1;
  while (hi - lo > 1) {
    int mid = (lo + hi) / 2;
    if (f(mid)) lo = mid;
    else        hi = mid;
  }
  cout << lo << "\n";
  return 0;
}

Measured memory_bytes: 33560
#include<stdio.h>
long long int fact[2000006];
long long int inv[2000006];
long long int modpow(long long int a, long long int n, long long int p)
{
	if (n < 0)
		return 0;
	long long int res = 1;
	while (n > 0)
	{
		if (n % 2 > 0)
			res = res * a % p;
		a = a * a % p;
		n /= 2;
	}
	return res;
}
long long int g(long long int r, long long int c, long long int p)
{
	long long int i;
	long long int res = 0;
	for (i = 0; i <= r; i++)
		res = (res + fact[i + c + 1] * inv[i + 1] % p) % p;
	return res * inv[c] % p;
}
int main()
{
	long long int r1, r2, c1, c2;
	scanf("%lld %lld %lld %lld", &r1, &c1, &r2, &c2);
	long long int p = 1000000007;
	long long int i;
	fact[0] = 1;
	for (i = 1; i < 2000006; i++)
		fact[i] = fact[i - 1] * i % p;
	for (i = 0; i < 2000006; i++)
		inv[i] = modpow(fact[i], p - 2, p);
	printf("%lld\n", (g(r2, c2, p) - g(r2, c1 - 1, p) - g(r1 - 1, c2, p) + g(r1 - 1, c1 - 1, p) + 2 * p) % p);
	return 0;
}

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

int main() {
    int N, sum = 0;
    cin >> N;
    vector<int> X(N);
    for (int i = 0; i < N; i++) {
        cin >> X.at(i);
        sum += X.at(i);
    }
    sum = round(sum / (double)N);
    int ans = 0;
    for (auto i : X) {
        ans += (i - sum) * (i - sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3676
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	ll n, h;
	vector<ll> v1, v2;
	ll sum = 0;

	cin >> n >> h;

	REP(i, n) {
		ll a, b;
		cin >> a >> b;
		v1.push_back(a);
		v2.push_back(b);
	}

	sort(v1.begin(), v1.end(), greater<ll>());
	sort(v2.begin(), v2.end(), greater<ll>());

	vector<ll> v;

	REP(i, n) {
		if (v1[0] >= v2[i]) {
			break;
		}
		else {
			sum += v2[i];
			v.push_back(v2[i]);
		}
	}

	if (sum >= h) {
		ll ans = 0;
		for (int i = 0; h > 0; i++) {
			h -= v[i];
			ans++;
		}
		cout << ans << endl;
	}
	else {
		h -= sum;
		if (h % v1[0] == 0) {
			cout << v.size() + h / v1[0] << endl;
		}
		else {
			cout << v.size() + h / v1[0] + 1 << endl;
		}
	}
}

Measured memory_bytes: 3308
import sys
def input(): return sys.stdin.readline().strip()
n,y=map(int,input().split())
for i in range(n+1):
    if 10000*i+5000*(n-i) < y:
        continue
    for g in range(n+1-i):
        if 10000*i+5000*g+1000*(n-g-i)==y:
            print(i,g,n-g-i)
            sys.exit()
print(-1,-1,-1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long

int b,r,n;

int32_t main()
{
	cin >> n >> b >> r;
	if(b+r < n)
	{
		int x = n - (b+r);
		if(x <= b)
			cout << b+x << '\n';
		else
		{
			int y = x/(b+r);
			int resp = b + b*y + min(b, x%(b+r));
			cout << resp << '\n';
		}
			
	}
	else
	{
		if(b >= n)
			cout << n << '\n';
		else
			cout << b << '\n'; 
	} 
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

r = INT()
print(3*r**2)

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

typedef long long ll;

const int P = 1000000007;

int n, m, fa[1005], fa_w[1005], dep[1005], pw[2005];
bool on_mst[2005];
vector<int> g[1005];
ll X, mst;
struct edge {
	int u, v, w;
} e[2005];
bool operator<(const edge &a, const edge &b) {
	return a.w < b.w;
}

int find(int x) {
	return !fa[x] ? x : fa[x] = find(fa[x]);
}

void dfs(int u) {
	for (int x : g[u]) {
		int v = e[x].u + e[x].v - u;
		if (v != fa[u]) {
			fa[v] = u;
			fa_w[v] = e[x].w;
			dep[v] = dep[u] + 1;
			dfs(v);
		}
	}
}

int main() {
	scanf("%d%d%lld", &n, &m, &X);
	for (int i = pw[0] = 1; i <= m; ++i)
		scanf("%d%d%d", &e[i].u, &e[i].v, &e[i].w), pw[i] = pw[i - 1] * 2 % P;
	sort(e + 1, e + 1 + m);
	for (int i = 1; i <= m; ++i) {
		int s = find(e[i].u), t = find(e[i].v);
		if (s != t)
			g[e[i].u].push_back(i), g[e[i].v].push_back(i), fa[s] = t, mst += e[i].w, on_mst[i] = true;
	}
	if (X < mst) return puts("0"), 0;
	int ans1 = 0;
	if (X == mst) ans1 = (pw[m] + P - pw[m - n + 2]) % P;
	fa[1] = 0, dfs(1);
	int ans2 = 1, c = 0;
	for (int i = 1; i <= m; ++i)
		if (!on_mst[i]) {
			int u = e[i].u, v = e[i].v, mx = 0;
			while (u != v)
				if (dep[u] > dep[v]) mx = max(mx, fa_w[u]), u = fa[u];
				else mx = max(mx, fa_w[v]), v = fa[v];
			mx = e[i].w - mx;
			if (mst + mx > X) ans2 = 2 * ans2 % P;
			if (mst + mx == X) ++c;
		}
	ans2 = (pw[c] - 1ll) * 2 * ans2 % P;
	printf("%d\n", (ans1 + ans2) % P);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
    int N,W;
    cin >> N >> W;
    int v[N],w[N];
    for(int i=0;i<N;i++) cin >> v[i] >> w[i];
    ll dp[N][W+1]; //i番目までのみ使って重さj以下になる価値の最大値
    for(int i=0;i<=W;i++){
        if(i >= w[0]) dp[0][i]=v[0];
        else dp[0][i]=0;
    }
    for(int i=1;i<N;i++){
        for(int j=0;j<=W;j++){
            if(j >= w[i]) dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
            else dp[i][j] = dp[i-1][j];
        }
    }
    cout << dp[N-1][W] << endl;
}



Measured memory_bytes: 10916
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 2e5 + 17;

int n;
llong a[maxn], b[maxn], c[maxn];

bool read()
{
	if (scanf("%d", &n) != 1)
		return false;

	forn (i, n)
		scanf("%lld", a + i);

	return true;
}

void gen()
{
	n = 1 + mrand() % 10;

	forn (i, n)
		a[i] = 1 + mrand() % 11;
}

llong naive()
{
	forn (i, n)
		c[i] = b[i] = a[i];

	llong res = 0ll;

	while (true)
	{
		sort(b, b + n);
		reverse(b, b + n);

		if (b[0] < n)
			return res;
		
		++res;
		b[0] -= n;
		
		forn (j, n - 1)
			++b[j + 1];
	}
}

void solve()
{
	sort(a, a + n);
	reverse(a, a + n);
	llong ans = 0;
	llong wans;
#ifdef SEREZHKA
	wans = naive();
#endif
	a[n] = -linf;

	forn (i, n - 1)
	{
		if (a[0] - a[i] < n)
		{
			llong l = 1, r = (llong) 1e16;

			for (; l < r; )
			{
				llong m = (l + r) / 2;

				vector<llong> cur(a, a + n);

				forn (j, i + 1)
					cur[j] -= (m - 1) * (n - i);

				for (int j = i + 1; j < n; ++j)
					cur[j] += (i + 1) * (m - 1);

				bool good = true;

				forn (k, i + 1)
				{
					if (cur[i] < cur[i + 1])
					{
						good = false;
						break;
					}

					sort(cur.begin(), cur.begin() + i + 1);
					reverse(cur.begin(), cur.begin() + i + 1);

					forn (j, n)
						++cur[j];

					cur[0] -= n + 1;

					if (cur[0] < cur[i + 1])
					{
						good = false;
						break;
					}
				}

				if (!good)
					r = m;
				else
					l = m + 1;
			}

			ans += (l - 1) * (i + 1);

			forn (j, i + 1)
				a[j] -= (l - 1) * (n - i);

			for (int j = i + 1; j < n; ++j)
				a[j] += (i + 1) * (l - 1);
		}

		while (true)
		{
			sort(a, a + i + 2);
			reverse(a, a + i + 2);

			if (a[0] - a[i + 1] < n)
				break;

			if (min(a[0] - n, a[i + 1] + 1) < a[i + 2] + 1)
				break;

			a[0] -= n;
			++ans;

			forn (j, n - 1)
				++a[j + 1];
		}
	}

	ans += 1ll * n * max(0ll, a[n - 1] - n + 1);

	forn (i, n)
		a[i] -= max(0ll, a[n - 1] - n + 1);

	while (true)
	{
		sort(a, a + n);
		reverse(a, a + n);

		if (a[0] < n)
			break;

		a[0] -= n;
		++ans;

		forn (j, n - 1)
			++a[j + 1];
	}

#ifdef SEREZHKA
	if (ans != wans)
	{
		cout << n << endl;

		forn (i, n)
			cout << c[i] << ' ';

		cout << ans << ' ' << wans << endl;
	}
	else
		return ;
#endif

	printf("%lld\n", ans);
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

#ifdef SEREZHKA
	while (1)
	{
		gen();
		solve();
	}
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 2304
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int ansc = -1;
    int ansv = 0;
    for (int i = 1; i <= n; ++i)
    {
        int cnt = 0;
        int x = i;
        while (x % 2 == 0)
        {
            x /= 2;
            ++cnt;
        }
        if (cnt > ansc)
        {
            ansc = cnt;
            ansv = i;
        }
    }
    cout << ansv << endl;
}

Measured memory_bytes: 256
def resolve():
    A,B,K = map(int,input().split())
    cnt=0
    for i in range(1,min(A+1,B+1))[::-1]:
        if A % i == 0 and B % i == 0:
            cnt += 1
            ans = i
        if cnt == K:
            break
    print(ans)
resolve()

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

int main(){
  while(1){
    int a=0,b=0;
    string game;
    cin >> game;
    if(game=="0")
      break;
    for(int j=1;j<game.size();j++)
      (game[j]=='A')?a++:b++;
    a>b?a++:b++;
    cout << a << " " << b << endl;
  }
  return 0;
}

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

namespace D_ABC144
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            if (s[2] <= (double)s[0] * s[0] * s[1] / 2)
            {
                double art = (double)(s[1] * (s[0] * s[1])) / s[2] / 2;
                WriteLine(Atan((art)) * 180 / PI);
                return;
            }
            else
            {
                double art = (double)(2 * s[0] * s[0] * s[1] - 2 * s[2]) / (double)(s[0] * s[0] * s[0]);
                WriteLine(Atan((art)) * 180 / PI);
                return;

            }
            //            WriteLine(Atan((art))*180/PI);
            //          WriteLine(Atan2(3,16)*180/PI);
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    LL a, b;
    vector<int> bit_a;
    vector<int> bit_b;
    vector<int> xor_a;
    vector<int> xor_b;
    int tmp_bit_a, tmp_bit_b;
    LL ans=0;
    cin >> a >> b;
    if(a>0){
        a--;
    }
    // initial run
    tmp_bit_a=a%2;
    tmp_bit_b=b%2;
    bit_a.push_back(tmp_bit_a);
    bit_b.push_back(tmp_bit_b);
    xor_a.push_back(0);
    xor_b.push_back(0);
    a/=2;
    b/=2;
    while(b>0){
        tmp_bit_a=a%2;
        tmp_bit_b=b%2;
        bit_a.push_back(tmp_bit_a);
        bit_b.push_back(tmp_bit_b);
        xor_a.push_back(0);
        xor_b.push_back(0);
        a/=2;
        b/=2;
    }
    for(int i=bit_b.size()-1; i>0; i--){
        if(bit_a[i]==0){
            xor_a[i]=0;
        }else if(bit_a[0]==0){
            xor_a[i]=1;
        }else{
            xor_a[i]=0;
        }
        if(bit_b[i]==0){
            xor_b[i]=0;
        }else if(bit_b[0]==0){
            xor_b[i]=1;
        }else{
            xor_b[i]=0;
        }
    }
    if(bit_b.size()==1){
        xor_a[0]=bit_a[0];
        xor_b[0]=bit_b[0];
    }else{
        if(bit_a[0]==0 && bit_a[1]==0){
            xor_a[0]=0;
        }else if(bit_a[0]==1 && bit_a[1]==1){
            xor_a[0]=0;
        }else{
            xor_a[0]=1;
        }
        if(bit_b[0]==0 && bit_b[1]==0){
            xor_b[0]=0;
        }else if(bit_b[0]==1 && bit_b[1]==1){
            xor_b[0]=0;
        }else{
            xor_b[0]=1;
        }
    }

    for(int i=bit_b.size()-1; i>=0; i--){
        ans*=2;
        if((xor_a[i]+xor_b[i])%2==1){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

for i in range(1, N):
    if H[i] < H[i - 1]:
        H[i] += 1
for i in range(1, N):
    if H[i] < H[i - 1]:
        print('No')
        exit(0)
print('Yes')

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

using namespace std;

#define int long long

const int N = 2e5 + 100;

int dp[N][10], a[N];
int n, ans = 1e15;

inline int val(int ind, int t) {
	if (t == 0 || t == 4)
		return a[ind];
	if (t == 1 || t == 3) {
		if (a[ind] == 0)
			return 2;
		return a[ind] % 2;
	}
	return !(a[ind] % 2);	
}

int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < 5; j++) {
			dp[i][j] = 1e15;
			for (int k = 0; k <= j; k++)
				dp[i][j] = min(dp[i][j], dp[i - 1][k] + val(i, j));
		}
	}
	for (int i = 0; i < 5; i++)
		ans = min(ans, dp[n][i]);
	return cout << ans, 0;
}


Measured memory_bytes: 17408
package main

import(
	"fmt"
	"sort"
)

func main() {
	var a int
	var i int
	dataint := [10]int{}
	i = 0
	for _, err := fmt.Scan(&a); err == nil; _, err = fmt.Scan(&a) {
		dataint[i] = a
		i++
	}
	sort.Ints(dataint[:])
	for i:=9; i>6; i--{
		fmt.Println(dataint[i])
	}
}


Measured memory_bytes: 1132
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int N,a,check=0;
  cin >> N;
  for(int i=0;i<N;i++) {
    cin >> a;
    if(a%2==0){
      if(a%3==0||a%5==0) ;
      else check--;
    }
  }
  if(check<0) cout << "DENIED" << endl;
  else cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int m = int.Parse(input[1]);
            int totalTime = 0;

            MyQueue nameQueue = new MyQueue();
            MyQueue timeQueue = new MyQueue();

            // Add
            for (int i = 0; i < n; i++)
            {
                string[] nameAndQtime = Console.ReadLine().Split();
                string name = nameAndQtime[0];
                int time = int.Parse(nameAndQtime[1]);

                //enqueue
                nameQueue.Enqueue(name);
                timeQueue.Enqueue(time);
            }
            
            // Proccess
            for (int i = 0; !timeQueue.IsEmpty() ;i++)
            {
                //dequeue
                var deqT = timeQueue.Dequeue();
                var deqN = nameQueue.Dequeue();
                if (m < (int)deqT)
                {
                    //enqueue again
                    timeQueue.Enqueue((int)deqT - m);
                    nameQueue.Enqueue(deqN);
                    totalTime += m;
                }
                else
                {
                    // dequeue
                    //Console.WriteLine("the process done is");
                    Console.WriteLine(deqN + " " + ((int)deqT + totalTime)); 
                    totalTime += (int)deqT;
                }
            }
        }
    }
}
    
public class MyQueue
{
    private int _qMaxSize = 100000;
    private int _head;
    private int _tail;
    private object[] _Q;
        
    // init
    public MyQueue() {
        _Q = new Object[_qMaxSize];
        _head = 0;
        _tail = 0;
    }

    public void Enqueue(object obj)
    {
        if (IsFull())
        {
            throw new OverflowException();
        }

        _Q[_tail] = obj;

        _tail = (_tail + 1 == _qMaxSize) ? _tail = 0 : _tail += 1;
    }

    public object Dequeue()
    {
        if (IsEmpty())
        {
            //TODO UNDERFLAW EXCEPTION
        }

        object deq = _Q[_head];
        _head = (_head + 1 == _qMaxSize) ? _head = 0 : _head += 1;
        return deq;
    }

    public bool IsFull()
    {
        return _head == (_tail + 1) % _qMaxSize;
    }

    public bool IsEmpty()
    {
        return _head == _tail;
    }
}


Measured memory_bytes: 24740
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<iomanip>
#include<cstring>
#include<string>
#include<set>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll = long long int;

const ll INF = 1<<30;
const ll LINF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(void) {
    int n; cin >> n;
    map<string, int> mp;
    REP(i, n) {
        string s; cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}

Measured memory_bytes: 3628
//ABC162_A
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	string s;
	cin >> s;
	bool ok = 0;
	for(int i = 0;i < s.size();i++)if(s[i] == '7')ok = 1;
	if(ok)cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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


int main ()
{
string s1;
string s2[1010];
string tmp;
cin >> s1;
std::transform(s1.begin(), s1.end(), s1.begin(), (int (*)(int))std::toupper);
int i=0;
while(cin >> tmp){
	if(tmp == "END_OF_TEXT") break;
	std::transform(tmp.begin(), tmp.end(), tmp.begin(), (int (*)(int))std::toupper);
	s2[i] = tmp;
	i++;
}

int count = 0;

for(int i=0; i<1000; i++){
	if(s1 == s2[i]) count++;
}

cout << count << endl;












}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
using namespace std;

bool dprime[1000000]={false};
void dPrime(){
	dprime[1]=true;
	for(int i=2;i*i<1000000;i++){
		if(!dprime[i]){
			for(int j=2*i;j<1000000;j+=i){
				dprime[j]=true;
			}
		}
	}

	return;
}

int main(){
	dPrime();
	int n,a,d;
	while(cin>>a>>d>>n&&a&&d&&n){
		int count=0;
		for(int i=a;;i+=d){
			if(!dprime[i]) count++;
			if(count==n){
				p(i);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 4028
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
    

        static void Main(string[] args)
        {
            var X = long.Parse(Console.ReadLine());
            //var c = Console.ReadLine();
            //var ABN = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var A = 0;
            var B = 0;
            var flg = true;
            for (int i = 1; flg && i <= 200; i++)
            {
                for (int j = -200; j <= 200; j++)
                {
                    if(X == (long)(Pow(j, 5) - Pow(j - i, 5)))
                    {
                        A = j;
                        B = j - i;
                        flg = false;
                    }
                }
            }
            Console.WriteLine(A+" "+B);
        }

    }

}


Measured memory_bytes: 27828
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;

int gcd(int a, int b) {//最大公約数
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {//最小公倍数
	int g = gcd(a, b);
	return a / g * b;
}

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

	int X; cin >> X;

	int tmp = lcm(X, 360LL);
	
	cout << tmp / X << endl;


	return 0;
}



Measured memory_bytes: 3648
#pragma GCC optimize(2)
#include<bits/stdc++.h> 
using namespace std;
#define ll long long
#define endl "\n"
const int MAX=1e6+7;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
	string s;cin>>s;
	int siz=s.size();
	 if(s[siz-1]=='s') s+="es"; 
	 else s+='s';
	cout<<s;
   return 0;
} 

Measured memory_bytes: 3616
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
dp=[[0]*3 for i in range(n+1)]
for i in range(3):
  dp[1][i]=l[0][i]
for i in range(2,n+1):
  for j in range(3):
    for k in range(3):
      if j!=k:
        dp[i][j]=max(dp[i-1][k]+l[i-1][j],dp[i][j])
print(max(dp[n]))

Measured memory_bytes: 47344
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
#define _GLIBCXX_DEBUG
int mod = 1e9+7;

int main() {
  ll n; cin >> n;
  ll ten=1, nine=1, eight = 1;
  rep(i,n){
    ten *= 10;
    ten %= mod;
    nine *= 9;
    nine %= mod;
    eight *= 8;
    eight %= mod;
  }


  ll ans;
  ans = ten - nine*2 + eight;
  ans += mod*2;
  ans %= mod;
  cout << ans << endl;
}


Measured memory_bytes: 3568
// A.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <set>
#include <map>
#include <bitset>

using namespace std;

int main(int argc, char* argv[]) {
	int a[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int k;
	cin >> k;
	cout << a[k - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

struct edge { int to, cost; };
vector<edge> G[200000];
vector<ll> d(200000, INF);

void dijkstra(int s) {
	priority_queue<P, vector<P>, greater<P> > que;
	d[s] = 0;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		REP(i,G[v].size()) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main(){
    int k;
	cin >> k;
	for(int i = 0;i < k - 1;i++)
		G[i].push_back({i+1,1});
	G[k-1].push_back({0,1});
	for(int i = 0;i < k;i++)
		G[i].push_back({(i*10)%k,0});
	dijkstra(1);
	cout << d[0]+1 << endl;
	return 0;
}

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


int mypow(int x, int y) {
    int ret = 1;
    while(y > 0) {
        ret *= x;
        y--;
    }
    return ret;
}
int main() {
    int t, num;
    while(cin >> t >> num, t) {
        vector<vector<vector<int>>> ret(1000000);
        ret[num].push_back({num});

        for(int i=1; i<(1<<5); ++i) {
            int top = 0;
            for(int j=4; j>=0; --j) {
                if((i >> j) % 2 == 1) {
                    top = j;
                    break;
                }
            }
            if(mypow(10, top+1) > num) {
                break;
            }
            int rest = num;
            vector<int> v2;
            int sum=0;
            int prev_b = -1;
            for(int b=0; b<5; ++b) {
                if((i >> b) % 2 == 1) {
                    int tmp = 0;
                    if(prev_b != -1) {
                        tmp = mypow(10, b - prev_b);
                    } else {
                        tmp = mypow(10, b+1);
                    }
                    v2.push_back(rest % tmp); // todo
                    sum += rest % tmp;
                    rest /= tmp;
                    prev_b = b;
                    if(rest == 0) {
                        break;
                    }
                }
            }
            if(rest != 0) {
                v2.push_back(rest);
            }
            sum += rest;
            //cout << "rest = " << rest << "   sum=" << sum << endl;
            //cout << endl;
            //for(auto x : v2) {
            //    cout << x << endl;
            //}
            //cout << endl;
            if(sum == 0) {
                continue;
            }
            ret[sum].push_back(v2);
        }

        bool finded = false;
        for(int i=t; i>=0; --i) {
            if(ret[i].size() >= 2) {
                cout << "rejected" << endl;
                finded = true;
                break;
            } else if(ret[i].size() == 1) {
                finded = true;
                cout << i << " ";
                reverse(ret[i][0].begin(), ret[i][0].end());
                for(int j=0; j<ret[i][0].size()-1; ++j) {
                    cout << ret[i][0][j] << " ";
                }
                cout << ret[i][0][ret[i][0].size()-1] << endl;
                break;
            }
        }
        if(!finded) {
            cout << "error" << endl;
        }
    }
}


Measured memory_bytes: 26564
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int n,x=0;
  	cin >> n;
  	for(int i=1;i<=n;i++){
    	int a = i*1.08;
      	if(a==n) {x=i; break;}
    }
  	if(x==0) cout << ":(" << endl; 
  	else cout << x << endl;
}

Measured memory_bytes: 3628
#include <iostream>

int main()
{
    int n, x, t;
    std::cin >> n >> x >> t;

    int sumtime = 0, timecount = 0;

    timecount = n / x;

    if (n % x != 0)
    {
        timecount++;
    }
    sumtime = timecount * t;

    std::cout << sumtime;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int> ;
using vi = vector<int> ;
using vll = vector<long long>;

int main(){
  ll k, x;
  cin >> k >> x;

  if(k * 500 >= x){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;

	int n;
	cin >> n;
	
	int ans = 0;
	int mini = inf;
	
	for(int i=1 ; i<=n ; i++)
	{
		int x;
		cin >> x;
		
		if(mini > x)
			ans++;
		mini = min(mini , x);
	}
	
	cout << ans;
}



Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n, d, a, ans = 0;
  scanf("%lld%lld", &n, &k);
  bool flg[n];
  for(i = 0; i < n; ++i) flg[i] = true;
  for(i = 0; i < k; ++i) {
    scanf("%lld", &d);
    for(j = 0; j < d; ++j) scanf("%lld", &a), flg[--a] = false;
  }
  for(i = 0; i < n; ++i) ans += flg[i];
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 1732
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

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

  int N, Q;
  cin >> N >> Q;

  vector<int> a;
  rep(i, N) {
    int v;
    cin >> v;
    a.push_back(v);
  }

  vector<int64_t> b(1, 0), c(1, 0);
  rep(i, N) {
    b.push_back(a[i]);
    c.push_back(a[i]);
  }
  irep(i, N - 2) { b[i + 2] += b[i]; }
  rep(i, N) { c[i + 1] += c[i]; }

  rep(i, Q) {
    int x;
    cin >> x;

    constexpr int INF = 1'000'000'000;
    int ok = 0, ng = INF;
    while (ng > ok + 1) {
      int mid = (ng + ok) / 2;

      int l = lower_bound(a.begin(), a.end(), x - mid) - a.begin();
      int r = lower_bound(a.begin(), a.end(), x + mid) - a.begin();

      (r <= N - (r - l) ? ok : ng) = mid;
    }
    int l = lower_bound(a.begin(), a.end(), x - ok) - a.begin();
    int r = lower_bound(a.begin(), a.end(), x + ok) - a.begin();
    int j = N - (r - l);
    // cerr << l << " " << r << " " << j << "\n";

    int64_t result = c[N] - c[j];
    // cerr << c[N] << " " << c[j] << " " << c[j - 1] << "\n";
    if (r != j) {
      result += a[j - 1];
    }
    if (r + 1 == j) {
      l--;
    }
    if (l >= 0) {
      result += b[l];
    }
    cout << result << "\n";
  }

  return 0;
}

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

//using namespace--------------------------------------------------------------------------------------------------------------
using namespace std;

//define-----------------------------------------------------------------------------------------------------------------------
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1 << 25
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cerr << #x << " = " << (x) << "\n";
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)

//typedef----------------------------------------------------------------------------------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned int uint;
typedef unsigned long long ull;

//const------------------------------------------------------------------------------------------------------------------------
const double EPS = 1e-10;
const double PI = acos( -1.0 );

//global-----------------------------------------------------------------------------------------------------------------------
int n;
int ar[ 10000 ];

//function---------------------------------------------------------------------------------------------------------------------
int main() {
	while ( scanf( "%d", &n ) ) {
		if ( n == 0 ) {
			return 0;
		}
		rep( i, 10000 ) {
			ar[ i ] = 0;
		}
		int mx = 0;
		rep( i, n ) {
			int numbar, one, two;
			scanf( "%d %d %d", &numbar, &one, &two );
			ar[ numbar - 1 ] = one + two;
			if ( ar[ mx ] < ar[ numbar - 1 ] ) {
				mx = numbar - 1;
			}
		}
		printf( "%d %d\n", mx + 1, ar[ mx ] );
	}
	return 0;
}

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

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        String t = in.next(); // s muss t enthaalen
        int count = 0;
        int min = 9999;
        for (int i = 0; i <= s.length()-t.length(); i++) {
            count = 0;
            for (int j = 0; j < t.length(); j++) {
                if(s.charAt(i+j)==t.charAt(j)){
                    
                } else {
                    count++;
                    
                }
   
            }
            if(min>count){
                min = count;
            }
        }
        if(s.contains(t)){
            System.out.println(0);
        } else
        System.out.println(min);
    }
}


Measured memory_bytes: 36200
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;
 
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
 
template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}
 
// ------------------------------------------------------------------------------------------
 
map<vector<int>, int> mp;
 
void init() {
   vector<int> v(8);
   iota(all(v), 0);
   mp[v] = 0;

   queue<vector<int>> que;
   que.push(v); // 最終状態をpush
   while (que.size()) {
      vector<int> cur = que.front(); que.pop();
      int idx = find(all(cur), 0) - cur.begin();
 
      rep (k, 4) {
         int nx = (idx / 4) + dx[k];
         int ny = (idx % 4) + dy[k];
         if (nx < 0 || nx >= 2 || ny < 0 || ny >= 4) continue;
         int nc = nx * 4 + ny;
         vector<int> tmp = cur;
         swap(tmp[nc], tmp[idx]);
         if (mp.count(tmp)) continue;
         mp[tmp] = mp[cur] + 1;
         que.push(tmp);
      }
   }
}
 
int main() {
   init();
 
   vector<int> vs(8);
   while (cin >> vs[0]) {
      repp (i, 1, 8) cin >> vs[i];
      cout << mp[vs] << endl;
   }
 
   return 0;
}


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

int main(){
  long n, k;
  cin >> n >> k;
  long r=n/k;
  if(k%2==1){
    cout << r*r*r;
  }
  else {
    long t=2*n/k-n/k;
    cout << r*r*r+t*t*t;
  }
  return 0;
}

Measured memory_bytes: 256
fn main() {
    let stdin = std::io::stdin();
    let mut sc = Scanner::new(stdin.lock());
    let n: usize = sc.read();
    let mut counter = 0isize;
    let mut answer = true;
    for _ in 0..n {
        let s: String = sc.read();
        if s == "A" {
            counter += 1;
        } else {
            counter -= 1;
        }
        if counter < 0 {
            answer = false;
        }
    }
    answer = answer && counter == 0;
    println!("{}", if answer { "YES" } else { "NO" });
}

pub struct Scanner<R> {
    reader: R,
}

impl<R> Scanner<R> {
    pub fn new(reader: R) -> Scanner<R> {
        Scanner { reader }
    }
}

fn is_whitespace(b: u8) -> bool {
    b == b' ' || b == b'\n' || b == b'\r' || b == b'\t'
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        let buf = std::io::Read::bytes(self.reader.by_ref())
            .map(|b| b.expect("Read failed"))
            .skip_while(|&b| is_whitespace(b))
            .take_while(|&b| !is_whitespace(b))
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error")
    }

    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}



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

const int N=2e4+10,Node=N<<2;

int n,L,node,num[N<<3],tot,pos[N],x[N],y[N];

struct Edge{ int to,next; } way[N*100];

struct Node{
	int v,id;
	bool operator < ( const Node &A ) const { return v<A.v; }
}p[N<<1];

void Add(int a,int b) { way[++tot]=(Edge){b,num[a]}; num[a]=tot;  }

struct SegmentTree{
	#define ls z<<1
	#define rs z<<1|1
	int root,id[Node];
	
	void build(int z,int l,int r) {
		if (l==r) {
			if (p[l].id>n) id[z]=p[l].id-n;
			else id[z]=p[l].id+n;
			pos[p[l].id]=l;
			return ;
		}
		int mid=(l+r)>>1;
		build(ls,l,mid);
		build(rs,mid+1,r);
		id[z]=++node; 
		Add(id[z],id[ls]); Add(id[z],id[rs]);
	}
	
	void insert(int z,int l,int r,int ql,int qr,int ind) {
		if (ql<=l && r<=qr) { 
			Add(ind,id[z]); 
			return ; 
		}
		int mid=(l+r)>>1;
		if (ql<=mid) insert(ls,l,mid,ql,qr,ind);
		if (qr>mid)  insert(rs,mid+1,r,ql,qr,ind);
	}
	
}st;

void Init() {
	scanf("%d",&n);
	for (int i=0;i<n;++i) {
		scanf("%d%d",&x[i+1],&y[i+1]);
		p[i<<1].v=x[i+1]; p[i<<1|1].v=y[i+1];
		p[i<<1].id=i+1,p[i<<1|1].id=i+n+1;
	}
}

int top,dfn[N<<3],cntdfn,que[N<<3],cntbcc,low[N<<3],col[N<<3];
bool inq[N<<3],vis[N<<3];
void Dfs(int x) {
	dfn[x]=++cntdfn; low[x]=dfn[x]; 
	inq[x]=1; vis[x]=1; que[++top]=x;
	for (int i=num[x];i;i=way[i].next) {
		int v=way[i].to;
		if (!vis[v]) {
			Dfs(v);
			low[x]=std::min(low[x],low[v]);
		}else if (inq[v]) low[x]=std::min(low[x],dfn[v]);
	}
	if (dfn[x]==low[x]) {
		++cntbcc;
		que[top+1]=0;
		while (que[top+1]!=x) {
			col[que[top]]=cntbcc;
			inq[que[top]]=0;
			top--;
		}
	}
}

void Tarjan() {
	for (int i=1;i<=node;++i) vis[i]=0,col[i]=0;
	for (int i=1;i<=node;++i) if (!vis[i]) 
		Dfs(i);
}

int find(int a) {
	int l=1,r=n<<1;
	while (l<=r) {
		int mid=(l+r)>>1;
		if (p[mid].v<a) l=mid+1;
		else r=mid-1;
	}
	return l;
}

int put[N<<3],pt;
bool Check(int ans) {
	tot=pt;
	for (int i=1;i<=node;++i) num[i]=put[i];
	int l,r;
	for (int i=1;i<=n;++i) {
		l=find(x[i]-ans+1); r=find(x[i]+ans)-1;
		if (l<=r) {
			if (pos[i]>l) st.insert(st.root,1,L,l,pos[i]-1,i);
			if (pos[i]<r) st.insert(st.root,1,L,pos[i]+1,r,i);
		}
		l=find(y[i]-ans+1); r=find(y[i]+ans)-1;
		if (l<=r) {
			if (pos[i+n]>l) st.insert(st.root,1,L,l,pos[i+n]-1,i+n);
			if (pos[i+n]<r) st.insert(st.root,1,L,pos[i+n]+1,r,i+n);
		}
	}
	Tarjan();
	for (int i=1;i<=n;++i) if (col[i]==col[i+n]) return 0;
	return 1;
}

void Solve() {
	L=n<<1;
	std::sort(p,p+2*n); for (int i=2*n;i>=1;--i) p[i]=p[i-1];
	st.root=1; node=2*n;
	st.build(st.root,1,L);
	for (int i=1;i<=node;++i) put[i]=num[i]; pt=tot;
	int l=1,r=1e9;
	while (l<=r) {
		int mid=(l+r)>>1;
		if (Check(mid)) l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",r);
}

int main() {
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<int> T(N);
    int sum = 0;
    rep(i, N) {
        cin >> T[i];
        sum += T[i];
    }
    int M;
    cin >> M;
    rep(i, M) {
        int P, X;
        cin >> P >> X;
        cout << sum - T[P - 1] + X << endl;
    }
    return 0;
}

Measured memory_bytes: 256