akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )
#define EACH( it, c ) for ( auto it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define DRANGE( c, p ) (c).begin(), (c).begin() + p, (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

// Eratosthenes の篩（素数かどうかの表が返る）
vector<bool> eratosthenes( int n )
{
	vector<bool> nums( n + 1, true );
	nums[0] = nums[1] = false;

	for ( int i = 0; i < nums.size(); ++i )
	{
		if ( !nums[i] )
		{
			continue;
		}

		for ( int j = 2; i * j < nums.size(); ++j )
		{
			nums[ i * j ] = false;
		}
	}

	return nums;
}

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

const int OFFSET = 512;

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

	auto isPrime = eratosthenes( 1000000 );
	VVI board( 1024, VI( 1024 ) );
	map<int,PII> pos;
	int max_y = 0, min_x = 0, max_x = 0;
	{
		int y = 0, x = 0, l = 1, n = 1;
		for ( int d = 0; n <= 1000000; d++ )
		{
			const int ny = y + l * dy[ d % 4 ], nx = x + l * dx[ d % 4 ];
			while ( !( y == ny && x == nx ) && n <= 1000000 )
			{
				board[ OFFSET + y ][ OFFSET + x ] = n;
				pos[ n++ ] = MP( y, x );

				max_y = max( max_y, y );
				min_x = min( min_x, x );
				max_x = max( max_x, x );

				y += dy[ d % 4 ];
				x += dx[ d % 4 ];
			}

			if ( d % 2 )
			{
				l++;
			}
		}
	}

	for ( int m, n; cin >> m >> n, m | n; )
	{
		vector<VPII> dp( 1024, VPII( 1024 ) );
		const int center = pos[ n ].snd;
		int depth = 0;

		REP( iy, pos[ n ].fst, max_y + 1 )
		{
			REP( ix, max( min_x, center - depth ), min( max_x, center + depth ) + 1 )
			{
				const int curhole = board[ OFFSET + iy ][ OFFSET + ix ];
				REP( nx, ix - 1, ix + 2 )
				{
					const PII next = MP(
						dp[ OFFSET + iy ][ OFFSET + ix ].fst + ( curhole <= m && isPrime[ curhole ] ),
						curhole <= m && isPrime[ curhole ] ? curhole : dp[ OFFSET + iy ][ OFFSET + ix ].snd
					);

					dp[ OFFSET + iy + 1 ][ OFFSET + nx ] = max( dp[ OFFSET + iy + 1 ][ OFFSET + nx ], next );
				}
			}

			depth++;
		}

		const PII res = *max_element( ALL( dp[ OFFSET + max_y + 1 ] ) );
		cout << res.fst << ' ' << res.snd << endl;
	}	

	return 0;
}

Measured memory_bytes: 76016
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,ll>;
using Graph= vector<vector<P>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}

ll  dp[3005][3005] ;
int main(){
  string s ,t ;cin>>s>>t ;
  ll a= s.size() ;
  ll b= t.size() ;
  rep(i,a+5) {
    dp[i][0]= 0;
    
  }
  rep(i,b+5) {
    dp[0][i]= 0; 
    
  }
  rep(i,a){
    rep(j,b){
      
      if(s[i]==t[j]) {
        dp[i+1][j+1]=dp[i][j]+1  ;
        
      }
    
      else {
        if(dp[i+1][j]>dp[i][j+1]){
            dp[i+1][j+1]=dp[i+1][j] ;
            
        }
       else{
         dp[i+1][j+1]=dp[i][j+1] ;
         
                }
      }
    }
  }
  string unti="" ;
  int i=a;int j=b ;
  while(dp[i][j]>0){
    if(s[i-1]!=t[j-1]){
    if(dp[i][j]==dp[i-1][j]) i-- ;
    else  j-- ;
    }
    else {
      unti+=s[i-1] ;
      i-- ;j-- ;
    }
  }
  reverse(unti.begin(),unti.end()) ;
  cout<<unti<<endl ;
  return 0;
  }

Measured memory_bytes: 70784
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

k, n = list(map(int, input().split()))
a = list(map(int, input().split()))

diff = [0] * n
for i in range(len(a) - 1):
    diff[i] = abs(a[i] - a[i+1])
diff[-1] = abs(a[-1] - k) + a[0]

print(k - max(diff))


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

#define pb push_back
#define Inv(x) ((ll)fac[x - 1] * inv[x] % mod) 

using namespace std;

typedef long long ll;

const int mod = 924844033, N = 8e5 + 10;
int a[N], b[N], rev[N];
int n, cnt[N], size[N];
int fac[N], inv[N];
vector<int> G[N];

int C(int n, int m) {
	if(n < m) return 0;
	return (ll)fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int qpow(int a, int x) {
	int ret = 1;
	while(x) {
		if(x & 1) ret = (ll)ret * a % mod;
		x >>= 1, a = (ll)a * a % mod;
	}
	return ret;
}

void dfs(int x) {
	size[x] = 1;
	for(auto v : G[x])
		if(!size[v]) {
			dfs(v);
			size[x] += size[v];
		}
	if(size[x] - n)
		++ cnt[size[x]], ++ cnt[n - size[x]];
}

void NTT(int n, int *a, int fh) {
	for(int i = 0; i < n; ++ i)
		if(i < rev[i]) 
			swap(a[i], a[rev[i]]);
	for(int limit = 2; limit <= n; limit <<= 1) {
		int Wn = qpow(fh == 1 ? 5 : Inv(5), (mod - 1) / limit), W = 1;
		for(int j = 0; j < n; j += limit, W = 1)
			for(int i = j; i < j + (limit >> 1); ++ i, W = (ll)W * Wn % mod) {
				int a1 = a[i], a2 = (ll)a[i + (limit >> 1)] * W % mod;
				a[i] = (a1 + a2) % mod, a[i + (limit >> 1)] = (a1 - a2 + mod) % mod;
			}
	}
	if(fh == -1) 
		for(int i = 0; i < n; ++ i)
			a[i] = ll(a[i]) * Inv(n) % mod;
}

int main() {
//	freopen("AGC005F.in", "r", stdin);
//	freopen("AGC005F.out", "w", stdout);
	int x, y, limit = 1, k = 0;
	scanf("%d", &n);
	fac[0] = inv[0] = 1;
	for(int i = 1; i <= N - 5; ++ i) 
		fac[i] = (ll)fac[i - 1] * i % mod;
	inv[N - 5] = qpow(fac[N - 5], mod - 2);
	for(int i = N - 5; i >= 1; -- i) 
		inv[i - 1] = (ll)inv[i] * i % mod;
	for(int i = 1; i <= n; ++ i) {
		scanf("%d%d", &x, &y);
		G[x].pb(y), G[y].pb(x);	
	}
	dfs(1);
	for(int i = 0; i <= n; ++ i) 
		a[i] = (ll)cnt[i] * fac[i] % mod;
	for(int i = 0; i <= n; ++ i)
		b[i] = inv[-(i - n)];
	while(limit <= (n << 1)) 
		limit <<= 1, ++ k;
	for(int i = 0; i < limit; ++ i)
		rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (k - 1));
	NTT(limit, a, 1), NTT(limit, b, 1);
	for(int i = 0; i < limit; ++ i)
		a[i] = (ll)a[i] * b[i] % mod;
	NTT(limit, a, -1);
	//for(int i = 0; i < limit; ++ i)
	//	printf("%d ", a[i]);
	for(int k = 1; k <= n; ++ k)
		printf("%d ", (((ll)n * C(n, k) - (ll)inv[k] * a[k + n]) % mod + mod) % mod);
	return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

ul solve(map<ul, ul> &m, ul n, ul a, ul b, ul c, ul d) {
    if (m[n] != 0) {
        return m[n];
    }
    if (n == 0) {
        return 0;
    }
    if (n == 1) {
        return d;
    }
    ul ans = d * n;
    if (n % 2 == 0) {
        ul temp = solve(m, n / 2, a, b, c, d) + a;
        ans = min(temp, ans);
    } else {
        ul temp0 = solve(m, (n - 1) / 2, a, b, c, d) + d + a;
        ul temp1 = solve(m, (n + 1) / 2, a, b, c, d) + d + a;
        ul temp = min(temp0, temp1);
        ans = min(temp, ans);
    }
    if (n % 3 == 0) {
        ul temp = solve(m, n / 3, a, b, c, d) + b;
        ans = min(temp, ans);
    } else {
        ul num = n % 3;
        ul temp0 = solve(m, (n - num) / 3, a, b, c, d) + d * num + b;
        ul temp1 =
            solve(m, (n + (3 - num)) / 3, a, b, c, d) + d * (3 - num) + b;
        ul temp = min(temp0, temp1);
        ans = min(temp, ans);
    }
    if (n % 5 == 0) {
        ul temp = solve(m, n / 5, a, b, c, d) + c;
        ans = min(temp, ans);
    } else {
        ul num = n % 5;
        ul temp0 = solve(m, (n - num) / 5, a, b, c, d) + d * num + c;
        ul temp1 =
            solve(m, (n + (5 - num)) / 5, a, b, c, d) + d * (5 - num) + c;
        ul temp = min(temp0, temp1);
        ans = min(temp, ans);
    }

    m[n] = ans;
    return ans;
}

int main() {
    ul t;
    cin >> t;
    ul ans[t];
    rep(i, t) {
        ul n, a, b, c, d;
        cin >> n >> a >> b >> c >> d;
        map<ul, ul> m;
        ans[i] = solve(m, n, a, b, c, d);
    }

    rep(i, t) { cout << ans[i] << endl; }
    return 0;
}



Measured memory_bytes: 4452
module Main (main) where

import Control.Monad
import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.Maybe

main :: IO ()
main = do
  [n] <- readInts
  if (n == 1)
  then putStrLn "Hello World"
  else do
    [[n],[m]] <- replicateM 2 readInts
    print . showAnswer $ solve (n,m)

type Input  = (Int, Int)
type Output = Int

solve :: Input -> Output
solve = uncurry (+)

showAnswer :: Output -> Answer
showAnswer = Number

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)    = bool "No" "Yes" b
  show (YESNO b)    = bool "NO" "YES" b
  show (AB b)       = bool "B"  "A" b
  show (Number i)   = show i
  show (String s)   = s
  show (Compare o)  = ordering "<" "=" ">" o
  show (Compare2 o) = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

Measured memory_bytes: 380
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
  string word;
  cin>>word;
  int counter=0;
    for(int i=0;i<word.length();i++)
    {   
       counter=count(word.begin(),word.end(),word[i]);
        if(counter%2!=0)
        {
          cout<<"No";
          exit(0);
        }
    }
   cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
/*
 * Author       : YangDavid
 * Created Time : 2020.05.30 20:04:34
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    string s;
    cin >> s;
    for(auto c : s) {
        cout << (c == '?' ? 'D' : c);
    }

    return 0;
}



Measured memory_bytes: 3724
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

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

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

  int max_a = a[0];
  int min_a = a[0];
  for (int i = 1; i < n; i++) {
    max_a = max(max_a, a[i]);
    min_a = min(min_a, a[i]);
  }

  cout << abs(max_a - min_a) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long ll;
typedef pair<int, int> P;
 
int main(){
  int s, w;
  cin >> s >> w;

  if(s>w)   cout << "safe" << endl;
  else   cout << "unsafe" << endl;
  
  return 0;
}

Measured memory_bytes: 3624
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.sort()
y.sort()
flag = False
if x[-1] < y[0]:
    for i in range(x[-1], y[0]+1):
        if i == x[-1]:
            if X <= i < Y:
                flag = True
                break
        elif i == y[0]:
            if X < i <= Y:
                flag = True
                break
        else:
            if X < i < Y:
                flag = True
                break
if flag:
    print("No War")
else:
    print("War")

Measured memory_bytes: 38256
from collections import Counter
N = int(input())
d = Counter()
for _ in range(N):
    S = input()
    if d[S]:
        d[S] += 1
    else:
        d[S] = 1
for j in 'AC WA TLE RE'.split():
    num = d[j]
    print('{} x {}'.format(j, num))

Measured memory_bytes: 9320
N, K = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
P2 = [(((P[i]+1)) / 2) for i in range(N)]
# i番目は1~P[i]の値を出す
# P[i]が大きいものからK個選んで期待値を求める
# 幅が最大のところを見つける
s = 0
init = 0
for i in range(K):
    s += P2[i] 
tmp = s
for i in range(1, N-K+1):
    tmp = tmp - P2[i-1] + P2[i+K-1]
    if s < tmp:
        s = tmp
        init = i

print(s)

Measured memory_bytes: 99152
N = gets.chomp.to_i
constrains = gets.chomp.split.map &:to_i
constrains.unshift(0)

boxes = [0] * (N+1)
N.downto(1) do |i|
    context = i.step(N, i).reduce(0) { |s, o| s + boxes[o] } % 2
    boxes[i] = constrains[i] ^ context 
end

is_good = N.downto(1).reduce(true) do |is_good, i|
    context = i.step(N, i).reduce(0) { |s, o| s + boxes[o] } % 2
    break false if context != constrains[i]
    true
end

# p boxes
# p is_good

if is_good
    puts boxes.count(1)
    if boxes.count(1) > 0
        ball_indexes = []
        boxes.map.with_index { |v, i| ball_indexes.push(i) if v == 1 }
        puts ball_indexes.join(" ")
    end
else
    puts -1
end


Measured memory_bytes: 26888
#include<bits/stdc++.h>
#define ll long long
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define pb push_back
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <=n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define mod 1000000007
#define gcd(x,y) __gcd(x, y)
using namespace std;
int main()
{
	ll a[5],i,x=0;
	for0(i,5)
	{
		cin>>a[i];
		
	}
	for0(i,5)
	{
		if(a[i]==0&&i==0)
		{
			x=max(abs(a[i+1]-a[i+2])/2,1ll);
			break;
		}
		if(a[i]==0&&i==4)
		{
			x=a[i-1]+max(abs(a[i-1]-a[i-2])/2,1ll);
			break;
		}
		if(a[i]==0&&i!=0)
		{
			if(a[i-1]<a[i+1])
			{
				x=a[i-1]+max((a[i+1]-a[i-1])/2,1ll);
			}
			else if(a[i-1]>a[i+1])
			{
				x=a[i-1]-max((a[i-1]-a[i+1])/2,1ll);
			}
			else
			{
				x=a[i-1];
			}
			break;
		}
	}
	cout<<x<<endl;
	
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(){
    int q, x;
    char com[20];

    list<int> v;
    scanf("%d", &q);
    for(int i = 0; i < q; i++){
        scanf("%s", com);
        if(com[0] == 'i'){
            scanf("%d", &x);
            v.push_front(x);
        }else if(com[6] == 'L'){
            scanf("%d", &x);
            v.pop_back();
        }else if(com[6] == 'F'){
            scanf("%d", &x);
            v.pop_front();
        }else if(com[0] == 'd'){
            scanf("%d", &x);
            for(list<int>::iterator it = v.begin(); it != v.end(); it++){
                if(*it == x){
                    v.erase(it);
                    break;
                }
            }
        }
    }
    int i = 0;
    for(list<int>::iterator it = v.begin(); it != v.end(); it++){
        if(i++) printf(" ");
        printf("%d", *it);
    }
    printf("\n");
}


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

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


int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		a[i]--;
	}
	vector<int> ever(0);

	ever.push_back(0);
	int num = 0, count = 0;
	while (count <= N + 1) {
		if (a[num] == 1) {
			cout << ever.size();
			return 0;
		}
		else {
			ever.push_back(a[num]);
			num = a[num];
			count++;
		}
	}
	cout << -1;
	return 0;
}

Measured memory_bytes: 1276
#include<iostream> 

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
	int n, k, x,y=0;
	cin >> n >> k;
	rep(i, n) {
		cin >> x;
		if (x > k) {
			y += (x - k) ;
		}
		else if (k - x < x) {
			y += (k - x) ;
		}
		else {
			y += x ;
		}
	}
	cout << y*2 << endl;
	return 0;
}

Measured memory_bytes: 3616
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]

name_union = set(s) | set(t)
money = {}
for i, n in enumerate(name_union):
  money.setdefault(n, s.count(n) - t.count(n))

print(0 if max(money.values()) < 0 else max(money.values()))

Measured memory_bytes: 3064
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007


const int N = 200005;
int d[N];
int s[N], t[N], x[N];

template <typename T>
class SquareRootDecomposition {
	int div;
	vector<T> a, b;
	function<T(T, T)> func;

public:
	SquareRootDecomposition<T>(const int n, T def, function<T(T,T)> _func) {
		LL ok = n;
		LL ng = 1;
		while (ok - ng > 1) {
			LL mid = (ok + ng) / 2;
			if (mid*mid >= n)ok = mid;
			else ng = mid;
		}
		div = (int)ok;
		a = vector<T>((n+div-1) / div, def);
		b = vector<T>(n, def);
		func = _func;
	}
	void update(int l, int r, T v) {// update [l, r)
		int as = (l + div - 1) / div;
		int ae = r / div;
		FOR(i, as, ae)a[i] = func(a[i], v);
		FOR(i, l, min(as * div, r))b[i] = func(b[i], v);
		FOR(i, max(ae * div, l), r)b[i] = func(b[i], v);
	}
	T query(int idx) {
		return func(a[idx / div], b[idx]);
	}
};

int main() {
	int n, q;
	scanf("%d%d", &n, &q);
	REP(i, n) scanf("%d%d%d", &s[i], &t[i], &x[i]);
	REP(i, q)scanf("%d", &d[i]);
	SquareRootDecomposition<int> srd(q, 0x7f7f7f7f, [](int a, int b) { return min(a, b); });
	REP(i, n) {
		int l = s[i] - x[i];
		int r = t[i] - x[i];
		int lidx = lower_bound(d, d + q, l) - d;
		int ridx = upper_bound(d, d + q, r-1) - d;
		srd.update(lidx, ridx, x[i]);
	}
	REP(i, q) {
		int ans = srd.query(i);
		if (ans > 1e9 + 5)ans = -1;
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 5760
import java.util.*;

import java.lang.*;

import java.math.*;



public class Main {

	Scanner sc = new Scanner(System.in);

	void run(){ //greedy

		int n = sc.nextInt();

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

			int val = 0;

			int val2 = 0;

			boolean ans = true;

			for(int j=0;j <10; j++){

				int ball = sc.nextInt();

				if(ball > val){

					val = ball;

				}

				else if(ball > val2){

					val2 = ball;

				}else{

					ans = false;

				}

			}	

			System.out.println(ans?"YES":"NO");

		}

		

	}

	public static void main(String[] args){

		Main m = new Main();

		m.run();

		

	}

}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF (1e10)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

template<typename T>
T gcd(T a,T b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a * b / g;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}

int N,M;


int main()
{
  cin>>N;
  ll A[N];
  ll B[N];
  REP(i,0,N){
    cin>>A[i];
  }
  REP(i,0,N){
    cin>>B[i];
  }

  int ans=0;
  long long S=0;
  vector<ll> overs;
  REP(i,0,N){
    if(B[i]>A[i]){
      ans++;
      S+=B[i]-A[i];
    }else{
      overs.push_back(A[i]-B[i]);
    }
  }
  sort(overs.begin(),overs.end(),greater<ll>());
  

  if(ans==0){
    cout<<ans<<endl;
    return 0;
  }
  REP(i,0,overs.size()){
    ans++;
    S-=overs[i];

    if(S<=0){
      cout<<ans<<endl;
      return 0;
    }

  }
  cout<<"-1"<<endl;



  return 0;
}

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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


int solve(int N, int M, int C, vi& b, vvi& a) {
    int cnt = 0;
    rep(i,N){
        int score = C;
        rep(j,M) {
            score += a[i][j] * b[j];
        }
        if (score > 0) ++cnt;
    }
    return cnt;
}

int main() {
    int N,M,C; scanf("%d%d%d", &N, &M, &C);
    vi b(M);
    rep(i,M) scanf("%d", &b[i]);
    vvi a(N, vi(M));
    rep(i,N) rep(j,M){
        scanf("%d", &a[i][j]);
    }
    cout << solve(N,M,C, b,a) << endl;
    return 0;
}


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

int main()
{
		int n, max;
  		long long sum = 0;
	cin>>n;
	int a[n];
	
	for(int i= 0 ; i < n ; i++)
	cin>>a[i];
	max = a[0];
	
	for( int i = 1; i < n ; i++)
	{
		if( max  > a[i])
		sum = sum + (max - a[i]);
		else
		max = a[i];
	}
	cout<<sum;
}

Measured memory_bytes: 4376
def cake_gen(a,b,c,k):
    d=[]
    for i in a:
        for j in b:
            d.append(i+j)
    d.sort(reverse = True)
    d=d[:k]
    e=[]
    for i in c[:k]:
        for j in d:
            e.append(i+j)
    e.sort(reverse = True) 
    for i in range(k):
        print(e[i])           
    
def ma(): return map(int, input().split())
def main():
    x,y,z,k = ma()
    a = list(ma())
    b = list(ma())
    c = list(ma())
    a.sort(reverse = True)
    b.sort(reverse = True)
    c.sort(reverse = True)
    cake_gen(a,b,c,k)


if __name__ == '__main__':
    main()

Measured memory_bytes: 139580
#include <bits/stdc++.h>
#define rua system("pause")
using namespace std;
typedef long long ll;
inline int read()
{
	int x = 0, f = 1; char c = getchar();
	while (!isdigit(c)) {if (c == '-') f = -1; c = getchar();}
	while (isdigit(c)) {x = x * 10 + c - '0', c = getchar();}
	return x * f;
}

const int MAXN = 1005;
int n, x[MAXN], y[MAXN], m = 31;

string Solve(int x, int y, int st)
{
	if (st == -1) {return "";}
	if (abs(y) < abs(x))
	{
		if (x > 0) return Solve(x - (1 << st), y, st - 1) + "R";
		else return Solve(x + (1 << st), y, st - 1) + 'L';
	}
	else
	{
		if (y > 0) return Solve(x, y - (1 << st), st - 1) + "U";
		else return Solve(x, y + (1 << st), st - 1) + "D";
	}
}

int main()
{
	n = read();
	for (int i = 1; i <= n; i ++) x[i] = read(), y[i] = read();
	int foo = (abs(x[1]) + abs(y[1])) % 2;
	for (int i = 2; i <= n; i ++)
		if ((abs(x[i]) + abs(y[i])) % 2 != foo)
			return puts("-1"), 0;
	if (!foo)
	{
		printf("%d\n", m + 1);
		for (int i = 0; i < m; i ++)
			printf("%d ", 1 << i);
		puts("1");
		for (int i = 1; i <= n; i ++)
			cout << Solve(x[i] - 1, y[i], 30) + "R" << endl;
	}
	else
	{
		printf("%d\n", m);
		for (int i = 0; i < m; i ++)
			printf("%d ", 1 << i);
		puts("");
		for (int i = 1; i <= n; i ++)
			cout << Solve(x[i], y[i], 30) << endl;
	}
	return 0;
} 

Measured memory_bytes: 384
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
       Scanner sc = new Scanner(System.in);
       ArrayList<Integer> arraylist = new ArrayList<Integer>();
       int N = sc.nextInt();
       int []array = new int[N];
       for(int i = 0; i < array.length; i++){
           array[i] = sc.nextInt();
       }
       Arrays.sort(array);
       for(int i = 0; i < array.length; i++){
           if(i != 0){
               if(array[i] != array[i-1]){
                   arraylist.add(array[i]);
               }else{
                   continue;
               }
           }else{
               arraylist.add(array[i]);
           }
       }
       System.out.println(arraylist.size());

    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
int main(){
    int a[5],i;
    for(i=0;i<5;i++){
        cin >> a[i];
        if(a[i]==0){
            break;
        }
    }
    cout << i+1 << '\n';


}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n, m;
		while ((n = in.nextInt()) != 0 & (m = in.nextInt()) != 0) {
			int counter = 0;
			int[] array = new int[n];
			int maxw = 0;
			int[] nn = new int[n];
			for (int i = 0; i < n; i++) {
				nn[i] = in.nextInt();
				maxw += nn[i];
			}

			int[] hs = new int[maxw + 1];
			for (int i1 = 0; i1 < n; i1++) {
				int val1 = nn[i1];
				int j1 = 0;
				int v1 = val1;
				do {
					hs[v1]++;
					v1 = val1 + array[j1];
					array[j1] = v1;
				} while (j1++ < i1);
			}
			array = new int[m];
			for (int i = 0; i < m; i++) {
				int val = in.nextInt();
				int j = 0;
				int v = val;
				do {
					v = val + array[j];
					array[j] = v;
					if (v <= maxw) {
						counter += hs[v];
					}
				} while (j++ < i);
			}
			System.out.println(counter);
		}

	}
}

Measured memory_bytes: 59144
N, K = map(int, input().split())
L = [0]*K
R = [0]*K
for i in range(K):
  L[i], R[i] = map(int, input().split())
  R[i] += 1

M = 998244353
T = [0]*N
T[0] = 1
s = 0
for i in range(N):
  s += T[i]
  for j in range(K):
    if i+L[j]<N:
      T[i+L[j]] += s
      T[i+L[j]] %= M
    if i+R[j]<N:
      T[i+R[j]] -= s
      T[i+R[j]] %= M

print(T[-1])


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

//typedef
typedef unsigned int UINT;
typedef unsigned long long ULL;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef tuple<LL, LL, LL> TLL3;
typedef tuple<LL, LL, LL, LL> TLL4;
typedef set<LL, greater<LL> > setdownLL;
#define PQ priority_queue
typedef PQ<LL, vector<LL>, greater<LL> > pqupLL;
//container utill
#define ALL(v) (v).begin(),(v).end()
#define CR [](auto element1, auto element2){return element1>element2;}
#define LB lower_bound
#define UP upper_bound
#define PB push_back
#define MP make_pair
#define MT make_tuple
//constant
#define PI 3.141592653589793

template<class Abel> struct RMQ_ST{//[0,ST.n)
    vector<Abel> dat;
    long long n;
    Abel unity;

    RMQ_ST(long long n_origin, Abel SUM_UNITY){
        unity=SUM_UNITY;
        long long i=0;
        while(n_origin>(1<<i)) i++;
        n = (1<<i);
        dat.resize(2*n -1);
        for(i=0; i< 2*n -1; i++){
            dat[i]=SUM_UNITY;
        }
    }

    void update(long long i, Abel x){
        i+=n-1;
        dat[i]=x;
        while(i>0){
            i=(i-1)/2;
            dat[i]=max(dat[i*2 +1],dat[i*2 +2]);
       }
    }

    Abel max_range(long long a, long long b, long long k, long long l, long long r){
        if(r<=a||b<=l) return unity;
        if(a<=l&&r<=b) return dat[k];
        Abel vl=max_range(a,b,k*2 +1, l, (l+r)/2);
        Abel vr=max_range(a,b,k*2 +2, (l+r)/2, r);
        return max(vl,vr);
    }
};

int main(){
    LL N,K;
    cin >> N >> K;
    RMQ_ST<LL> stre(300001,0);
    LL A,i,val;
    for(i=0; i<N; i++){
        cin >> A;
        val=stre.max_range(max(0LL,A-K),min(300001LL,A+K+1LL),0,0,stre.n);
        stre.update(A,val+1LL);
    }
    cout << stre.max_range(0LL,300001LL,0,0,stre.n) << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 11452
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin>>s;
  int n=s.size();
  long long int cnt=0,w[n]={};
  if(s[0]=='W')
    w[0]++;
  for(int i=1;i<n;i++){
    if(s[i]=='W')
      w[i]=w[i-1]+1;
    else w[i]=w[i-1];
  }
  
  for(int i=0;i<n;i++){
    if(s[i]=='B')
      cnt+=w[n-1]-w[i];
  }
  
  
  cout<<cnt;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1e18;
//const ll mod = 1000000007;
vector<ll> Div(ll x) {
    vector<ll> ret;
    for(ll i = 1; i * i <= x; i++) {
        if(x % i == 0) {
            ret.push_back(i);
            ret.push_back(x / i);
        }
    }
    return ret;
}
ll ans;
ll N;
bool check(ll x) {
    if(x <= 1) return false;
    ll tmp = N;
    while(tmp % x == 0) tmp /= x;
    tmp %= x;
    return tmp == 1;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    vector<ll> a = Div(N);
    vector<ll> b = Div(N - 1);
    vector<ll> c = a;
    for(auto tmp : b) {
        c.push_back(tmp);
    }
    sort(c.begin(), c.end());
    c.erase(unique(c.begin(), c.end()), c.end());
    for(auto tmp : c) {
        if(check(tmp)) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

const double PI=3.141592653589793;

int main()
{
  string s, t;
  cin >> s >> t;

  int cnt = 0;
  rep(i,s.size()){
    if(s.at(i)!=t.at(i))
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3908
#include<iostream>
#include<vector>
#include<queue>
#define MAX 10000
#define INF (1<<21)
using namespace std;

int n;
vector<pair<int,int> > E[MAX];
int d[MAX];

void dijkstra(int s){
    priority_queue<pair<int,int> > PQ;
    int visited[MAX];
    for(int i=0;i<n;i++){
        visited[i]=false;
    }
    d[s]=0;
    PQ.push(make_pair(d[s],s));
    while(!PQ.empty()){
        pair<int,int> f=PQ.top();
        PQ.pop();
        int u=f.second;
        visited[u]=true;

        if(d[u]<f.first*(-1)) continue;

        for(int j=0;j<E[u].size();j++){
            int v=E[u][j].first;   //之前这里写错了
            if(visited[v]==true) continue;
            if(d[v]>d[u]+E[u][j].second){
                d[v]=d[u]+E[u][j].second;
                PQ.push(make_pair(d[v]*(-1), v));
            }
        }

    }


}

void init(){
    int k,b,e,val;
    cin>>n;
    for(int i=0;i<n;i++){
        d[i]=INF;
        cin>>b>>k;
        for(int j=0;j<k;j++){
            cin>>e>>val;
            E[b].push_back(make_pair(e,val));
        }
    }
}

int main(){
    init();

    /*for(int i=0;i<n;i++){
        for(int j=0;j<E[i].size();j++){
            cout<<E[i][j].first<<":"<<E[i][j].second<<' ';
        }
        cout<<endl;
    }*/

    dijkstra(0);
    for(int i=0;i<n;i++){
        cout<<i<<' '<<d[i]<<endl;
    }

    return 0;
}



Measured memory_bytes: 8044
#include <stdio.h>
#include <string.h>

int main(void){
	int a, b, ab, o;
	int temp;
	char blood[3];

	a = b = ab = o = 0;

	while(scanf("%d,%s", &temp, blood) != EOF){
		if(strcmp(blood, "AB") == 0) ab++;
		else if(strcmp(blood, "A") == 0) a++;
		else if(strcmp(blood, "B") == 0) b++;
		else if(strcmp(blood, "O") == 0) o++;
	}

	printf("%d\n%d\n%d\n%d\n", a, b, ab, o);

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const int INF = 100000009;
const int DP_SIZE = 1000006;

int dp[DP_SIZE];

int main(){
	int N;
	cin >> N;
	
	for(int i=0; i<DP_SIZE; i++) dp[i] = INF;
	dp[0] = 0;
	
	for(int n=0; n<=N; n++){
		for(int pow6=1; n+pow6<=N; pow6*=6) dp[n+pow6] = min(dp[n+pow6], dp[n]+1);
		for(int pow9=1; n+pow9<=N; pow9*=9) dp[n+pow9] = min(dp[n+pow9], dp[n]+1);
	}
	
	cout << dp[N] << endl;
	
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <vector>
#include <math.h>
#include <climits>
using namespace std;


vector<int> m;
vector<int> v;

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

	for (int i = 15; 0 <= i; i--) {
		if ((n & (1<<i))!=0) {
			cout << pow(2,i);
			break;
		}
	}
	
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int[] A = new int[9] { 1, 2, 3, 4, 5, 6, 7, 8, 9, };
            int[] B = new int[9] { 1, 2, 3, 4, 5, 6, 7, 8, 9, };

            bool flag = false;

            for(int i= 0; i < 9; i++)
            {
                for(int j= 0; j<9; j++)
                {
                    if(A[i]*B[j] == N)
                    {
                        flag = true;
                    }
                }
            }

            Console.WriteLine(flag ? "Yes":"No");
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	if(n==7 || n==5 ||n==3)
		printf("YES\n");
	else
		printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

    int n1, n2, n3, p1, p2, p3;

    cin >> n1 >> n2 >> n3;

    p1 = n1 + n2;
    p2 = n2 + n3;
    p3 = n1 + n3;

    if(p1 <= p2 && p1 <= p3){
        cout << p1 << endl;
    }
    else if(p2 <= p1 && p2 <= p3){
        cout << p2 << endl;
    }
    else{
        cout << p3 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)
int main(){
    string s; cin >> s;
    int len = s.size(), tmp1 = 0, tmp2 = 0;
    vector<int> child(len, 0), mv(len, 0);
    rep(i, 0, len){
        if (s[i] == 'L'){
            tmp1 += 1;
            if (tmp1==1) tmp2 = i;
            if (tmp1%2) mv[i] = tmp2;
            else mv[i] = max(0, tmp2-1);
        }else tmp1 = 0;
    }
    for (int i = len-1; i >= 0; i--){
        if (s[i] == 'R'){
            tmp1 += 1;
            if (tmp1==1) tmp2 = i;
            if (tmp1%2) mv[i] = tmp2;
            else mv[i] = min(len-1, tmp2+1);
        }else tmp1 = 0;
    }
    rep(i, 0, len) child[mv[i]] += 1;
    rep(i, 0, len){
        if (i==0) cout << child[i];
        else cout << " " << child[i]; 
    }
    cout << endl; 
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;

ll popcnt(ll x) {
    return __builtin_popcount(x);
}

ll f(ll x) {
    if (x == 0) {
        return 0;
    }

    return f(x % popcnt(x)) + 1;
}

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

    int pcnt = 0;
    vi X(N);
    rep(i, N) {
        X[i] = XX[i] - '0';
        pcnt += X[i];
    }

    vi ans(N);
    rep(bit, 2) {
        int npcnt = pcnt;
        if (bit == 0) {
            npcnt++;
        } else {
            npcnt--;
        }
        if (npcnt <= 0) continue;

        ll y = 0;
        ll a = 1;
        // X % popcount(X) + 1, X % popcount(X) - 1を求める
        for (int i = N - 1; i >= 0; i--) {
            if (X[i] == 1) {
                y += a;
                y %= npcnt;
            }

            a *= 2;
            a %= npcnt;
        }

        a = 1;
        for (int i = N - 1; i >= 0; i--) {
            if (X[i] == bit) {
                int nx = y;

                if (bit == 0) {
                    nx = (nx + a) % npcnt;
                } else {
                    nx = (nx - a + npcnt) % npcnt;
                }

                ans[i] = f(nx) + 1;
            }

            a *= 2;
            a %= npcnt;
        }
    }

    rep(i, N) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 5156
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<": "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

void cp()
{
    string s, t;
    cin >> s >> t;
    int n = ln(s), m = ln(t);
    int best = INT_MAX;
    for(int i = m - 1; i < n; i++)
    {
        // [i-m+1, i]
        int cnt = 0;
        for(int j = 0; j < m; j++)
        {
            if(s[i - m + 1 + j] != t[j])
                cnt++;
        }
        best = min(best, cnt);
    }
    cout << best;
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main(){
    long n,h;
    cin>>n>>h;
    vector<long> a(n),b(n);
    for(int i = 0; i< n; i++){
        cin>>a[i];
        cin>>b[i];
    }
    sort(begin(b),end(b),greater<long>());
    long a_max = *max_element(begin(a),end(a));
    long sum=0;
    for(auto x:b){
        if(x<a_max)
            break;
        h-=x;
        sum++;
        if(h<=0){
            cout<<sum;
            return 0;
        }
    }
    sum+=h/a_max;
    if(h-a_max*(h/a_max)>0)
        sum++;
    cout<<sum;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
//F6編譯，右上三角形執行，ctrl+c強制停止執行  F5開啟exe
#define ll long long
#define maxn 200005
#define mod 998244353
using namespace std;

typedef pair<int, int> P;

ll a, b, n;
ll ans;

int main()
{
    cin >> a >> b >> n;
    ans = a * n / b - a * (n / b);
    if (n >= b - 1)
        ans = max(ans, (a * b - a) / b);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3664
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
    public static void main(String[] args) throws IOException {
        try (InputReader reader = new InputReader(System.in)) {
            int inputNumber = reader.readInt();
            int numOfEven, numOfOdd;
            numOfEven = numOfOdd = inputNumber / 2;
            if (inputNumber % 2 != 0) {
                numOfOdd++;
            }
            System.out.println(numOfEven * numOfOdd);
        }
    }
}

class InputReader implements Closeable, AutoCloseable {
    private final BufferedReader br;

    InputReader(InputStream inputStream) {
        this.br = new BufferedReader(new InputStreamReader(inputStream));
    }

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

    int readInt() throws IOException {
        return Integer.parseInt(this.readLine());
    }

    long readLong() throws IOException {
        return Long.parseLong(this.readLine());
    }

    String[] readStringsSplitByDelimiter(String delimiter) throws IOException {
        return this.readLine().split(delimiter);
    }

    int[] readIntsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        int[] ints = new int[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            ints[i] = Integer.parseInt(strings[i]);
        }

        return ints;
    }

    long[] readLongsSplitByDelimiter(String delimiter) throws IOException {
        String[] strings = this.readStringsSplitByDelimiter(delimiter);

        int stringsLength = strings.length;
        long[] longs = new long[stringsLength];
        for (int i = 0; i < stringsLength; i++) {
            longs[i] = Long.parseLong(strings[i]);
        }

        return longs;
    }

    @Override
    public void close() throws IOException {
        this.br.close();
    }
}

Measured memory_bytes: 22868
/*-------enazuma11----------------*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define F first
#define S second
#define M 1000000007
 
/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/
/* int x[]={-1,0,1,0};
int y[]={0,1,0,-1};
*/

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int t=1;
	//	cin>>t;
	while(t--){
		ll a,b;
		cin>>a>>b;
		ll mx=-1e16;
		mx=max(mx,a+b);
		mx=max(mx,a*b);
		mx=max(mx,a-b);
		cout<<mx<<'\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,k,n) for(ll i = k;i<n;i++)
#define mo map<ll,ll> 
int main(){
	 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll d,t,s;
    cin>>d>>t>>s;
    if(s*t>=d){
    	cout<<"Yes"<<"\n";
    }
    else{
    	cout<<"No"<<"\n";
    }
}

Measured memory_bytes: 3608
N = input()
operation_cnt = len(N) - 1

for i in range(1 << operation_cnt):
    operation = ["-"] * operation_cnt
    for j in range(operation_cnt):
        if ((i >> j) & 1):
            operation[j] = "+"

    formula = ""
    for num,operator in zip(N, operation + [""]):
        formula += (num + operator)
    if eval(formula) == 7:
        print(formula + "=7")
        exit()

Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
const int N = 105;
int n;
int arr[N];
long long add , sub;
int main(){
	cin >> n;
	for(int i = 1 ; i <= n ; ++i){
		cin >> arr[i];
	}
	add = 1;
	sub = 1;
	for(int i = 1 ; i <= n ; ++i){
		add *= 3LL;
		int mult = 0;
		for(int j = arr[i] - 1 ; j <= arr[i] + 1 ; ++j){
			if(j & 1){
				++mult;
			}
		}
		sub *= mult;
	}
	add -= sub;
	printf("%lld\n" , add);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, d;
    cin >> n >> d;
    int piece = d * 2 + 1;
    cout << (n-1) / piece + 1 << endl;
    return 0;
}




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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if ((a < b) && (b < c)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

const ll MOD = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    double ans = 0;
    rep(i, n) {
        int a; cin >> a;
        ans += 1.0/a;
    }
    cout << setprecision(10) << 1.0/ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 


#define M 100010


int main(){
	IOS;
	tihs;

	
	ld r;cin>>r;
	ld pi=3.141592653589793238;
	cout<<setprecision(10)<<2.0*pi*r;


	return 0;
}

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

int main(){
    string s;
    cin >> s;
    
    int n = (int)s.size();
    long long ans = 0;
    
    for (int tmp = 0; tmp < (1<<n-1); tmp++){
        bitset<10> t(tmp);
        
        long long cur = s[0] - '0';
        
        for (int i = 0; i < n-1; i++){
            if (t.test(i)){
                ans += cur;
                cur = s[i+1] - '0';
            }
            else{
                cur = cur*10 + (s[i+1]-'0');
            }
        }
        
        ans += cur;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256