akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() 
{
    int n, m; cin >> n >> m;
    int odd = m&1 ? m : m-1;
    int even = m&1 ? m-1 : m;
    int j = 1+odd+1;
    for (int i = 1; odd >= 1 && m > 0; i++, odd -= 2, m--) {
        cout << i << ' ' << i+odd << '\n';
    }
    for (; even >= 2 && m > 0; j++, even -= 2, m--) {
        cout << j << ' ' << j+even << '\n';
    }
}


Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int n, q;
  cin >> n >> q;
  ll a[100010];
  rep(i, n) cin >> a[i];
  ll sum_l[100010], sum_r[100010];
  sum_r[n] = 0;
  for (int i = n; i > 0; --i)
  {
    sum_r[i - 1] = sum_r[i] + a[i - 1];
  }

  sum_l[0] = a[0], sum_l[1] = a[1];
  REP(i, 2, n)
  sum_l[i] = sum_l[i - 2] + a[i];

  rep(qi, q)
  {
    ll x;
    cin >> x;
    auto simulate = [&](ll i) {
      if (n - 1 - 2 * i < 0)
        return true;
      return abs(a[n - 1 - i] - x) < abs(a[n - 1 - 2 * i] - x);
    };

    auto binary_search = [&]() {
      ll lo = 0, hi = n;
      while (hi - lo > 1)
      {
        ll mi = (lo + hi) / 2;
        if (simulate(mi))
          hi = mi;
        else
          lo = mi;
      }
      return hi;
    };

    int i = binary_search();
    ll ans = sum_r[n - i] + sum_l[n - 1 - 2 * i];
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

array<array<array<array<int, 50>, 50>, 50>, 50> visited{};

int main() {
    int h, w;
    while(cin >> w >> h, h){
        vector<vector<int>> v(h+2, vector<int>(w+2, 0));
        auto u = v;
        for(auto &&i: visited) for(auto &&j: i) for(auto &&k: j) fill(k.begin(),k.end(), 0);
        int sy1, sx1, sy2, sx2, gy1, gx1, gy2, gx2;
        for (int i = 0; i < h; ++i) {
            string s, t;
            cin >> s >> t;
            for (int j = 0; j < w; ++j) {
                v[i+1][j+1] = (s[j] != '#');
                u[i+1][j+1] = (t[j] != '#');
                if(s[j] == 'L') sy1 = i, sx1 = j;
                if(t[j] == 'R') sy2 = i, sx2 = j;
                if(s[j] == '%') gy1 = i, gx1 = j;
                if(t[j] == '%') gy2 = i, gx2 = j;
            }
        }
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                for (int k = 0; k < h; ++k) {
                    for (int l = 0; l < w; ++l) {
                        if((i != gy1 || j != gx1) && (k == gy2 && l == gx2)) visited[i][j][k][l] = 1;
                        if((i == gy1 && j == gx1) && (k != gy2 || l != gx2)) visited[i][j][k][l] = 1;
                    }
                }
            }
        }
        using tup = array<int, 4>;
        queue<tup> s;
        s.emplace(tup{sy1, sx1, sy2, sx2});
        visited[sy1][sx1][sy2][sx2] = 1;
        tup di = {-1, 1, 0, 0}, dj = {0, 0, 1, -1};
        while(!s.empty()){
            auto x = s.front(); s.pop();
            for (int k = 0; k < 4; ++k) {
                tup to(x);
                if(v[to[0]+di[k]+1][to[1]+dj[k]+1]){
                    to[0] += di[k];
                    to[1] += dj[k];
                }
                if(u[to[2]+di[k]+1][to[3]-dj[k]+1]){
                    to[2] += di[k];
                    to[3] -= dj[k];
                }
                if(!visited[to[0]][to[1]][to[2]][to[3]]) {
                    visited[to[0]][to[1]][to[2]][to[3]] = 1;
                    s.emplace(to);
                }

            }
        }
        puts(visited[gy1][gx1][gy2][gx2] ? "Yes" : "No");
    }

    return 0;
}


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

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

#define MAXN 100001
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FAIL {printf("-1\n"); return 0;}

int N;
int S[100];

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);

    scanf("%d", &N);
    int k = 0;

    if (N == 0) {
        S[0] = 0;
        k++;
    } else {
        while (N) {
            if (abs(N) % 2) {
                S[k] = 1;
                if (k % 2) N += 1;
                else N -= 1;
            } else {
                S[k] = 0;
            }

            k++;
            N /= 2;
        }
    }
    while (--k >= 0) {
        printf("%c", '0' + S[k]);
    }
    printf("\n");
    return 0;
}

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

int main() {
    ll X;
    cin >> X;
    ll n = X % 100;
    ll cnt = 0;
    while (n != 0) {
        if (n >= 5)
            n -= 5;
        else
            n = 0;
        cnt++;
    }
    n = X / 100;
    if ((n - cnt) >= 0) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    veci a(3);
    cin >> a[0] >> a[1] >> a[2];
    int f=0,s=0;
    REP(i,3){
        if(a[i]==5){
            f++;
        }else if(a[i]==7){
            s++;
        }
    }
    if(f==2&&s==1){
        cout << "YES" <<endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
# coding: UTF-8
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    s,c=[0]*M,[0]*M
    d={}
    for i in range(M):
        s,c=map(int,input().split())
        if s in d:
            if c!=d[s]:
                print(-1)
                exit()
        else:
            d[s]=c
    if N!=1 and 1 in d and d[1]==0:
        print(-1)
        exit()
    ans=''
    if N==1 and M==0:
        print(0)
        exit()
    for i in range(1,N+1):
        if i in d:
            ans+=str(d[i])
        else:
            if i==1:
                ans+='1'
            else:
                ans+='0'
    print(ans)

    

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
/*author: hyperion_1724
  date: 
*/

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(int i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define trav(x,A) for(auto &x:A)
#define veci vector<int>
#define vecl vector<long long>
#define FORI(a,b,c) for(int a=b;a<c;a++)
#define FORD(a,b,c) for(int a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

	READV(N);
	READV(A);
	READV(B);
	cout<<min(N*A,B)<<endl;

	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);

int dfs(int n, vector<int> &dp, vector<vector<int>> &edge){
  if(dp[n] != -1)return dp[n];

  int tmp=0;
  REP(i,edge[n].size()){
    tmp = max(tmp, dfs(edge[n][i], dp, edge)+1);
  }
  return dp[n]=tmp;
}

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

  vector<vector<int>> edge(N, vector<int>());

  REP(i,M){
    int x,y;
    cin >> x >> y;
    edge[--x].push_back(--y);
  }

  vector<int> dp(N,-1);

  REP(i,N){
    dfs(i,dp,edge);
  }

  int ans=0;
  REP(i,N){
    ans=max(ans,dp[i]);
  }
  cout << ans << endl;

}



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

int main(){
  int N,m,ans,i;
  ans=0;
  i=0;
  while(1){
    ans =0;
    cin >> N;
    for(int a=1;a<N;a++){
      m=0;
      for(i=a;i<N;i++){
	m+=i;
	if(m==N){
	  ans++;
	}
      }
    }
    if(N==0){
      break;
    }
    cout << ans << endl;
  }
  return 0;
}

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

#include <cstdlib>  // abs() for integer 絶対値求めやつ

#include <cmath>    // abs() for float, and fabs()

#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0; i< (n);i++)

#define SORT(a) sort((a).begin(),(a).end());

#define che(a,string) cout<<string<<":"<<(a)<<endl;

#define ch(a,string) cout<<string<<":"<<(a)<<" ";

using namespace std;

typedef pair<int,int> P;

int main(){
	string S;
	cin >>S;
	int ans =700;
	rep(i,3){
		if(S.at(i)!='x'){
		  ans+=100;
		  }
	  }
	  cout<<ans<<endl;
}



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

#ifdef local
#define debug(var) cerr << #var << " = " << var;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

int a[123434];

void solve() {
	int n, x; scanf("%d %d", &n, &x);
	for (int i = 0; i < n; ++i) {
		scanf("%d", a+i);
	}
	long long ans = 0;
	for (int i = 0; i < n-1; ++i) {
		if (a[i]+a[i+1] > x) {
			int t = max(0, min(a[i+1], a[i]+a[i+1]-x));
			ans += t;
			a[i+1] -= t;
			t = max(0, min(a[i], a[i]+a[i+1]-x));
			ans += t;
			a[i] -= t;
		}
	}
	printf("%lld", ans);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 640
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

main :: IO ()
main = do
	n <- readLn
	items <- replicateM n $ BS.getLine
	print . Set.size $ Set.fromList items

Measured memory_bytes: 65204
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int64_t gcd(int64_t a, int64_t b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;

	int v = gcd(n, 360);
	int m = n * 360 / v;
	cout << m / n << endl;

	return 0;
}

Measured memory_bytes: 3652
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
typedef pair<P,long double> Pi;
typedef pair <long double,int> Pd;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
vector<ll> a,f;
ll n,k;
bool C(ll m){
  ll minus=0;
   for(int i=0;i<n;i++){
     if(a[i]*f[i]>m){
           minus+=(a[i]*f[i]-m+f[i]-1)/f[i];
     }
   }
   if(minus>k)return false;
   else return true;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>k;
a.resize(n);f.resize(n);
for(int i=0;i<n;i++){
  cin>>a[i];
}
for(int i=0;i<n;i++){
  cin>>f[i];
}
sort(all(a));
sort(all(f),greater<ll>());
ll l=-1,r=inf;
while(r-l>1){
   ll mid=(l+r)/2;
   if(C(mid))r=mid;
   else l=mid;
}
cout<<r<<endl;
}



Measured memory_bytes: 3456
#include<cstdio>//AT2043
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib>

using namespace std;

int n,m;

char ch[2]={'.','#'};

char ch2[2]={' ','\n'};

int red[502][502],blue[502][502];

char purple[502][502];

int main(){
    scanf("%d%d",&n,&m);
    scanf("\n");
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            scanf("%c",&purple[i][j]);
        }
        if(i<n){
            scanf("\n");
        }
    }
    for(int i=1;i<=n;i++){
        if(i%2){
            for(int j=1;j<m;j++){
                red[i][j]=1;
            }
            blue[i][m]=1;
        }
        else{
            for(int j=2;j<=m;j++){
                blue[i][j]=1;
            }
            red[i][1]=1;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(red[i][j]==0&&purple[i][j]==ch[1]){
                red[i][j]=1;
            }
            if(blue[i][j]==0&&purple[i][j]==ch[1]){
                blue[i][j]=1;
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            printf("%c",red[i][j]?ch[1]:ch[0]);
        }
        printf("\n");
    }
    printf("\n");
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            printf("%c",blue[i][j]?ch[1]:ch[0]);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll h, w; cin >> h >> w;

	if (h % 3 == 0 || w % 3 == 0) {
		cout << 0 << endl;
		return 0;
	}

	ll ans = TEN(15);
	if (h >= 3) ans = min(ans, w);
	if (w >= 3) ans = min(ans, h);

	if (w >= 2) {
		FOR(i, 1, h) {
			ll mi = min(h - i, i);
			ll ma = max(h - i, i);
			vl v = { mi * w, ma * (w / 2), ma * (w - w / 2) };
			sort(ALL(v));
			ans = min(ans, v[2] - v[0]);
		}
	}
	if (h >= 2) {
		FOR(i, 1, w) {
			ll mi = min(w - i, i);
			ll ma = max(w - i, i);
			vl v = { mi * h, ma * (h / 2), ma * (h - h / 2) };
			sort(ALL(v));
			ans = min(ans, v[2] - v[0]);
		}
	}

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


Measured memory_bytes: 256
#ceilevenoddformula
import math
from queue import PriorityQueue
import bisect
import copy
import time
from collections import Counter
#map(int,input().split())
#int(x) for x in input().split()
x,k,d=map(int,input().split())
x=abs(x)
if x%d==0:
	c=x//d
	if c==k:
		print(0)
	elif c<k:
		k=k-c
		if k%2==0:
			print(0)
		else:
			print(d)
	else:
		print(x-k*d)
else:
	c1=x-(x//d)*d
	c2=abs(c1-d)
	cc1=x//d
	cc2=cc1+1
	if k==cc1:
		print(c1)
	elif k==cc2:
		print(c2)
	elif cc1<k:
		k=k-cc1
		if k%2==0:
			print(c1)
		else:
			print(c2)
	else:
		print(x-k*d)	











 
          





























Measured memory_bytes: 74900
#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()
{
    ll N,K;
    cin >> N >> K;
    vector<int> A(N);
    int box[60][200000+1] = {0};
    rep(i, N)
    {
        cin >> A[i];
        box[0][i+1] = A[i];
    }
    int ans = 1;
    
    for(int i = 1; i < 60; ++i)
    {
        for(int j = 1; j < N+1; ++j)
        {
            box[i][j] = box[i-1][box[i-1][j]];
        }
    }
    
    for(int i = 0; i < 60; ++i)
    {
        if(K % 2)
        {
            ans = box[i][ans];
            if(K == 1)
                break;
        }
        K = K / 2;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 51024
# encoding:utf-8

import numpy as np
import random

a,b = map(str, input().split())

square_numbers = []
for i in range(1000):
    if i**2 <= 100100:
        square_numbers.append(i**2)
    else:
        break

if int(a+b) in square_numbers:
    print("Yes")
else:
    print("No")


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

int main(){
	int N;
	cin >> N;
	vector<int> P(N);
	vector<int> Q(N);
	rep(i,N){
		cin >> P[i];
	}
	rep(i,N){
		cin >> Q[i];
	}
	vector<int> d(N);
	rep(i,N){
		d[i] = i+1;
	}
	
	int a,b = 0;
	int count = 0;
	
	do{
		bool ok1 = true;
		rep(i,N){
			if(d[i] != P[i]) ok1 = false;
		}
		if (ok1){
			a = count;
			
		}
		bool ok2 = true;
		rep(i,N){
			if(d[i] != Q[i]) ok2 = false;
		}
		if (ok2){
			b = count;
		}
		count++;
	}while (next_permutation(d.begin(),d.end()));
	
	cout << abs(a-b) << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define frw(i, a, b) for(int i = a; i < b; i++)
#define fi first
#define se second
#define pb push_back
#define in insert
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) int(a.size())
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define vpii vector<pii>
#define vpiii vector<piii>
#define vpll vector<pll>
#define vplll vector<plll>
#define mo 1000000007
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}

vector<ll>v[100005];


int main() {
	ll n,m;
	cin>>n>>m;
	ll s[n],t[m];
	for(int i=0;i<n;i++)
		cin>>s[i];
	for(int i=0;i<m;i++)
		cin>>t[i];
	//cin>>s>>t;
	ll k,l;
	k=n;
	l=m;
	ll dp[k+1][l+1];
	for(int i=0;i<=k;i++)
		for(int j=0;j<=l;j++)
			dp[i][j]=0;


	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=l;j++)
		{
			
			if(s[i-1]==t[j-1])
				dp[i][j]=madd(1,madd(dp[i-1][j],dp[i][j-1]));
			else
				dp[i][j]=msub(madd(dp[i][j-1],dp[i-1][j]),dp[i-1][j-1]);
		}
	}
	cout<<dp[k][l]+1;

}


Measured memory_bytes: 33920
N,A,B = input().split()
N,A,B = map(int,(N,A,B))
f=0
for i in range(1,N+1):
  k=i
  a = i//10000
  i = i-a*10000
  b = i//1000
  i = i-b*1000
  c = i//100
  i = i-c*100
  d = i//10
  i = i-d*10
  e = i
  s = a+b+c+d+e
  if A<=s<=B:
    f += k
print(f)



Measured memory_bytes: 9088
#include<iostream>
#include<map>
#include<cstring>
using namespace std;

const int maxn = 1e6;
const int p = 1e9+7;
long long dp[maxn+5];
long long pre[maxn+5];

long long add(long long x, long long y) {
    return (x+y)%p;
}

int n;

int main() {
    cin>>n;
    dp[0] = 1;
    dp[1] = n;
    pre[0] = 1;
    pre[1] = n+1;
    long long n_n = (long long)(n-1)*(n-1)%p;
    for (int m = 2; m <= n; ++m) {
        long long ans = dp[m-1];
        
        ans = add(ans, n_n);
        ans = add(ans, m-3 >= 0 ? pre[m-3] : 0);
        ans = add(ans, n+1-m);
        dp[m]=ans;
        pre[m] = add(pre[m-1], dp[m]);
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 15872
from collections import deque
n,m,s,t = map(int,input().split())
edgem = [[]for i in range(n)]
edges = [[]for i in range(n)]
for i in range(m):
    u,v,a,b = map(int,input().split())
    edgem[u-1].append([v-1,a])
    edgem[v-1].append([u-1,a])
    edges[u-1].append([v-1,b])
    edges[v-1].append([u-1,b])

costm = [float('inf')]*n
costs = [float('inf')]*n
costm[s-1],costs[t-1] = 0,0

queue = deque([s-1])
while queue.__len__() > 0:
    p = queue.popleft()
    for a,b in edgem[p]:
        if costm[a] > costm[p] + b:
            costm[a] = costm[p] + b
            queue.append(a)
queue = deque([t-1])
while queue.__len__() > 0:
    p = queue.popleft()
    for a,b in edges[p]:
        if costs[a] > costs[p] + b:
            costs[a] = costs[p] + b
            queue.append(a)
ans = [float('inf')]*n
for i in range(n):
    ans[i] = costm[i] + costs[i]
for i in range(n-1,0,-1):
    ans[i-1] = min(ans[i-1],ans[i])
money = 10**15
for i in ans:
    print(money-i)

Measured memory_bytes: 126188
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	in_v(ll, c, 9);
	YesNo(
		   c[0] - c[3] == c[1] - c[4] && c[1] - c[4] == c[2] - c[5]
		&& c[0] - c[6] == c[1] - c[7] && c[1] - c[7] == c[2] - c[8]
		&& c[0] - c[1] == c[3] - c[4] && c[3] - c[4] == c[6] - c[7]
		&& c[0] - c[2] == c[3] - c[5] && c[3] - c[5] == c[6] - c[8]
	);
	return 0;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.15f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

struct Cmb
{
	void init(long n)
	{
		long powmod(long a, long p)
		{
			long ans = 1;
			long mul = a;
			while (p > 0)
			{
				if ((p & 1) == 1)
					modm(ans, mul);
				p >>= 1;
				modm(mul, mul);
			}
			return ans;
		}

		++n;
		fact = new long[2][](n);
		fact[0][0] = 1;
		foreach (i; 1..n)
		{
			fact[i][0] = fact[i-1][0];
			modm(fact[i][0], i);
		}
		fact[n-1][1] = powmod(fact[n-1][0], mod - 2);
		foreach_reverse (i; 0..n-1)
		{
			fact[i][1] = fact[i+1][1];
			modm(fact[i][1], i+1);
		}
	}

	long get(long a, long b)
	{
		long r = fact[a][0];
		modm(r, fact[b][1]);
		modm(r, fact[a-b][1]);
		return r;
	}

	long[2][] fact;
}

void main()
{
	auto H = RD;
	auto W = RD;
	auto A = RD;
	auto B = RD;

	Cmb cmb;
	cmb.init(H+W);

	long ans;
	foreach (x; 0..W-B)
	{
		auto c1 = cmb.get(B+x+H-A-1, B+x);
		auto c2 = cmb.get(W-B-x-1+A-1, A-1);
		c1.modm(c2);
		ans.moda(c1);
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}

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

#define ii pair<int, int>
#define lli long long int
#define ll pair<lli, lli>
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

bool prime(int a) {
	int akar = sqrt(a);
	for (int i = 2; i <= akar; i++)
		if (a % i == 0)
			return false;
	return true;
}

int main() {
	int x;
	scanf("%d", &x);
	while (!prime(x))
		x++;
	printf("%d\n", x);
	return 0;
}

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

using namespace std;
map<int,int> m1;

int main(){
    int n;
    cin>>n;
    int ans = 0;
    for(int i=1;i<=n;i++){
        int x;
        cin>>x;
        m1[x]++;
    }
    for(auto x:m1){
        ans+=(x.second-1);
    }
    if(ans%2 == 0){
        cout<<m1.size()<<endl;
    }else{
        cout<<m1.size()-1<<endl;
    }
}

Measured memory_bytes: 8216
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2")

#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <chrono>
#include <vector>
#include <map>
#include <random>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <stdio.h>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <deque>
#include <cassert>
#include <stack>
using namespace std;

#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ppb pop_back
#define ll long long
#define ull unsigned long long
#define cntbit(x) __builtin_popcount(x)
#define endl '\n'
#define uset unordered_set
#define umap unordered_map
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define ld long double
#define pll pair<long long, long long>

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

inline void setin(string s) {
	freopen(s.c_str(), "r", stdin);
}

inline void setout(string s) {
	freopen(s.c_str(), "w", stdout);
}

template <typename T> inline T range(T l, T r) {
	return uniform_int_distribution <T>(l, r)(rng);
}

template <typename T> void Min(T &a, T b) {
    a = min(a, b);
}
 
template <typename T> void Max(T &a, T b) {
    a = max(a, b);
}

#define int long long

const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int N = 2e5 + 15;
int n, a[N];
vector <int> is;

struct fenwick {
	int t[N];
	inline void inc(int i, int val) {
		for(; i < is.size(); i = (i | (i + 1)))
			t[i] += val;
	}
	inline int get(int i) {
		int res = 0;
		for(; i >= 0; i = (i & (i + 1)) - 1)
			res += t[i];
		return res;
	}
} t;

inline int gt(int x) {
	return lower_bound(is.begin(), is.end(), x) - is.begin();
}

int p[N], k;

main() {
	ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
	// setin("input.txt");
	cin >> n >> k;
	for(int i = 1; i <= n; ++i) {
		cin >> a[i];
		p[i] = p[i-1] + a[i];
		is.pb(p[i] - k * i);
	}
	is.pb(0);
	sort(is.begin(), is.end());
	is.erase(unique(is.begin(), is.end()), is.end());

	int ans = 0;

	for(int i = 1; i <= n; ++i) {
		t.inc(gt(p[i-1] - k * (i - 1)), 1);
		ans += t.get(gt(p[i] - k * i));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6640
from math import *

A, B, H, M = [float(i) for i in input().split()]

y1 = sin(-H/6*pi+0.5*pi-M/60/6*pi)*A
x1 = cos(-H/6*pi+0.5*pi-M/60/6*pi)*A
x2 = cos(-M/30*pi+0.5*pi)*B
y2 = sin(-M/30*pi+0.5*pi)*B
print(sqrt((x2-x1)**2+(y2-y1)**2))

Measured memory_bytes: 9516
#include<stdio.h>
#include<stdlib.h>

int main(){
  char C[2][3];
  for(int i = 0; i < 2; i++){
    scanf("%s", &C[i]);
  }
  for(int i = 0; i < 3; i++){
    if(C[0][i] != C[1][2 - i]){
      printf("NO\n");
      exit(0);
    }
  }
  printf("YES\n");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
using namespace std;
int a[100005],n,k,q,b;
int main(){
	scanf("%d%d%d",&n,&k,&q);
	for(int i=1;i<=q;i++){
		scanf("%d",&b);
		a[b]++;
	}
	for(int i=1;i<=n;i++){
		if(a[i]>q-k)cout<<"Yes\n";
		else cout<<"No\n";
	}
	return 0;
}

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

const int MAXN = 100055;

char A[MAXN];
int B[MAXN], C[MAXN];

int Q;

int main() {
	scanf(" %s", A+1);
	for(int i = 1; A[i]; i++)
		B[i] = B[i-1] + ('A' == A[i] ? 1 : 2);
	scanf(" %s", A+1);
	for(int i = 1; A[i]; i++)
		C[i] = C[i-1] + ('A' == A[i] ? 1 : 2);
	scanf("%d", &Q);
	for(int a, b, c, d; Q--;) {
		scanf("%d%d%d%d", &a, &b, &c, &d);
		a = B[b] - B[a-1];
		c = C[d] - C[c-1];
		a %= 3; c %= 3;
		puts(a == c ? "YES" : "NO");
	}
	return 0;
}

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

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

constexpr int MOD = 998244353;

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

    int n, s, ans = 0;
    cin >> n >> s;

    vll dp(s + 1, 0);

    rep(i, 0, n) {
        int a;
        cin >> a;
        ++dp[0];
        if (s >= a) { ans = (ans + dp[s - a] * (n - i)) % MOD; }
        rrep(j, 0, s - a) { dp[j + a] = (dp[j + a] + dp[j]) % MOD; }
    }
    cout << ans << endl;

    return 0;
}

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

int main(int argc, char const *argv[]) {
  int N;
  scanf("%d", &N);

  int c = 0;
  for (size_t i = 0; i < N; i++) {
    int a;
    scanf("%d", &a);
    if (a % 2 == 1 && i % 2 == 0) {
      c++;
    }
  }

  printf("%d\n", c);
  return 0;
}


Measured memory_bytes: 1712
#include <stdio.h>
#include <stdlib.h>
int main (void) {
char *Seasons[3] ={"Sunny","Cloudy","Rainy"};
char S[10]={'\0'};
scanf("%s",S);
for (int i=0;i<3;i++){
    if (strcmp(S,Seasons[i])==0) {if (i<2) {printf("%s",Seasons[i+1]);}
                                   else printf("Sunny");}
}



return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#include <bits/stdc++.h>
#define pb(X) push_back(X)
using namespace std;

int n, a, b, c, d, q, ans;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t, u;
	cin >> s >> t >> a >> b >> u;
	if( u == s) --a;
	else --b;
	cout << a << ' ' << b;

	return 0;
}

Measured memory_bytes: 256
import math

N = int(input())
A = N // 1.08
A2 = A + 1

if math.floor(A * 1.08) == N:
	ans = int(A)
	print(ans)
elif math.floor(A2 * 1.08) == N:
	ans = int(A2)
	print(ans)
else:
	print(":(")

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

int main(){
	static int w,h,dp[100+2][100+2][2][2];
	for(int i=0;i<102;i++){
		for(int j=0;j<102;j++){
			for(int k=0;k<4;k++){
				dp[i][j][(k-k%2)/2][k%2]=0;
			}
		}
	}
	dp[3][1][0][0]=1;
	dp[2][2][0][1]=1;
	dp[2][2][1][0]=1;
	dp[1][3][1][1]=1;
	for(int i=1;i<101;i++){
		for(int j=max(1,5-i);j<101;j++){
			dp[i][j][0][0]=(dp[i-1][j][0][0]+dp[i-1][j][1][0])%100000;
			dp[i][j][0][1]=dp[i][j-1][0][0]%100000;
			dp[i][j][1][0]=dp[i-1][j][1][1]%100000;
			dp[i][j][1][1]=(dp[i][j-1][0][1]+dp[i][j-1][1][1])%100000;
		}
	}
	while(1){
	scanf("%d%d",&w,&h);
	if(w==0&&h==0)break;
	printf("%d\n",(dp[w][h][0][0]+dp[w][h][0][1]+dp[w][h][1][0]+dp[w][h][1][1])%100000);
	}
}

Measured memory_bytes: 1348
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define VI vector<int>
#define VII vector<vector<int>>
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)


int main(){
    int N;cin>>N;
    if(N==2){
        int A,B;cin>>A>>B;
        cout<<A+B<<endl;
    }
    else cout<<"Hello World\n";
}

Measured memory_bytes: 256
<?php
list($n, $y) = explode(' ', fgets(STDIN));
$r10000 = -1;
$r5000 = -1;
$r1000 = -1;
for($a = 0; $a <= $n; $a++){
  for($b = 0; $a+$b <= $n; $b++){
    $c = $n - $a - $b;
    if(10000 * $a + 5000 * $b + 1000 * $c == $y){
      $r10000 = $a;
      $r5000 = $b;
      $r1000 = $c;
    }
  }
}
printf('%d %d %d', $r10000, $r5000, $r1000);
?>

Measured memory_bytes: 3576
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}


int main(void) {
    int i,j;
    int n,m;
    cin >> n >> m;
    vi imos(n+1,0);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        imos[a]++;
        imos[b]--;
    }
    rep(i,n)imos[i+1]+=imos[i];
    int ans = 0;
    rep(i,n+1){
        ans++;
        if(imos[i])ans+=2;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3128
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan =new Scanner(System.in);
    		
    		char[]s =scan.next().toCharArray();
    		
    		int ans=0;
    		for (char i:s) {
    			if (i=='-') {
    				--ans;
    			}else {
    				++ans;
    			}
    		}
    		
    		System.out.print(ans);

    		
     
    }
    }
// end 

Measured memory_bytes: 22612
// 答えあってるのになぜか通らない

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

struct store {
  long price;
  long stock;
};

int main() {
  long N, M;
  cin >> N >> M;

  // vector<long> A;
  // vector<long> B;
  vector<store> S;

  long price;
  long stock;
  for (long i = 0; i < N; i++)
  {
    S.push_back(store());
    cin >> price >> stock;
    S[i].price = price;
    S[i].stock = stock;
  }

  sort(S.begin(), S.end(), [](const store& x, const store& y) { return x.price < y.price; });

  long want = M;
  long total_price = 0;
  for (long i = 0; S.size(); i++) {
    if (want == 0) { break; }
    if (want - S[i].stock > 0) {
      want -= S[i].stock;
      total_price += S[i].stock * S[i].price;
    } else {
      total_price += want * S[i].price;
      want = 0;
    }
  }

  printf("%ld", total_price);

  return 0;
}


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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fastt ios_base::sync_with_stdio(false); cin.tie(NULL)

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

/*-----------------------------------------------------------------------*/

int main(){
   fastt;

   int n;
   cin>>n;

   int height[n];
   int dp[n];

   for(int i=1;i<=n;i++){
      cin>>height[i];
      dp[i]=2e9;
   }

   dp[1]=0;

   for(int i=1;i<=n;i++){
      if(i<n){
         dp[i+1]=min(dp[i+1],dp[i]+abs(height[i+1]-height[i]));
      }
      if(i<n-1){
         dp[i+2]=min(dp[i+2],dp[i]+abs(height[i+2]-height[i]));
      }
   }

   cout<<dp[n]<<endl;

   return 0;
}


Measured memory_bytes: 1024
from math import factorial
n, m = map(int, input().split())

if abs(n - m) > 1:
    print(0)
elif n == m:
    print(factorial(n) * factorial(m) * 2 % (10 ** 9 + 7))
else:
    print(factorial(n) * factorial(m) % (10 ** 9 + 7))


Measured memory_bytes: 5196
// Problem : E - Dist Max
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e9 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

// sprawdz MODULO!
int main() {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n; cin >> n;
	int maxx = -inf, minx = inf, maxy = -inf, miny = inf;
	REP(i, n) {
		int x, y;
		cin >> x >> y;
		maxi(maxx, x + y);
		mini(minx, x + y);
		maxi(maxy, x - y);
		mini(miny, x - y);
	}
	cout << max(maxx - minx, maxy - miny);
	return 0;
}
 


Measured memory_bytes: 3652
#include <cstdio>

typedef long long ll;
const int MAXN = 3e5 + 19, MOD = 998244353;

int root, ind, s[MAXN];

struct Node{
	int ls, rs;
	int sum, tag;
}tr[MAXN << 1];

inline void push_up(int node){
	tr[node].sum = (tr[tr[node].ls].sum + tr[tr[node].rs].sum) % MOD;
}

inline void push_down(int node, int L, int R){
	if(tr[node].tag == -1) return;
	int mid = (L + R) >> 1;
	if(!tr[node].ls) tr[node].ls = ++ind;
	if(!tr[node].rs) tr[node].rs = ++ind;
	tr[tr[node].ls].sum = (ll)(s[mid] - s[L - 1]) * tr[node].tag % MOD;
	tr[tr[node].ls].tag = tr[node].tag;
	tr[tr[node].rs].sum = (ll)(s[R] - s[mid]) * tr[node].tag % MOD;
	tr[tr[node].rs].tag = tr[node].tag;
	tr[node].tag = -1;
}

void modify(int &node, int L, int R, int l, int r, const int &val){
	if(!node) node = ++ind;
	if(l <= L && R <= r){
		tr[node].sum = (ll)(s[R] - s[L - 1]) * val % MOD;
		tr[node].tag = val;
		return;
	}
	push_down(node, L, R);
	int mid = (L + R) >> 1;
	if(l <= mid) modify(tr[node].ls, L, mid, l, r, val);
	if(r > mid) modify(tr[node].rs, mid + 1, R, l, r, val);
	push_up(node);
}

int query(int node, int L, int R, int l, int r){
	if(l <= L && R <= r) return tr[node].sum;
	push_down(node, L, R);
	int mid = (L + R) >> 1, res = 0;
	if(l <= mid) res = (res + query(tr[node].ls, L, mid, l, r)) % MOD;
	if(r > mid) res = (res + query(tr[node].rs, mid + 1, R, l, r)) % MOD;
	push_up(node);
	return res;
}

int n, q;
int bit[MAXN];

int main(){
	std::scanf("%d%d", &n, &q);
	
	bit[n] = 1;
	for(int i = n - 1; i >= 1; --i)
		bit[i] = (ll)bit[i + 1] * 10 % MOD;
	for(int i = 1; i <= n; ++i)
		s[i] = (s[i - 1] + bit[i]) % MOD;
	
	modify(root, 1, n, 1, n, 1);
	
	while(q--){
		int l, r, d; std::scanf("%d%d%d", &l, &r, &d);
		modify(root, 1, n, l, r, d);
		std::printf("%d\n", (query(root, 1, n, 1, n) + MOD) % MOD);
	}
	
	return 0;
}

Measured memory_bytes: 10120
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (!n) return 0;
    long long p[10000];
    for (int i = 0; i < n; i++)
      cin >> p[i];
    sort(p, p+n);
    long long s = 0;
    for (int i = 1; i < n; i++)
      s += p[i-1]*(n-i);
    cout << s << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;


int main(){
   int a, b;
   cin >> a >> b;
   out(max({a+b, a-b, a*b}));
}

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

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

    int ans = 0, l= 0, r = s.length() - 1;
    while(l < r){
        if(s[l] == 'W' && s[r] == 'R'){
            swap(s[l], s[r]);
            ans += 1;
        }
        if(s[l] == 'R') l += 1;
        if(s[r] == 'W') r -= 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void call(int n) {
	for (int i = 1; i < n+1; ++i) {
		if (i%3 == 0) {
			cout << " " << i;
		}
		else {
			int num = i;
			while (num > 0) {
				if (num%10 == 3) {
					cout << " " << i;
					num = 0;
				}
				num /= 10;
			}
		}
	}
	cout << endl;
}

int main(void) {
	int n;
	cin >> n;
	call(n);
	return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp make_pair
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define INF 0x3f3f3f3f

typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<double,double> pdd;
set<ll> s;
int main()
{
    rep1(i,9) rep1(j,9) s.insert(i*j);
    ll n;
    while(cin>>n)
    {
        if(s.count(n)) cout<<"Yes\n";
        else cout<<"No\n";
    }

    return 0;
}



Measured memory_bytes: 256
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

pad_S = [['.']*(W+2)] + [['.']+s+['.'] for s in S] + [['.']*(W+2)]

def calc_bomb(r, c, pad_S):
    h = pad_S[r-1][c-1:c+2].count('#')
    m = pad_S[r][c-1:c+2].count('#')
    l = pad_S[r+1][c-1:c+2].count('#')
    return h+m+l

for i, s in enumerate(S):
   r = i+1 
   lis = []
   for k, char in enumerate(s):
       c = k+1
       if char == '#':
           lis.append('#')
       else:
           lis.append(str(calc_bomb(r, c, pad_S)))
   print(''.join(lis))


Measured memory_bytes: 3064
N, K = map(int, input().split())

d = []
A = []
for i in range(K):
  d_temp = int(input())
  d.append(d_temp)
  A = A + list( map(int, input().split()))

B = [m + 1 for m in range(N)]
print(len(list(set(B) - set(A))))

Measured memory_bytes: 67644