akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> ordered_mset;
    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;
/*.....................................................................................................................*/

    const ll mod=(ll)1e9+7;
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
    long long binpow(long long x, long long p) 
    {
        if (p == 0) {return 1;}
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    const ll man=(ll)1e5+5;
/*........................................................................................................................*/

ll dp[10005];
signed main()
{
    fast;
    ll h,n;
    cin>>h>>n;
    ll a[n],b[n];
    For(i,n)cin>>a[i]>>b[i];
    For(i,10005)dp[i]=mod;
    dp[0]=0;
    f(x,1,h+2)
    {
        For(i,n)
        {
            ll val;
            if(x-a[i]<0)val=0;
            else val=dp[x-a[i]];
            dp[x]=min(dp[x],val+b[i]);
        }
    }
    cout<<dp[h]<<endl;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
typedef long long ll;
#define fi first
#define se second
#define pii pair<int,int>
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(s) (int)s.size()
#define y1 fdfbvfds
typedef long double f80;
#define all(x) x.begin(), x.end()
typedef long double f80;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l,ll r){
    uniform_int_distribution<ll> uid(l, r);
    return uid(rng);
}
 
const int mod = 998244353;
int pwr(int a,int b) {
    int ans = 1;
    while(b) {
        if(b & 1) {
            ans = (ans * 1LL * a) % mod;
        }
        a = (a * 1LL * a) % mod;
        b >>= 1;
    }
    return ans;
}

const int NN = 4e6 + 5;
map<pair<string,string>,int> m;
 
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int mask = 0; mask < (1 << n); mask++) {
        string s1 = "", s2 = "";
        fr(j, 0, n - 1) {
            if((mask >> j) & 1) s1 += s[j];
            else s2 += s[j];
        }
        m[{s1, s2}]++;
    }
    reverse(all(s));
    ll ans = 0;
    for(int mask = 0; mask < (1 << n); mask++) {
        string s1 = "", s2 = "";
        fr(j, 0, n - 1) {
            if((mask >> j) & 1) s1 += s[j];
            else s2 += s[j];
        }
        ans += m[{s1, s2}];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 91904
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <numeric>
#include <algorithm>


template <typename DataType>
auto convert(const std::string& data_str) -> DataType {
	std::stringstream ss;
	DataType ret {};

	ss << data_str;
	ss >> ret;

	return ret;
}


auto split(const std::string& str) {
	std::vector<std::string> ret {};

	std::size_t currentp {}, nextp {};
	while(true) {
		nextp = str.find_first_of(' ', currentp);

		ret.push_back(str.substr(currentp, nextp-currentp));
		
		if(nextp == std::string::npos)
			break;
		
		currentp = nextp + 1;
	}

	return ret;
}


auto extractData(const std::string& str, uint64_t num) {
	std::vector<uint64_t> skill_set(num, 0);
	auto str_set = split(str);

	for(int i = 0; i < str_set.size(); ++i)
		skill_set[i] = convert<uint64_t>(str_set[i]);

	return skill_set;
}


auto judge(uint64_t K, std::vector<uint64_t>& H_set) {
	if(K >= H_set.size())
		return uint64_t{};

	std::sort(H_set.begin(), H_set.end());

	return std::accumulate(H_set.begin(), H_set.end()-K, uint64_t{});
}


auto input() {
	std::string data {};
	std::getline(std::cin, data);
	return data;
}


void process() {
	auto data = extractData(input(), 2);
	auto H_set = extractData(input(), data[0]);
	std::cout << judge(data[1], H_set) << std::endl;
}

int main() {
	process();
}

Measured memory_bytes: 16004
n=int(input())
lists=list(map(int,input().split()))
a=lists.copy()
anslist=[0 for i in range(n+1)]
for j in lists:
    anslist[j]+=1
if anslist[0]!=1:
    print(0)
else:
    ans=1
    for j in range(n):
            for k in range(anslist[j+1]):
                ans=anslist[j]*ans
                ans=ans%(998244353)
    if a[0]!=0:
      print(0)
    else:
      print(ans)


Measured memory_bytes: 13908
n,m = map(int,input().split())
h_list = list(map(int,input().split()))
n_list = [1]*n
for i in range(m):
    a,b = map(int,input().split())
    if h_list[a-1] > h_list[b-1]:
        n_list[b-1] = 0
    elif h_list[a-1] < h_list[b-1]:
        n_list[a-1] = 0
    else:
        n_list[a-1] = 0
        n_list[b-1] = 0
count = 0
for i in n_list:
    if i == 1:
        count += 1
print(count)

Measured memory_bytes: 84996
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

int n;
int dp[ 8 ][ 1001 ];
int m, d, ans;
vector<PII> Cards;

int solve( const int now, const int now_score ) {
	if ( now == n ) {
		return now_score == 0;
	}
	if ( dp[ now ][ now_score ] >= 0 ) {
		return dp[ now ][ now_score ];
	}
	int res = 0;
	for ( int i = 0; i <= Cards[now].second; i++ ) {
		if ( now_score - Cards[ now ].first * i < 0 ) {
			break;
		}
		res += solve( now + 1, now_score - Cards[ now ].first * i );
	}
	return dp[ now ][ now_score ] = res;
}

int main() {
	while ( ~scanf( "%d", &n ) && n ) {
		NCLR( dp );
		Cards.resize( n );
		for ( int i = 0; i < n; i++ ) {
			scanf( "%d %d", &Cards[ i ].first, &Cards[ i ].second );
		}
		sort( Cards.begin(), Cards.end() );
		scanf( "%d", &m );
		for ( int i = 0; i < m; i++ ) {
			scanf( "%d", &d );
			ans = solve( 0, d );
			printf( "%d\n", ans );
		}
	}

	return 0;
}

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

int main() {
    int n;
  	string s;
    cin >> n >> s;
    if(n % 2 == 1) puts("No");
    if(n % 2 == 0){
        vector<char> a(n), b(n);
        for(int i = 0; i < n/2; i++)
        {
            a[i] = s.at(i);
        }
        for(int i = n/2; i < n; i++) 
        {
            b[i - n/2] = s.at(i);
        }
        if(a == b) puts("Yes");
        else puts("No");
    }
    return 0;
}

Measured memory_bytes: 256
n = input()

dp1 = [0] * (len(n) + 1)
dp2 = [1] * (len(n) + 1)

for i in range(1, len(n) + 1):
    m = int(n[i - 1])
    dp1[i] = min(dp1[i - 1] + m, dp2[i - 1] + 10 - m)
    dp2[i] = min(dp1[i - 1] + m + 1, dp2[i - 1] + 9 - m)

print(dp1[-1])

Measured memory_bytes: 68588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int k;
string s;
vector<string> vec;

int main(void)
{
	cin >> s;
	cin >> k;
	
	for(int i = 0; i < s.size(); i++){
		for(int j = 1; j <= k; j++){
			if(i+j > s.size()) continue;
			vec.push_back(s.substr(i, j));
		}
	}
	sort(vec.begin(), vec.end());
	vec.erase(unique(vec.begin(), vec.end()), vec.end());
	
	//for(int i = 0; i < vec.size(); i++) cout << vec[i] << endl;
	
	cout << vec[k-1] << endl;
	return 0;
}

Measured memory_bytes: 1660
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

void prime_factorize(int n, std::map<int,int>& prime_factors) {
	for(int i=2;i*i<=n;i++) {
		while(n%i==0) {
			prime_factors[i]++;
			n/=i;
		}
	}
	if(n!=1) prime_factors[n]++;
}


signed main() {
	int n;
	std::cin >> n;
	int min = n-1;
	for(int i=2;i*i<=n;i++) {
		if(n%i==0) {
			min = std::min(min,(i-1)+(n/i-1));
		}
	}
	print(min);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using ll=long long;
using ld=long double;
using pii=pair<int,int>;
using pll=pair<ll,ll>;	

int n;
int ara[305];
ld dp[305][305][305];
bool flag[305][305][305];

ld f(int o,int tw,int th)
{
	if(o<0 || tw<0 || th<0) return 0.0;
	
	int z=n-(o+tw+th);
	
	if(z==n) return 0.0;
	
	ld &ans=dp[o][tw][th];
	
	if(flag[o][tw][th]) return ans;
	
	
	ld a=(ld)o/(ld)n*(1.0+f(o-1,tw,th));
	ld b=ld(tw)/(ld)n*(1.0+f(o+1,tw-1,th));
	ld c=ld(th)/(ld)n*(1.0+f(o,tw+1,th-1));
	ld d=(ld)z/(ld)n;
	
	ld mul=(ld)n/(ld)(n-z);
	
	flag[o][tw][th]=1;
	return ans=(a+b+c+d)*mul;
}

void solve()
{
	cin>>n;
	
	int one=0,two=0,three=0;
	
	for(int i=0;i<n;i++)
	{
		cin>>ara[i];
		
		if(ara[i]==1) one++;
		else if(ara[i]==2) two++;
		else three++;
	}
	
	cout<<fixed<<setprecision(10);
	cout<<"\n"<<f(one,two,three);
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
	
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	
	return 0;
}


Measured memory_bytes: 467328
def resolve():
    S = input()
    abc = "abcdefghijklmnopqrstuvwxyz"
    count = 0
    if S[0]=="A":
        S = S[1:]
        if "C" in S[1:-1] and S.count("C")==1:
            S = S[:S.index("C")] + S[S.index("C")+1:]
            for i in range(len(S)):
                if S[i] in abc:
                    count += 1
            if count == len(S):
                print("AC")
            else:
                print("WA")
        else:
            print("WA")
    else:
        print("WA")
resolve()

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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a[i] = {x, i + 1};
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        cout << a[i].second << " ";    
    }
    return 0;
}

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

int main() {
    int n; cin >> n;
    int ans[n] = {};
    for (int i = 0; i < n - 1; i++) {
        int a; cin >> a;
        ans[a-1]++;
    }
    for (int i = 0; i < n; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

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

int main() {
    int n;
    int result = 0;

    cin >> n;

    vector<int> a(n);

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

    sort(a.begin(), a.end());

    if(n%2 == 0) {
        for(int i=0; i<n; i++) {
            if(i%2 == 0) result-=a[i];
            else         result+=a[i];
        }
    } else{
        for(int i=0; i<n; i++) {
            if(i%2 == 1) result-=a[i];
            else         result+=a[i];
        }
    }


    cout << result << endl;
}

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

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

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

  if(s=="ABC") cout << "ARC";
  else cout << "ABC";
}

Measured memory_bytes: 3596
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>

#define REP(i,n) for(int i=0; i<n; i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
 
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9

using namespace std;
typedef long long ll;

int main(){
	int n, ans=0;
	cin >> n;
	
	for (int i=105; i<=n; i+=2){
		int d = 0;
		for (int k=1; k<=i; k++){
			if (i%k==0) d++;
		}
		if (d==8){
			ans++;
			//cout << i << endl;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;
const double PI=3.14159265359;

signed main(){
  int n;
  while(cin>>n,n){
    vector<int> t(n);
    rep(i,n)cin>>t[i];
    sort(all(t));
    vector<int> wait(n+5);
    wait[0]=0;
    rep(i,n+1)wait[i+1]=wait[i]+t[i];
    rep(i,n)wait[i+1]+=wait[i];
    cout<<wait[n-1]<<endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N;
ll A[200000];

int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];
    for(int i=1;i<N;i++) A[i] += A[i-1];
    unordered_map<ll,ll> um;
    um[0]++;
    for(int i=0;i<N;i++) um[A[i]]++;
    ll ans = 0;
    for(auto &e : um){
        ll c = e.second;
        ans += c * (c-1) / 2;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

int main() {
  int n;
  cin >> n;
  vi h(n);
  rep (i, n) {
    cin >> h[i];
  }

  vi ans(n);
  int cnt = 0;
  for (int i = n - 2; i >= 0; i--) {
    if (h[i] >= h[i + 1]) cnt++;
    else cnt = 0;
    ans[i] = cnt;
  }

  int ma = 0;
  rep (i, n) {
    chmax(ma, ans[i]);
  }
  cout << ma << endl;
}


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

int a,b,c,d;

int main(){
    cin>>a>>b>>c>>d;
    if(a+b==c+d) cout<<"Balanced"<<endl;
    else if(a+b>c+d) cout<<"Left"<<endl;
    else cout<<"Right"<<endl;
    return 0;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){

    int m;
    cin >> m;
    cout << 48-m << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

lli agc[101][4][4][4][4];
lli bad[40][4] = {};

int main(void) {

	lli N;
	cin >> N;

	// a c g t

	for (int i = 0; i < 4; i++) {
		bad[i][0] = 0;
		bad[i][1] = 2;
		bad[i][2] = 1;
		bad[i][3] = i;
	}
	for (int i = 0; i < 4; i++) {
		bad[i + 4][0] = 2;
		bad[i + 4][1] = 0;
		bad[i + 4][2] = 1;
		bad[i + 4][3] = i;
	}
	for (int i = 0; i < 4; i++) {
		bad[i + 8][0] = 0;
		bad[i + 8][1] = 1;
		bad[i + 8][2] = 2;
		bad[i + 8][3] = i;
	}
	for (int i = 0; i < 4; i++) {
		bad[i + 12][0] = 0;
		bad[i + 12][1] = 2;
		bad[i + 12][2] = i;
		bad[i + 12][3] = 1;
	}
	for (int i = 0; i < 4; i++) {
		bad[i + 16][0] = 0;
		bad[i + 16][1] = i;
		bad[i + 16][2] = 2;
		bad[i + 16][3] = 1;
	}

	for (int i = 0; i < 4; i++) {
		bad[i + 20][1] = 0;
		bad[i + 20][2] = 2;
		bad[i + 20][3] = 1;
		bad[i + 20][0] = i;
	}
	for (int i = 0; i < 4; i++) {
		bad[i + 24][1] = 2;
		bad[i + 24][2] = 0;
		bad[i + 24][3] = 1;
		bad[i + 24][0] = i;
	}
	for (int i = 0; i < 4; i++) {
		bad[i + 28][1] = 0;
		bad[i + 28][2] = 1;
		bad[i + 28][3] = 2;
		bad[i + 28][0] = i;
	}

	agc[0][3][3][3][3] = 1;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				for (int l = 0; l < 4; l++) {
					for (int r = 0; r < 4; r++) {
						
						lli t = agc[i][0][j][k][l] + 
						agc[i][1][j][k][l] +
						agc[i][2][j][k][l] +
						agc[i][3][j][k][l];

						agc[i + 1][j][k][l][r] += t;
						agc[i + 1][j][k][l][r] %= mod197;
					}
				}
			}
		}

		for (int j = 0; j < 32; j++) {
			agc[i + 1][bad[j][0]][bad[j][1]][bad[j][2]][bad[j][3]] = 0;
		}
	}

	lli ans = 0;

	for (int j = 0; j < 4; j++) {
		for (int k = 0; k < 4; k++) {
			for (int l = 0; l < 4; l++) {
				for (int r = 0; r < 4; r++) {

					lli t = agc[N][j][k][l][r];

					ans += t;
					ans %= mod197;
				}
			}
		}
	}

	COUT(ans);

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <cstring>
#include <map>
#include <unordered_map>
#include <tuple>

using namespace std;

#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define umap unordered_map
#define uset unordered_set
#define cina(s, n, a) for(int quer = s; quer < n; quer++) cin >> a[quer]
#define couta(s, n, a) for(int quer = s; quer < n; quer++) cout << a[quer] << ' '
#define copy(s, n, a, b) for(int i = s; i < n; i++) b[i] = a[i]
#define yesno(ok) cout << (ok ? "YES\n" : "NO\n")
#define mod(a, b) (abs(b) + (a % abs(b))) % abs(b)
#define setp(x) fixed << setprecision(x)
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll MOD = 1e9 + 7;

void solve(){
    int n;
    cin >> n;
    cout << (n + 1) / 2;
}

int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int q = 1;
    //cin >> q;
    for (int i = 1; i <= q; i++) {
        solve();
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		double count = 0;
		for(int i=1;i<=N;i++) {
			if(i%2 == 1)count++;
		}
		
		double a = (Double)count/N;
		System.out.println(a);
		
		sc.close();	
	}
}

Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
    long long n, t, a;
    cin >> n;
 
    long long m, va = 1, vb = 1;
    for (int i=0; i<n; i++) {
        cin >> t >> a;
        m = 1LL * max(va/t + (va%t ? 1 : 0), vb/a + (vb%a ? 1 : 0));
        va = m * t;
        vb = m * a;
    }
 
    cout << va + vb << endl;

    return 0;
}


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

int main() {
  int N,a,b;
  cin >> N;
  a = N%1000;
  b = N/10;
  if (N%1111==0)
    cout << "Yes" << endl;
  else if (a % 111==0)
    cout << "Yes" << endl;
  else if (b % 111==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main(void){
    int a[5];
    rep(i, 5)
        cin >> a[i];

    int mi = 10;
    int count = 0;
    rep(i, 5){
        count += ceil(a[i] / 10.0) * 10;
        if(a[i] % 10 != 0)
            mi = min(mi, a[i] % 10);
    }

    cout << count + mi - 10 << 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;

int main() {
    int n, a, b, flag = 0;
    cin >> n;
    a = n / 100;
    b = n % 100;
    if(1 <= a && a <= 12) flag += 1;
    if(1 <= b && b <= 12) flag += 2;
    if(flag == 0) cout << "NA" << endl;
    else if(flag == 1) cout << "MMYY" << endl;
    else if(flag == 2) cout << "YYMM" << endl;
    else cout << "AMBIGUOUS" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>

using namespace std;

#define int long long

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

    int n, m;
    cin >> n >> m;
    multiset<int> hv;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        hv.insert(x);
    }
    while (m--) {
        int v = *hv.rbegin();
        hv.erase(--hv.end());
        hv.insert(v / 2);
    }
    int ans = 0;
    for (auto t : hv)  {
        ans += t;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992
// finish date: 2018/2/14

#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)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int N, K;
    cin >> N >> K;
    vi h(N);
    rep(i, N) cin >> h[i];
    vi cost(N, INF);
    cost[0] = 0;
    rep(i, N) {
        FOR(j, i + 1, min(N , i + K + 1)) {
            cost[j] = min(cost[j], cost[i] + abs(h[j] - h[i]));
        }
    }
    cout << cost[N - 1] << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <set>
#include <queue>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
ll n,m,v,pc;
ll a[100010],b[100010];

bool ok(ll pos){
	ll totv = m*(v-1);
	ll cpov = a[pos]+m;
	//cout<<pos<<' '<<cpov<<endl;
	memcpy(b,a,sizeof(a));
	ll m2 = n-1;
	for(int i=pos;i<=m2;i++)b[i] = b[i+1];
	ll cu = 0;
	vector<int> cc;
	ll cnt = 0;
	for(int i=1;i<=m2;i++){
		int cab = 0;
		if(b[i]>cpov){
			cab = m;
			cnt+=1;
		}else{
			cab = min(m,cpov-b[i]);
		}
		cu+=cab;
		cc.push_back(m-cab);
	}
	sort(cc.begin(),cc.end());
	while(cnt<pc-1){
		cu+=cc[cc.size()-1];
		cc.pop_back();
		cnt++;
	}
	if(cnt>pc-1)return false;
	if(cu>=totv)return true;
	return false;
}

int main() {
	read(n);read(m);read(v);read(pc);
	for(int i=1;i<=n;i++){
		read(a[i]);
	}
	int l = 0,r = n;
	sort(a+1,a+n+1);
	while(l+1!=r){
		int mid = (l+r+1)/2;
		if(ok(mid)){
			r = mid;
		}else{
			l = mid;
		}
	}
	cout<<n-r+1<<endl;
	return 0;
}


Measured memory_bytes: 2764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <math.h>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

int main()
{
	int n, a, b;
	cin >> n >> a >> b;

	if (a * n < b)
	{
		cout << a * n << endl;
	}
	else
	{
		cout << b << endl;
	}
}


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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

map<int, int> freq;
int n, a[200005];

int f(int x){
	int ret = 1;
	while(ret <= x){
		ret *= 2;
	}
	return ret - x;
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
		if(!freq.count(a[i])){
			freq[a[i]] = 1;
		}else{
			freq[a[i]]++;
		}
	}
	
	// observation: the largest number only has one choice
	sort(a + 1, a + n + 1);
	int ans = 0;
	for(int i = n; i >= 1; i--){
		int cur_num = a[i];
		while(freq[cur_num] > 0){
			freq[cur_num]--;
			int choose = f(cur_num);
			if(freq[choose] > 0){
				freq[choose]--;
				ans++;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 19712
import java.util.Scanner;

public class Main {
//java11
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int ABCD = sc.nextInt();

		int[] kurai = new int[4];
		for(int i=0; i<4; i++) {
			kurai[3-i] = ABCD % 10;
			ABCD /= 10;
		}

		//bit全探索
		for(int i=0; i<(1 << 3); i++) {
			String[] fugou = new String[3];
			int ans = kurai[0];
			for(int j=0; j<3; j++) {
				if((1 & (i>>j)) == 1) {
					fugou[j] = "+";
					ans += kurai[j+1];
				}else {
					fugou[j] = "-";
					ans -= kurai[j+1];
				}
			}

			if(ans == 7) {
				for(int j=0; j<3; j++) {
					System.out.print(kurai[j] + fugou[j]);
				}
				System.out.println(kurai[3] + "=" + ans);
				break;
			}
		}

	}

}


Measured memory_bytes: 25044
n = int(input())
a = list(map(int, input().split()))

if n%2 != 0:
  a.append(0)
  n += 1
 
a.sort()
d = 0

for i in range(int(n/2)):
               d += a[2*i+1]-a[2*i]
           
print(d)


Measured memory_bytes: 9184
# -*- coding: utf-8 -*-


def main():
    n, m = map(int, input().split())
    xs = sorted(list(map(int, input().split())))

    if n >= m:
        print(0)
    else:
        ans = xs[-1] - xs[0]
        diff = [0 for _ in range(m - 1)]

        for i in range(m - 1):
            diff[i] = xs[i + 1] - xs[i]

        print(ans - sum(sorted(diff, reverse=True)[:n - 1]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 13968
#include <bits/stdc++.h>
#define debug(a) cout << #a ": " << a << endl
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;
int cnt[10];
int main(void){    
    IOS;
    int x, y; cin >> x >> y;
    for (int i = 0; i <= x; ++i){
    	int two = i*2, four = (x-i)*4;
    	if (two+four == y){
    		cout << "Yes" << endl; return 0;
    	}
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)
#define REP1(i, n) for(int i=0; i<n; i++)

int INF = 10e8;
int n, m;
int dis[21][21];
int s, g, v, p;

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

    REP(i, n+1){
        REP(j, n+1){
            if(i!=0 && i==j){
                dis[i][j] = 0;
            } else {
                dis[i][j] = INF; dis[j][i] = INF;
            }
        }
    }

    REP(i, m){
        int a, b, c, d;
        scanf("%d,%d,%d,%d", &a, &b, &c, &d);
        dis[a][b] = c;
        dis[b][a] = d;
    }

    scanf("%d,%d,%d,%d", &s, &g, &v, &p);

    REP1(k, n+1){
        REP1(i, n+1){
            REP1(j, n+1){
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
            }
        }
    }

    int output = v - (p + dis[s][g] + dis[g][s]);
    cout << output << endl;
}

Measured memory_bytes: 3124
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<stdio.h>
#include<stack>
using namespace std;
string q[100001];
bool qaq(string x,string y)
{
	return x<y;
}
int main()
{
	int a,b;
	cin>>a>>b;
	for(int i=1;i<=a;i++)
		cin>>q[i];
	sort(q+1,q+a+1,qaq);
	for(int i=1;i<=a;i++)	
		cout<<q[i];
	return 0;
}


Measured memory_bytes: 1024
def main():
    n = int(input())
    As = list(map(int, input().split()))
    sumA = sum(As)
    Bs = list(map(int, input().split()))
    sumB = sum(Bs)

    if sumB > sumA:
        print(-1)
        return

    pos = []
    neg = []
    for i in range(n):
        diff = As[i] - Bs[i]

        if diff > 0:
            pos.append(diff)
        elif diff < 0:
            neg.append(diff)

    pos.sort(reverse=True)
    sum_neg = sum(neg)

    work_neg = sum_neg
    i = 0
    while work_neg < 0:
        work_neg += pos[i]
        i += 1

    ans = len(neg) + i
    print(ans)

    return

main()

Measured memory_bytes: 18356
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define vii vector<ll> 
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
const int MOD = 1e9 + 7, N = 1e4 + 3;

int main(){
    fast;
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    while(k--){
        if(b <= a) b *= 2;
        else if(c <= b) c *= 2;
    }
    if(b > a && c > b)  cout << "Yes";
    else cout << "No";
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
using namespace std;
#define forn(i,a,b) for(i=a;i<b;i++)
#define for1(i,b) for(int i=1;i<=b;i++);
#define rep(i,n) forn(i,0,n)
#define ford(i,a,b) for(i=a;i>=b;i--)
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)


map<string, int> blu;
map<string, int> red;

int main(){
    std::ios::sync_with_stdio(false);
    int N, M,i;
    cin >> N;

    string s;
   forn(i,0,N) {
	cin >> s;
	if(blu.find(s) == blu.end())
	    blu.insert(pair<string, int>(s, 1));
	
	else blu[s]++;
   }
   cin >> M;
   forn(i,0,M) {
	cin >> s; 
	if(blu.find(s) != blu.end() && blu[s] > 0) {
	    blu[s]--;
	}
   }

    int res = 0;
    for(pair<string,int> p : blu) {
	 res = max(res, p.ss);
    }

    
    cout << res << endl;
    return 0;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <vector>
#include <stack>
#include <set>
#include <bitset>
using namespace std;
typedef  long long ll;
const int maxn=1e6+50;
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int HASH=131;

int a[10][10];
int n,m,k;
int ans=0;
string s;

bool jungle(int row[],int line[])//row line 1代表涂色，0没涂色
{
    int num=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(row[i]==0&&line[j]==0&&a[i][j]==0)  num++;
        }
    }
    if(num==k)
    {
//        printf("*************************\n");
//        printf("row:");
//        for(int i=1;i<=n;i++)
//        printf(" %d",row[i]);
//        printf("\nline:");
//        for(int i=1;i<=m;i++)
//        printf(" %d",line[i]);
//        printf("\n");
        return true;
    }
    else return false;
}


int main()
{
    cin>>n>>m>>k;
    int row[10];
    int line[10];
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            char tmp;
            cin>>tmp;
            if(tmp=='.') a[i][j]=1;
            else {a[i][j]=0;}
        }
    }
    int r=1,l=1;
    for(int i=1;i<=n;i++)
        r*=2;
    for(int i=1;i<=m;i++)
        l*=2;
    for(int i=0;i<=r;i++)
    {
        bitset<6> t(i-1);
        s=t.to_string();
        for(int j=0;j<n;j++)
        {
            row[j+1]=s[6-n+j]-'0';
        }
        for(int j=0;j<=l;j++)
        {
            bitset<6> tt(j-1);
            s=tt.to_string();
            for(int k=0;k<m;k++)
            {
                line[k+1]=s[6-m+k]-'0';
            }
            if(jungle(row,line)) ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3696
#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define sqr(x) (x) * (x)
#define cube(x) (z) * (z) * (x)
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))
#define itn int

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

template <class T = int>
int in() {
  T x;
  cin >> x;
  return x;
}
string S;
int judge(int now, string temp) {
  rep(i, temp.size()) {
    if (temp[i] != S[now + i]) {
      return 0;
    }
  }
  now += temp.size();
  if (now == S.size()) {
    return 1;
  } else {
    return max(judge(now, "dream"), max(judge(now, "dreamer"), max(judge(now, "erase"), judge(now, "eraser"))));
  }
}

signed main() {
  cin >> S;
  int now = 0;
  if (max(judge(now, "dream"), max(judge(now, "dreamer"), max(judge(now, "erase"), judge(now, "eraser"))))) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
signed main() {
	int N;
	cin >> N;
	int a, b;
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> a >> b;
		res += b - a + 1;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
def make_divisors(n):
    divisors = []
    # 試し割りで、かつ積でnを作るときの相方も同時に追加してる
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
divisors = make_divisors(n)
ans = 0
for div in divisors:
    if div != 1:
        q,r = divmod(n,div-1)
        if q == r:
            ans += div-1
print(ans)



Measured memory_bytes: 9628
#include<bits/stdc++.h>
using namespace std;
#define lld long long int
int main(){
    int a[]={105,135,165,189,195};
    lld n,i,c=0;
    cin>>n;
    for(i=0;i<5;i++){
        if(a[i]<=n){
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
/*
* @Author: _dp95
* @Date:   2020-04-03 05:39:41
*/
#include "bits/stdc++.h"
using namespace std ;

#define timesaver ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll ;
typedef long double ldb ;

#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'

#define all( x ) x.begin(),x.end() 
#define sz( x ) ( int )( x ).size( )
#define mem( a, val ) memset(a, val, sizeof( a ) )
#define deci( x ) cout<<fixed<<setprecision( x );
#define bitcount( x ) __builtin_popcountll( x )

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

const int MAX = 2*1000*1000 + 10 ;
const ll INF = 1e18 ;
const int MOD = 1e9 + 7 ;

signed main( ){
  timesaver ;
  ll x ;
  cin >> x; 
  ll ans = 1000*(x/500);
  x %= 500 ;
  ans += 5*(x/5) ;
  cout << ans << nl ;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
typedef long long ll;
using namespace std;

int main(){
    string S;
    cin >> S;
    int a, b, c, d;
    a = S.at(0) - '0';
    b = S.at(1) - '0';
    c = S.at(2) - '0';
    d = S.at(3) - '0';
    char op1, op2, op3;
    rep(i,2){
        if(i) op1 = '+';
        else op1 = '-';
        rep(j,2){
            if(j) op2 = '+';
            else op2 = '-';
            rep(k,2){
                if(k) op3 = '+';
                else op3 = '-';
                if(a + (2 * i - 1) * b + (2 * j - 1) * c + (2 * k - 1) * d == 7){
                    cout << a << op1 << b << op2 << c << op3 << d << "=7" << endl;;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

int main() {
  ll n, ww;
  cin >> n >> ww;
  vll w(n), v(n);
  for (ll i = 0; i < n; i++) cin >> w[i] >> v[i];
  vll dp(100001, 0);
  vector<vll> check(100001, vll(n, 0));
  for (ll i = 1; i <= ww; i++) {
    dp[i] = dp[i - 1];
    ll memo = -1;
    for (ll j = 0; j < n; j++) {
      if (i < w[j]) continue;
      if (check[i - w[j]][j] == 1) continue;
      if (dp[i] < dp[i - w[j]] + v[j]) {
        dp[i] = dp[i - w[j]] + v[j];
        memo = j;
      }
    }
    if (memo != -1) {
      check[i] = check[i - w[memo]];
      check[i][memo] = 1;
    }
    else check[i] = check[i - 1];
  }
  cout << dp[ww] << endl;
}

Measured memory_bytes: 83072
def main():
    N = int(input())
    #print(N)
    p = []
    isFound = False
    for _ in range(N):
        x, y, h = map(int, input().split())
        p.append([x, y, h])
        if not isFound and h > 0:
            ref = [x, y, h]
            isFound = True
    #print(p)

    for cx in range(0, 100+1):
        for cy in range(0, 100+1):
            isCenter = True
            H = ref[2] + abs(ref[0]-cx) + abs(ref[1]-cy)
            for x, y, h in p:
                if h > 0:
                    Hp = h + abs(x-cx) + abs(y-cy)
                    if Hp != H:
                        isCenter = False
                        break
                else:
                    if (H - abs(x-cx) - abs(y-cy)) > 0:
                        isCenter = False
                        break
            if isCenter:
                return [cx, cy, H]
    return [-1,-1,-1]

if __name__ == '__main__':
    output = main()
    print(' '.join(map(str, output)))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
typedef pair<int,int>P;
const int TIMES = 5;
int main(){
  int day;
  int cost[30];
  int satisfied[370][30];
  int i,j;
  priority_queue<P>pq_s[370];
  
  long long score=1000000;
  long long cost_sum=0;
  long long sub=0;
  int last[370]={0};
  
  //scanf("%d",&day);
  cin>>day;
  
  for(i=1;i<=26;i++){
    //scanf("%d ",&cost[i]);
    cin>>cost[i];
    cost_sum+=cost[i];
  }
  
  for(i=1;i<=day;i++){
    for(j=1;j<=26;j++){
      //scanf("%d ",&satisfied[i][j]);
      cin>>satisfied[i][j];
      pq_s[i].push(P(satisfied[i][j],j));
    }
  }
  
  //  int array[]={0,1,17,13,14,13};
  for(i=0;i<TIMES;i++){
    
  }
  for(i=1;i<=day;i++){
    //    int contest=(i+25)%26+1;
    int contest=pq_s[i].top().second;
    printf("%d\n",contest);
    score+=satisfied[i][contest];
    sub+=cost_sum-(i-last[contest])*cost[contest];
    score-=sub;
    last[contest]=i;
  }
  //printf("%lld\n",score);
  return(0);
}

Measured memory_bytes: 3872
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

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

Measured memory_bytes: 256
import math
from itertools import permutations
import numpy as np

N = int(input())
c = list()
for n in range(N):
  x, y = list(map(int, input().split()))
  c.append((x, y))

def length(c1, c2):
  return math.sqrt((c1[0]-c2[0])**2 + (c1[1]-c2[1])**2)
 
A = list()
for i in list(permutations(range(len(c)))):
  L = 0
  for j in range(len(i)-1):
    L += length(c[i[j]], c[i[j+1]])
  A.append(L)
  
print(np.mean(A))

Measured memory_bytes: 27288
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>

using namespace std;


int main()
{
    int a[100];
    int n,i;
    cin>>n;
    for(i=0;i<n;++i)
        cin>>a[i];
    sort(a,a+n);
    int cnt=1;
    for(i=0;i<n-1;++i)
    {
        if(a[i]!=a[i+1])
            cnt++;
    }
    cout<<cnt<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second
#define _GLIBCXX_DEBUG

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S>
void print(vector<S> &v){
	for(ll i=0; i<(ll)v.size(); i++){
		cerr << v[i] << ' ';
	}
	cerr << endl;
}
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}


int main(){
	int n,m; cin >> n >> m;
	vector<vector<int>> adj(n);
	Rep(m){
		int a,b;
		cin >> a >> b;
		adj[--a].push_back(--b);
		adj[b].push_back(a);
	}
	queue<int> q;
	vector<int> ans(n,-1);
	int able = 1;
	q.push(0);
	while(!q.empty()){
		int a=q.front();
		q.pop();
		for(int ad: adj[a]){
			if(ans[ad] == -1){
				ans[ad]=a;
				q.push(ad);
				able++;
			}
		}
	}
	
		cout << "Yes\n";
		for(int i=1; i<n; i++){
			cout << ans[i]+1 << endl;
		}
	
}


Measured memory_bytes: 10176
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main( ) {
    //freopen("A.01.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x,y;
    cin >> x >> y;
    cout << x+y/2 << endl;
    return 0;
}

Measured memory_bytes: 3608
s=list(input())
sw=False
for i in range(len(s)):
  if i%2==0:
    if not(s[i]=="R" or s[i]=="U" or s[i]=="D"):
      sw=True
  elif i%2==1:
    if not(s[i]=="L" or s[i]=="U" or s[i]=="D"):
      sw=True

if sw:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 3060