akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define MAX 100
#define INFTY 1<<21
#define WHITE 0
#define GRAY  1
#define BLACK 2

int n , M[MAX][MAX];

void dijkstra() {
  int i,v,u,minv;
  int d[MAX],p[MAX],color[MAX];

  for(i = 0;i<n;i++) {
    d[i] = INFTY;
    color[i] = WHITE;
  }
  d[0] = 0;
    color[0]  = 0;
  while(1) {
    minv = INFTY;
    u = -1;
    for(i = 0;i<n;i++) {
      if(minv > d[i] && color[i] != BLACK) {
        u = i;
        minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(v = 0;v<n;v++) {
      if(color[v] != BLACK && M[u][v] != INFTY) {
      if(d[v] > d[u] + M[u][v]) {
        d[v] = d[u] + M[u][v];
        color[v] = GRAY;
      }
      }
    }
  }

  for(i = 0;i<n;i++) {
    printf("%d %d\n", i,d[i] == INFTY? -1 : d[i] );
  }
}

int main() {
  int i,j,k,c,u,v;
  scanf("%d\n", &n);

  for(i = 0;i<n;i++) {
    for(j=0;j<n;j++) {
      M[i][j] = INFTY;
    }
  }

   for( i = 0;i<n;i++)  {
     scanf("%d%d\n", &u , &k);
     for( j = 0;j<k;j++) {
       scanf("%d%d\n", &v,&c);
       M[u][v] =c;
     }
   }
    dijkstra();

  return 0;
}

Measured memory_bytes: 640
x=int(input())
if x<100:
  print(0)
  exit()
elif 100<=x<=105:
  print(1)
  exit()
else:
  DP=[False]*(x+1)
  for i in range(x+1):
    coin=list(range(100,106,1))
    if i in coin:
      DP[i]=True
      continue
    DP[i]=True if any(DP[i-m] for m in coin) else False
  print(1 if DP[x]==True else 0)

Measured memory_bytes: 3828
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;


int main()
{
	int n;
	cin>>n;
	vector<ll> l(n);
	ll sum = 0;
	ll lmax = 0;
	for(int i = 0 ; i < n; i++){
		cin>>l[i];
		sum += l[i];
		lmax = max(lmax,l[i]);
	}
	sum = sum - lmax;
	if( sum > lmax){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	lli N, K;
	cin >> N >> K;
	vector<lli> v(N);

	for (lli i = 0; i < N; i++) {
		cin >> v[i];
	}
	//keyの数字で次に対になる要素
	map<lli, lli> se;

	//i番目の要素の対の要素番号
	vector<lli> range_pair(N);
	iota(range_pair.begin(), range_pair.end(), 0);

	//対になるのを決定する(NlogN)
	for (lli i = 0; i < N; i++) {
		if (se.count(v[i])) {
			swap(range_pair[se[v[i]]], range_pair[i]);
		}
		se[v[i]] = i;
	}
	//周期は最大でもN
	vector<lli> dp(N + 1);
	//0回目及び周期に達したら空文字列
	dp[0] = N;
	//周期iにおいてdp[i]文字目から始まる
	lli beg = 0;
	//周期
	lli moddl = 0;

	//range_pair[beg] <= begで1周期またぐためdpにbegを保存

	for (int i = 1; i <= N;) {
		if (range_pair[beg] <= beg) {
			dp[i] = beg;
			i++;
		}
		//文字は再代入されないためbegはrange_pair[beg] + 1
		beg = range_pair[beg] + 1;

		//周期の終わり
		if (beg == N) {
			moddl = i;
			break;
		}
	}
	//周期のmodをとる
	K %= (moddl);
	for (lli i = dp[K]; i < N; i++) {
		//dp[K]文字目以降でペアがあったら除外する
		if (range_pair[i] > i) {
			i = range_pair[i];
			continue;
		}
		cout << v[i];
		if (i == N - 1) {
			cout << endl;
		}
		else {
			cout << " ";
		}
	}
	return 0;
}


Measured memory_bytes: 18688
#include <iostream>
#include<algorithm>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int A[100050],B[100050];
int n;
int main(int argc, char** argv) 
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>A[i];
		B[A[i]]=i;
	}
	sort(A+1,A+n+1);
	for(int i=1;i<=n;i++)cout<<B[A[i]]<<" ";
	return 0;
}

Measured memory_bytes: 1536
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0260 >
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

//ll dp[65050][65050];
ll dp[2][65050];
ll solve(ll n){
    for(int i = 0; i < 65050;i++) dp[0][i] = dp[1][i] = 0;
    ll res = 0;
    vector<ll> P(n); for(auto& in:P) cin >> in;
    vector<ll> J(n-1); for(auto& in:J) cin >> in;
    sort(J.rbegin(),J.rend());
    vector<ll> cusum(n); for(int i = 0; i < n-1;i++) cusum[i+1] = cusum[i] + J[i];
    ll Sum = accumulate(P.begin(),P.end(),0LL);

    for(int i = 0; i < n;i++){
        res = max(res,(n-i)*(Sum+cusum[i]));
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll n;
    while(cin >> n,n){
        cout << solve(n) << endl;
    }
    return 0;
}



Measured memory_bytes: 5436
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

signed main() {
	int n; cin >> n;
	string s; cin >> s;
	int cnt = 0;
	for (int i = 0; i < n - 2; ++i) {
		if (s.substr(i, 3) == "ABC")
			++cnt;
	}
	cout << cnt << endl;
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  
  string ans = "Yes";
  
  for (int i = 0; i < s.size(); i++) {
    if (i % 2 == 0 && (s[i] == 'R' || s[i] == 'U' || s[i] == 'D')) {
      continue;
    } else if (i % 2 == 1 && (s[i] == 'L' || s[i] == 'U' || s[i] == 'D')) {
      continue;
    } else {
      ans = "No";
      break;
    }
  }
    
  cout << ans << endl;
 
  return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

void compute() {

}

const ll mod = 1000000007LL;
ll cnt[30];
ll dp[27];

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep(i,n) ++cnt[s[i]-'a'];
  dp[0] = 0;
  rep(i,26) {
    dp[i+1] = dp[i];
    ( dp[i+1] += cnt[i] ) %= mod;
    ( dp[i+1] +=  ( ( dp[i] * cnt[i] ) % mod ) ) %= mod;
  }
  cout << dp[26] << endl;
  compute();
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll N, K;
    cin >> N >> K;
    rep(i, 0, N){
        ll a; cin >> a;
    }

    ll ans = (N-1 + K - 2)/(K-1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int r;
  cin >> r;
  cout << r * r << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 256
N = int(input())
C = list(input())

move_right = 0
move_left = N-1

count = 0

while move_right < move_left:
    if C[move_right] == 'R':
        move_right += 1

    else:
        while C[move_left] != 'R' and move_left >= 0:
            move_left -= 1

        if move_left <= move_right:
            # 入れ替えできるものがなかったので置き換え
            if C[move_right + 1] == 'R':
                count += 1

        # 入れ替え
        elif C[move_left] == 'R':
            count += 1

        move_right += 1
        move_left -= 1


print(count)


Measured memory_bytes: 10784
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
const int N = 35;
const int M = 1e4;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0); 

int main(){
	double r;
	cin >> r;
	printf("%.16f",2*PI*r);
	return 0;
}

Measured memory_bytes: 3784
s=input()
ACGT=["A","C","G","T"]
moji=[]
for i in range(len(s)):
    #print(moji)
    if s[i] in ACGT:
        moji.append(s[i])
        for j in range(i+1,len(s)):
            if s[j] in ACGT:
                moji[i]+=s[j]
            else:
                break
    else:
        moji.append("")
index=0
for i in moji:
    moji[index]=len(i)
    index+=1
print(max(moji))



Measured memory_bytes: 3060
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  int A, B, K;
  cin >> A >> B >> K;
  for(int i=A;i<B+1;i++){
    if(i-A<K || B-i<K){
      cout << i << endl;
    }
  }

}


Measured memory_bytes: 256
import numpy as np
N = int(input())
a = [int(input()) for _ in range(N)]
mod = 998244353
suma = sum(a)
memo = np.zeros((N+1, suma+1), dtype=np.int)
memo[0][0] = 1
memoe = np.zeros((N+1, suma+1), dtype=np.int)
memoe[0][0] = 1

ttl = 3
for i in range(N-1):
  ttl *=3
  ttl %= mod

for i in range(1, N+1):
  memotmp = memo[i-1]
  memotmpe = memoe[i-1]
  memotmp = np.concatenate((np.zeros((a[i-1]), dtype=np.int), memotmp),axis=1)
  memotmpe = np.concatenate((np.zeros((a[i-1]), dtype=np.int), memotmpe),axis=1)
  memo[i] = (memo[i-1]*2 + memotmp[:suma+1])%mod
  memoe[i] = (memoe[i-1] + memotmpe[:suma+1])%mod

ans = sum(memo[N][(suma-1)//2+1:])
if suma%2==0:
  ans -= memoe[N][suma/2]
  
print(((ttl - ans*3)%mod+mod)%mod)

Measured memory_bytes: 435644
#include <bits/stdc++.h>
const int mod=1e9+7;
using namespace std;
#define ll long long
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m,k;
    cin>>n>>m;
    if(n*2>m){
        k=m/2;
    }
    else{
        k=n;
        m-=n*2;
        k+=m/4;
    }
    cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	int x;
	int s=0;
	int m[1000];
	cin>>n>>x;
	for(int i=0;i<n;i++)
	{
		cin>>m[i];
		x-=m[i];
	}
	sort(m,m+n);
	s+=x/m[0]+n;
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <utility>
#include<bits/stdc++.h>
#define ull unsigned long long int
#define ll int
#define ld long double
// #define loop(i,a,b) for(ll i=a;i<b;i++)
// #define inll(n) ll n;cin>>n;
// #define instr(s)  string s;cin>>s;
// #define inarr(a,n)  ll*a = new ll[n];loop(i,0,n)cin>>a[i]; 
// #define invec(v,n)  vector<ll> v(n);loop(i,0,n)inll(v[i])
// #define arr(a,n) ll*a = new ll[n];
// #define outarr(a,n) loop(i,0,n)cout<<a[i]<<" ";cout<<endl;
#define pb push_back
#define mp make_pair
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector <int>
#define vb vector <bool>
#define vll vector <ll>
#define vc vector <char>
#define clr(a) memset(a,0,sizeof(a))
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define infd 1e+18
#define inf 101901199101
#define mod 1000000007

inline ll min(ll a,ll b)
{
    return (a<b?a:b);
}
inline ll max(ll a,ll b)
{
    return (a<b?b:a);
}

using namespace std;
int main()
{fastio
    ll a,b;cin>>a>>b;
    set<ll> s{1,2,3};
    s.erase(a);
    s.erase(b);
    cout<<*(s.begin())<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ii pair<double,double> 
int main() {
   
  int n;
  cin>>n;
  vector<int> p(n);
  vector<int> fact(n+1);
  fact[0]=fact[1]=1;
  for(int i=2;i<=n;i++)fact[i]=i*fact[i-1];
  double ans=0.0;
  for(int i=0;i<n;i++)p[i]=i;
  vector<ii> v(n);
  for(int i=0;i<n;i++){
      int x,y;
      cin>>x>>y;
      v[i]={x,y};
  }
  do{
      double dis=0.0;
      for(int i=0;i<n-1;i++){
          dis+= sqrt((v[p[i]].f - v[p[i+1]].f)*(v[p[i]].f - v[p[i+1]].f) + (v[p[i]].s - v[p[i+1]].s)*(v[p[i]].s - v[p[i+1]].s));
          
      }
      ans+=dis;
  }while(next_permutation(p.begin(),p.end()));
  ans/=fact[n];
  cout<<fixed<<setprecision(9)<<ans;
}

Measured memory_bytes: 3764
N , M = map(int,input().split())
L = sorted(list(map(int,input().split())))
table =  [0,2,5,5,4,5,6,3,7,6]
L_val =sorted( list(map(lambda x:(table[x],x),L)))
number = ["0" for i in range(10**4+10)]

def comp(x,y):
    if len(x) >len(y):
        return 0
    elif len(x) < len(y):
        return 1
    else:
        for i in range(len(x)):
            if x[i] == y[i]:
                i+=1
            elif int(x[i]) < int(y[i]):
                return 1
            elif int(x[i]) > int(y[i]):
                return 0
        return 0



for x in L_val:
    number[x[0]] = str(x[1])

for i in range(10**4):
    tmp = number[i]
    if tmp=="0":
        continue
    for x in L_val:
        if  comp(number[i+x[0]],tmp + str(x[1])):
            number[i+x[0]] = tmp + str(x[1])

print(number[N])


Measured memory_bytes: 138200
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

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

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
	ll i, j;
	ll A, B;
	cin >> A >> B;
	cout << max(0LL, A - B * 2) << endl;

	return 0;
}


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

long long N, M, a[100009][3], maxn = -(1LL << 60);

int main()
{
	cin >> N >> M;
	for (int i = 1; i <= N; i++)
    {
		for (int j = 0; j < 3; j++)
            cin >> a[i][j];
	}

	for (int i = 0; i < 8; i++)
	{
		vector<long long>vec;
		for (int j = 1; j <= N; j++)
		{
			long long S = 0;
			for (int k = 0; k < 3; k++)
			{
			    if ((i / (1 << k)) % 2 == 0)
                    S += a[j][k];
                else
                    S -= a[j][k];
            }
			vec.push_back(S);
		}

		sort(vec.begin(), vec.end());
		reverse(vec.begin(), vec.end());

		long long ans = 0;
		for (int j = 0; j < M; j++)
        {
            ans += vec[j];
        }

		maxn = max(maxn, ans);
	}

	cout << maxn << endl;
	return 0;
}


Measured memory_bytes: 256
#考察はほとんどOK
n = gets.to_i
num = gets.strip.split.map(&:to_i)
rec = Array.new(4,0)
for i in 0..n-1
  rec[num[i]%4] += 1
end
if rec[2] == 0
  if rec[0] >= rec[1]+rec[3]-1
    puts "Yes"
  else
    puts "No"
  end
else
  if rec[0] >= rec[1]+rec[3]
    puts "Yes"
  else
    puts "No"
  end
end



Measured memory_bytes: 21668
a, op, b = input().split()
while op != "?":
	if op == "+":
		print(int(a) + int(b))
	elif op == "-":
		print(int(a) - int(b))
	elif op == "*":
		print(int(a) * int(b))
	else:
		print(int(int(a) / int(b)))
	a, op, b = input().split()


Measured memory_bytes: 5600
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{

	int x,y;
	cin >> x >> y;
	int ans=0;
	if(abs(x)==abs(y)){
		if(x==y){
			ans=0;
		}else{
			ans=1;
		}
	}else if(abs(x)<abs(y)){
		ans += abs(y)-abs(x);
		if(x<0){
			ans++;
		}
		if(y<0){
			ans++;
		}
	}else if(abs(x)>abs(y)){
		if(x>0){
			ans++;
		}
		ans+= abs(x)-abs(y);
		if(y>0){
			ans++;
		}
	}
	cout << ans << endl;	
	return 0;
}

Measured memory_bytes: 256
mymappend :: (a->[a])->[a]->[a]
mymappend _ [] = []
mymappend f (e:es) = mappend (f e) (mymappend f es)

manipu :: Int->Int->[Int]
manipu x b = manipu' (b*b)
  where
    manipu' :: Int -> [Int]
    manipu' c = if c<=x
                then c:(manipu' (c*b))
                else []

main = do
  x <- readLn :: IO Int
  putStrLn $ show $ maximum $ 1:(mymappend (manipu x) [2..1000])


Measured memory_bytes: 508
#include<iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
if (a>b){
cout <<"a > b"<<endl;
}
if (a<b){
cout <<"a < b"<<endl;
}
if (a==b)
cout <<"a == b"<<endl;
return 0;
}


Measured memory_bytes: 3088
import math
from itertools import combinations
from itertools import combinations_with_replacement
from itertools import product
from collections import defaultdict
from collections import deque
from collections import Counter
import heapq


def input_li():
    return list(map(int, input().split()))


N = int(input())
A_LI = input_li()
max_h = A_LI[0]
ans = 0
for i in range(1, N):
    if A_LI[i] < max_h:
        ans += max_h - A_LI[i]
    else:
        max_h = max(max_h, A_LI[i])
print(ans)


Measured memory_bytes: 106024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,i,cnt=0;
    cin>>a>>b;
    if(a==b)
        cout<<"Yay!"<<endl;
    if(a>b)
    {
        if(16-a>=a)
          cout<<"Yay!"<<endl;
        else
               cout<<":("<<endl;
    }
    else{
          if(b>a)
    {
        if(16-b>=b)
          cout<<"Yay!"<<endl;
        else
               cout<<":("<<endl;
    }
    }


    return 0;
}



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

int main()
{
    int n;
    string bg="", ed="";
    cin >> n;
    for(int i=0; i<n; i++)
    {
        int temp;
        cin >> temp;
        bg += temp + '0';
    }
    for(int i=0; i<n; i++)
    {
        int temp;
        cin >> temp;
        ed += temp + '0';
    }

    if(bg>ed)
    {
        swap(bg, ed);
    }
    int cnt = 0;
    while(bg!=ed){
        cnt ++;
        next_permutation(bg.begin(), bg.end());
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i, N) cin >> H[i];

    int max = 0, vec = 0;
    for (int i = 0; i < N-1; i++) {
        if (H[i] >= H[i+1]) vec++;
        if (H[i] < H[i+1] || i == N-2) {
            if (max < vec) max = vec;
            vec = 0;
        }
    }
    
    cout << max << endl;

    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int n,i,cnt,x[]={500,100,50,10,5,1};
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		n=1000-n; cnt=0;
		for(i=0;i<6;i++){
			if(n>=x[i]){
				cnt+=n/x[i];
				n%=x[i];
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int h, w;
int a[501][501];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  if (stream2 == NULL) return 0;
#endif
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
    }
  }
  vector<tuple<int,int,int,int> > v;
  bool ok[501];
  for (int i = 0; i < h; i++) ok[i] = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w - 1; j++) {
      if (a[i][j] & 1) { 
        v.push_back(make_tuple(i + 1, j + 1, i + 1, j + 2));
        a[i][j]--;
        a[i][j + 1]++;
      }
    }
  }
  for (int i = 0; i < h - 1; i++) {
    if (a[i][w - 1] & 1) {
      v.push_back(make_tuple(i + 1, w, i + 2, w));
      a[i][w - 1]--;
      a[i + 1][w - 1]++;
    }
  }
  cout << v.size() << endl;
  for (int i = 0; i < (int)v.size(); i++) {
    cout << get<0>(v[i]) << " " << get<1>(v[i]) << " " << get<2>(v[i]) <<" " << get<3>(v[i]) << endl;
  }
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  fclose(stream2);
#endif
  return 0;
}

Measured memory_bytes: 5232
#include<iostream>
#include<sstream>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<string>
#include<numeric>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using vi = vector<int>;
using vl = vector<long>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using vpii = vector<pii>;

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

  if(N % 2 == 0){
    cout << N / 2 - 1 << endl;
  }
  else{
    cout << N / 2 << endl;
  }
  
  return 0;
}

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

int main(int argc, char *argv[]) {
	string S;
	cin >> S;
	for (int i = 0; i < 5; i++) cout << S[i];
	cout << " ";
	for (int i = 0; i < 7; i++) cout << S[i+6];
	cout << " ";
	for (int i = 0; i < 5; i++) cout << S[i+14];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
/*input
abcdefghijklmnopqrstuvwxyz
ibyhqfrekavclxjstdwgpzmonu
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}
vector<int> v,vv;
int pre[26];

int main()
{
	IOS;
	REP(i,26) pre[i]=-1;
	string s,t;
	cin>>s>>t;

	REP(i,SZ(s)){
		v.pb(pre[s[i]-'a']);
		pre[s[i]-'a']=i;
	}

	REP(i,26) pre[i]=-1;
	REP(i,SZ(t)){
		if(pre[t[i]-'a']!=v[i]){
			cout<<"No\n";
			return 0;
		}
		pre[t[i]-'a']=i;
	}
	cout<<"Yes\n";


	return 0;
}


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

bool vis[50];
int main()
{
	int n,k;
	int c;
	int cnt1=0,cnt2=0;
	cin>>n>>k>>c;
	if(n==5)++cnt1;
	if(n==7)++cnt2;
	if(k==5)++cnt1;
	if(k==7)++cnt2;
	if(c==5)++cnt1;
	if(c==7)++cnt2;
	if(cnt1==2&&cnt2==1)puts("YES");else puts("NO");
	return 0;
}


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

#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()

const int NAX = 2e5 + 5, MOD = 1000000007;

class Solution
{
private:
public:
    Solution() {}
    ~Solution() {}
    void solveCase()
    {
        int n;
        cin >> n;
        ll res = 0;
        for (size_t i = 1; i <= n; i++)
        {
            for (size_t j = 1; j <= n; j++)
                for (size_t k = 1; k <= n; k++)
                    res += __gcd(i, __gcd(j, k));
            /* code */
        }

        cout << res << '\n';
    }
};

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef LOCAL
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


Measured memory_bytes: 3656
import sys

def main():
    N,A,B=map(int,input().split())
    towns=list(map(int,sys.stdin.readline().strip().split()))
    f=lambda x:min(A*x,B)
    fl=0
    for x in range(N-1):
        fl+=f(towns[x+1]-towns[x])
    print(fl)

if __name__=='__main__':
    main()



Measured memory_bytes: 20104
import itertools
H, W, K = map(int, input().split())
Array = [[0]*W for _ in range(H)]

for i in range(H):
    S = input()
    for j in range(W):
        if S[j] == "#":
            Array[i][j] = 1
LH = range(H)
LW = range(W)
CH = []
CW = []
Ans = 0
for i in range(H+1):
    for combi in itertools.combinations(LH, i):
        CH.append(list(combi))
for i in range(W+1):
    for combi in itertools.combinations(LW, i):
        CW.append(list(combi))
for ch in CH:
    for cw in CW:
        Sum = 0
        for i in range(H):
            for j in range(W):
                if not (i in ch or j in cw):
                    Sum += Array[i][j]
        if Sum == K:
            Ans += 1
print(Ans)

Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;

int n;
vector<int> w;
int dp[310][310];

int calc(int l, int r){
    if(dp[l][r] != -1) return dp[l][r];
    if(l + 1 >= r) return dp[l][r] = 0;
    int res = 0;
    rep(i, l, r){
        int tmp = 0;
        int cent = calc(l + 1, i);
        int len = i - l - 1;
        if(abs(w[l] - w[i]) <= 1 && len == cent * 2) tmp++;
        tmp += cent + calc(i + 1, r);
        res = max(res, tmp);
    }
    return dp[l][r] = res;
}

int main() {
    while(cin >> n, n){
        w.clear();
        w.resize(n);
        rep(i, 0, n) cin >> w[i];
        rep(i, 0, n + 1) rep(j, 0, n + 1) dp[i][j] = -1;
        int ans = calc(0, n);
        cout << ans * 2 << endl;
    }
}


Measured memory_bytes: 3468
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

fn main() {
    input! {
        x:isize
    }
    if x >= 30 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNextDouble()) {
			double[] a = new double[10];
			a[0] = sc.nextDouble();
			double s = a[0];
			for (int i = 1; i < 10; i++) {
				if (i % 2 == 0) {
					a[i] = a[i - 1] / 3;
				} else {
					a[i] = a[i - 1] * 2;
				}
				s+=a[i];
			}
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define INF 1000000

int main() {
    while (true) {
        int c, n, m, s, d;
        cin >> c >> n >> m >> s >> d;
        
        if (c==0 && n==0 && m==0 && s==0 && d==0) {
            break;
        }
        
        s -= 1;
        d -= 1;
        
        vector<P> adj_list[n*(c+1)];
    
        for (int i=0; i<m; i++) {
            int ai, bi, fi;
            cin >> ai >> bi >> fi;
            ai -= 1;
            bi -= 1;
        
            for (int j=0; j<=c; j++) {
                adj_list[ai*(c+1)+j].push_back(P(bi*(c+1)+j, fi));
                adj_list[bi*(c+1)+j].push_back(P(ai*(c+1)+j, fi));
            
                if (j>0) {
                    adj_list[ai*(c+1)+j].push_back(P(bi*(c+1)+j-1, fi/2));
                    adj_list[bi*(c+1)+j].push_back(P(ai*(c+1)+j-1, fi/2));
                }
            }
        }
        
        priority_queue<P, vector<P>, greater<P>> pq;
        int dist[n*(c+1)];
        
        for (int i=0; i<n*(c+1); i++) {
            dist[i] = INF;
        }
        
        dist[s*(c+1)+c] = 0;
        pq.push(P(0, s*(c+1)+c));
        
        while (pq.size()) {
            P p = pq.top();
            pq.pop();
            
            int d = p.first;
            int v = p.second;
            
            if (dist[v]<d) {
                continue;
            }
            
            for (int i=0; i<adj_list[v].size(); i++) {
                int nv = adj_list[v][i].first;
                int w = adj_list[v][i].second;
                
                if (dist[nv]>dist[v]+w) {
                    dist[nv] = dist[v]+w;
                    pq.push(P(dist[nv], nv));
                }
            }
        }
        
        int ans = INF;
        
        for (int i=0; i<=c; i++) {
            ans = min(ans, dist[d*(c+1)+i]);
        }
        
        cout << ans << endl;
    }
}


Measured memory_bytes: 3240
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define pb push_back
using namespace std;
typedef pair<int,int> p;
typedef long long ll;

int main(){
	ll x,t;
	cin>>x>>t;
	cout<<(((x-t)>0)?x-t:0)<<endl;
	return 0;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll

#define loopinc(i, a, b, inc) for(int i = a; i < (b); i += inc)
#define loop(i, a, b) for(int i = a; i < (b); i++)
#define rep(i, n) loop(i, 0, n)
#define endl "\n"
#define all(c) (c).begin(),(c).end()
//#define lloopinc(i, a, b, inc) for(ll i = a; i < (b); i += inc)
//#define lloop(i, a, b) for(ll i = a; i < (b); i++)
//#define lrep(i, n) lloop(i, 0, n)
typedef pair<int, int> pii;
//typedef pair<ll, ll> pll;
typedef vector<int> vi;
//typedef vector<ll> vll;
typedef tuple<int, int, int> tiii;
//void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

signed main() {
	// freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vi a(n);
	vi b(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];

	if (a > b) swap(a, b);

	int count = 0;
	while (a != b) {
		next_permutation(all(a));
		count++;
	}

	cout << count << endl;
}


Measured memory_bytes: 256
n, x = map(int, input().split())

S, P = [1], [1]
for i in range(n):
    S.append(S[i]*2+3)
    P.append(P[i]*2+1)


def f(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    elif x <= 1+S[n-1]:
        return f(n-1, x-1)
    else:
        return P[n-1] + 1 + f(n-1, x-2-S[n-1])


print(f(n, x))


Measured memory_bytes: 3064
n, k = map(int, input().split())
lr = [tuple(map(int, input().split())) for _ in range(k)]

dp = [0 for _ in range(n+1)]
dp[1] = 1
dp_cum = [0 for _ in range(n+1)]
dp_cum[1] = 1

mod = 998244353

for i in range(2, n+1):
    for l, r in lr:
        left, right = i - r, i - l
        if left > 0:
            dp[i] += dp_cum[right] - dp_cum[left - 1]
        elif right > 0:
            dp[i] += dp_cum[right]
    
    dp[i] %= mod
    dp_cum[i] = dp[i] + dp_cum[i-1]
    dp_cum[i] %= mod

print(dp[n])

Measured memory_bytes: 24708
import itertools
A,B,C = map(int,input().split())
N = int(input())

for i in range(N):
  for j in range(N):
    k = N-(i+j)
    P = A*pow(2,i)
    Q = B*pow(2,j)
    R = C*pow(2,k)
    #print(A,B,C,C>B)
    if R > Q and Q > P:
      print("Yes")
      exit()
print("No")

Measured memory_bytes: 61876
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), ans = 0;
		int  b[] = new int[a];
		for(int i = 0; i < a; i++) {
			b[i] = sc.nextInt();
		}
		Arrays.sort(b);
		
		for(int i = 0; i < b.length;i++) {
			for(int j = i + 1; j < b.length; j++) {
				for(int  k = j + 1; k < b.length; k++) {
					if(b[i] + b[j] > b[k]) {
						ans++;
					}else {
						break;
					}
				}	
			}
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 26592
#include<bits/stdc++.h>
using namespace std;
int dp[1000000];
int main()
{
    for(int i=0;i<1000000;i++)
    dp[i]=0;
    
    int n,k;
    cin>>n;
    cin>>k;
    int arr[n];
    int mini=999999;
    for(int i=0;i<n;i++)
    {
    cin>>arr[i];
    if(arr[i]<mini)
    mini=arr[i];
    }
    for(int i=k;i>=k-mini+1;i--)
    {
        dp[i]=0;
    }
    //dp[i] will store 1 when the person can win standing at i number of stones used and
                //else store 0
    for(int i=k;i>=0;i--)
    {
        for(int j=0;j<n;j++)
        {
            if(i+arr[j]<=k)
            {
                if(dp[i+arr[j]]==0)
                {
                dp[i]=1;
                break;
                }
                else
                {
                    dp[i]=0;
                }
            }
        }
    }
    if(dp[0]==1)
    cout<<"First"<<endl;
    else
    cout<<"Second"<<endl;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
const int MAXN=11;
const int a[]={0,1,2,4,7,12,20,29,38,52};
int n,p[MAXN];
ll w[MAXN][MAXN],M;
void GetM(int x)
{
	M=0;
	for(int i=1;i<=x;++i)
		p[i]=i;
	do
	{
		ll res=0;
		for(int i=1;i<x;++i)
			res+=w[p[i]][p[i+1]];
		M=max(M,res);
	}while(next_permutation(p+1,p+1+x));
}
void solve(int x)
{
	for(int i=1;i<x;++i)
		w[i][x]=w[x][i]=(M+1)*a[i];
}
int main()
{
	n=read();
	w[1][2]=w[2][1]=1;
	M=1;
	for(int i=3;i<=n;++i)
	{
		solve(i);
		GetM(i);
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=n;++j)
			printf("%lld ",w[i][j]);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

long pp[100005];
long a[100005];
long s[100005];

int main(int argc, char* argv[])
{
    long a,b,c,d;
    scanf("%ld%ld%ld%ld", &a, &b, &c, &d);

    if(a+b>c+d) {
        printf("Left\n");
    }
    else if(a+b==c+d) {
        printf("Balanced\n");
    }
    else {
        printf("Right\n");
    }

    return 0;
}


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

void solve();

signed main () {
    cout.precision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;	
    int tt = t;
    while (t--) { 
        solve();
    }
    return 0;
}

void solve() {
	int mx = -1;
	int n;
	cin >> n;
	for (int i = 1; ; i += 1) {
		if (i * i <= n) 
			mx = i;
		else
			break;
	}
	cout << mx * mx;
}     	

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long lonng
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
vector<string> field(100);
int main(){
    int H,W;
    cin>>H>>W;
    for(int h=0;h<H;h++){
        cin>>field[h];
    }
    vector<vector<int>> dist(H,vector<int>(W,-1));
    queue<pair<int,int>> que;
    dist[0][0]=0;
    que.push({0,0});
    int count=0;
    rep(i,H){
        rep(j,W){
            if(field[i][j]=='#')count++;
        }
    }
    while(!que.empty()){
       pair<int,int> now=que.front();
       int h=now.first;
       int w=now.second;
       que.pop();
       rep(i,4){
           int nh=h+dx[i];
           int nw=w+dy[i];
           if (nh < 0 || nw < 0 || nh >= H || nw >= W)
                    continue;
           if (dist[nh][nw] != -1)
                    continue;
           if (field[nh][nw] == '#')
                    continue;
        que.push({nh,nw});
        dist[nh][nw]=dist[h][w]+1;
       }
    }
    int ans=H*W-(count+dist[H-1][W-1]+1);
    if(dist[H-1][W-1]!=-1)cout<<ans<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 256
/*in the name of Allah the most beneficent the most merciful.*/
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define MAX 1e18
#define MIN -1e18
#define MOD 1000000007
//#define mod2 20071027
//#define MOD 998244353
// #define base 100001
//#define mod 1000074259
#define base2 31
#define memz(a) memset(a, 0, sizeof(a))
#define memn(a) memset(a, -1, sizeof(a))
#define in1(a) scanf("%lld", &a)
#define in2(a, b) scanf("%lld%lld", &a, &b)
#define TC(c) printf("Case %lld:\n", ++c)
#define out(x) cout << #x << " -> " << x << endl;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FILE   freopen("input.txt", "r", stdin);  freopen("out.txt", "w", stdout);
using namespace std;
const int N = 300010;
string s,t;
ll cnt, res=MAX;

int solve() {
	cin>>s>>t;
	ll sz=s.length(), s2=t.length();
	for(int i=0;i<=sz-s2;i++)
	{
		cnt=0;
		for(int j=0, k=i;j<s2;j++,k++){
			if(s[k]!=t[j]) cnt++;
		}
		res=min(res, cnt);
	}
	printf("%lld\n", res);
	return 0;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return solve();
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
using p = pair<int,int>;
using pp = pair<p,int>;
using ll = long long;
const auto INF =(ll)1e5;
int main(){
  int n;
  cin >> n;
  auto b = vector<int>(n,0);
  for (int i = 0; i < n-1; i++)
  {
    cin >> b[i];
  }
  
  auto before=0;
  auto sum = 0;
  sum += b[0]+b[n-2];
  for (int i = 0; i < n-2; i++)
  {
     sum += min(b[i],b[i+1]);
  }
  
  cout << sum;
  
}

Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int main(){
	int i;
	int n, a, b;
	int tmp, sum, ans=0;
	
	scanf("%d %d %d", &n, &a, &b);
	for(i=1; i<=n; i++){
		sum=0;
		tmp=i;
		while(tmp){
			sum+=tmp%10;
			tmp/=10;
		}
		if(sum>=a and sum<=b)
			ans+=i;
	}
	printf("%d", ans);
	return 0;
}

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


int main()
{
	string s; cin >> s;
	int b, e;
	for (int i = 0; i < s.size()/2; ++i)
		if (s[i] == 'A')
		{
			 b = i;
			 break;
		}
	for (int i = s.size()-1; i >= 0; --i)
		if (s[i] == 'Z')
		{
			e = i;
			break;
		}
	cout << e-b+1 << endl;
}




Measured memory_bytes: 3748
#include <iostream>
#include <cstdlib>
#include <string>
#include <cctype>
using namespace std;

int main(){
	string str;
	int ans = 0;
	int start;
	while (cin >> str) {
		start = -1;
		for (int i = 0; i < str.size(); i++) {
			if (isdigit(str[i]) && start == -1) {
				start = i;
			}else if (start != -1 && !isdigit(str[i])) {
				ans += atoi(str.substr(start,i-start).c_str());
				start = -1;
			}else if(!isdigit(str[i])){
				start = -1;
			}
		}
		if(isdigit(str[str.size()-1])){
			ans += atoi(str.substr(start,str.size()-start).c_str());
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

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

  vector<string> s(n);
  for (string &x : s) {
    cin >> x;
  }

  sort(s.begin(), s.end());
  string out;
  for (string x : s) {
    out += x;
  }

  cout << out << endl;
}


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

class E { static void Main() => new J(); }
class J
{
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	int MOD = 1000000007;
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var S = ReadLine();
		var T = ReadLine();
		var Q = F();
		var N = S.Length;
		var M = T.Length;
		var a = new int[N + 1];
		var b = new int[M + 1];
		for (var i = 0; i < N; i++) a[i + 1] = a[i] + (S[i] == 'A' ? 1 : -1);
		for (var i = 0; i < M; i++) b[i + 1] = b[i] + (T[i] == 'A' ? 1 : -1);
		for (var i = 0; i < Q; i++)
		{
			var q = G();
			WriteLine((a[q[1]] - a[q[0] - 1] - b[q[3]] + b[q[2] - 1]) % 3 == 0 ? "YES" : "NO");
		}
	}
}

Measured memory_bytes: 19120
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define sz(x)  ((ll)x.size())
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
//#ifdef LOCAL
//#include "uj.h"
//#endif
void tokenize(string str,const char delim,vector<string> & res){
	stringstream p(str);
	string token;
	while(getline(p,token,delim)){
		res.push_back(token);
	}
	return;
}

// Your workSpace ...

	

	
void test_case(){
	string str;
	cin >> str;
	int sum = 0;
	for(auto ch :  str)
		sum += (ch - '0');
	
	if(sum % 9 == 0) cout << "Yes";
	else cout << "No";
}
	

	





int main(){
	FAST_IO;
	int tt;
	//cin>>tt;
	tt = 1;
	while(tt--){
		test_case();
	}
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
int main() {

  string s;
  cin >> s;
  int len = s.size();

  rep(i, len) {
    cout << 'x';
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
 
#define MAX 2000000
 
int H,A[MAX+1];
void maxHeapfy(int i){
 
    int  l,r,largest,t;
    l = 2 * i;
    r = 2 * i +1;
 
    if( l <= H && A[l] > A[i]) largest = l;
    else largest = i;
    if(r <= H && A[r] > A[largest]) largest = r;
 
    if( largest != i){
        t = A[i];
        A[i] = A[largest];
        A[largest] = t;
        maxHeapfy(largest);
    }
 
}
int main(){
int i;
scanf("%d",&H);
 
for( i = 1 ; i <= H ; i++ ){
 
    scanf("%d",&A[i]);
 
}
for( i = H/2 ; i >= 1 ; i-- ){
    maxHeapfy(i);
}
 
for( i = 1 ; i <= H ; i++){
    printf(" %d",A[i]);
}
printf("\n");
 
return 0;
 
}
 
 
 

Measured memory_bytes: 2548