akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define md (ll)(1e9+7)

const int M=1e6+6;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}
ll n,i,dp[M],h[M],k,j;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	cin >> n >> k;
	for(i=1;i<=n;++i)
	{
		cin >> h[i];
		if(i>1)
			dp[i] = 1e18;
		for(j=1;j<=k && i-j >= 1;++j)
		{
			dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
		}
	}
	cout << dp[n] << endl;
	return 0;
}

	


Measured memory_bytes: 5120
// #pragma GCC optimize("Ofast,unroll-loops")
// #pragma GCC target("avx,avx2,fma")

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

#define ll long long
#define ull unsigned long long
#define dd double
#define ld long double
#define sl(n) scanf("%lld", &n)
#define si(n) scanf("%d", &n)
#define sd(n) scanf("%lf", &n)
#define pll pair <ll, ll>
#define pii pair <int, int>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()
#define inf (1LL << 62)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define for1(i, stop) for(ll i = 1; i <= stop; ++i)
#define for0(i, stop) for(ll i = 0; i < stop; ++i)
#define rep1(i, start) for(ll i = start; i >= 1; --i)
#define rep0(i, start) for(ll i = (start-1); i >= 0; --i)
#define ms(n, i) memset(n, i, sizeof(n))
#define casep(n) printf("Case %lld:", ++n)
#define pn printf("\n")
#define pf printf
#define EL '\n'
#define fastio std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

char grid[10][10];
ll h, w, k, ans;

void solve(ll r, ll c, ll msk1, ll msk2)
{
    if(r == 0 && c == 0) {
        ll b = 0;
        for1(i, h) {
            for1(j, w) {
                bool br = (msk1 >> (i-1)) & 1;
                bool bc = (msk2 >> (j-1)) & 1;

                if(br == 1 || bc == 1)
                    continue;

                if(grid[i][j] == '#') b++;
            }
        }
        if(b == k) ans++;
        return;
    }

    if(r == 0) {
        ll lim = 1 << w;
        for0(i, lim)
            solve(0, 0, msk1, i);
    }
    else {
        ll lim = 1 << h;
        for0(i, lim)
            solve(0, 1, i, msk2);
    }
}

int main()
{
    cin >> h >> w >> k;

    for1(i, h)
        scanf("%s", grid[i]+1);

    solve(1, 0, 0, 0);
    cout << ans << EL;

    return 0;
}


Measured memory_bytes: 3728
#include <stdio.h>

int main(void)
{
	char a,S,H,C,D;
	int i,j,k,n,s[13],h[13],c[13],d[13];
	scanf("%d",&n);
	for(i=0;i<=12;i++)
	{
		s[i]=0;
		h[i]=0;
		c[i]=0;
		d[i]=0;
	}
	for(j=0;j<=2*n-1;j++)
	{
		scanf("%c",&a);
		if(a=='S')
		{
			scanf("%d",&i);
			s[i-1] = 1;
		}
		else if(a=='H')
		{
			scanf("%d",&i);
			h[i-1] = 1;
		}
		else if(a=='C')
		{
			scanf("%d",&i);
			c[i-1] = 1;
		}
		else if(a=='D')
		{
			scanf("%d",&i);
			d[i-1] = 1;
		}
	}
	for(i=0;i<13;i++)
	{
		if(s[i]==0)
		{
			k = i+1;
			printf("S %d\n",k);
		}
	}
	for(i=0;i<13;i++)
	{
		if(h[i]==0)
		{
			k = i+1;
			printf("H %d\n",k);
		}
	}
	for(i=0;i<13;i++)
	{
		if(c[i]==0)
		{
			k = i+1;
			printf("C %d\n",k);
		}
	}
	for(i=0;i<13;i++)
	{
		if(d[i]==0)
		{
			k = i+1;
			printf("D %d\n",k);
		}
	}
	return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        Integer[] d = new Integer[n];
        for(int i=0; i<n; i++) {
            d[i] = sc.nextInt();
        }

        Set<Integer> setD = new TreeSet<>(Arrays.asList(d));

        System.out.println(setD.size());
        sc.close();
    }
}


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

using namespace std;

int main(){
    int n;
    while(cin>>n,n){
        bool pre=1,l=0,r=0;
        int ans=0;
        for(int i=0;i<n;++i){
            string s;cin>>s;
            if(s[0]=='l'){
                if(l)l=0;
                else l=1;
            }
            else{
                if(r)r=0;
                else r=1;
            }
            if((pre==r) && (pre==l)){
                ++ans;
                if(pre)pre=0;
                else pre=1;
            }
        }
        cout<<ans<<endl;
    }
}

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

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

    vector<int> L(n);
    for(int i=0; i<n; i++) cin >> L[i];

    sort(L.begin(), L.end());
    int max_L = L[n-1];
    int total_L = 0;

    for(int i=0; i<n-1; i++ ) total_L += L[i];

    if(total_L > max_L) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main() {
    int a, b, c, d, e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if (e - a > k) cout << ":(" << endl;
    else cout << "Yay!" << endl;

}

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

int N, M;
const int MAX_NM = 1000 + 10;
ll x[MAX_NM], y[MAX_NM], z[MAX_NM];

int main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i] >> z[i];

    ll ans = -1.0e9;
    for (int bit = 0; bit < 8; bit++) {
        vector<ll> res;

        for (int i = 0; i < N; i++) {
            ll a = x[i] * (bit & 1 ? 1 : -1);
            ll b = y[i] * (bit & 2 ? 1 : -1);
            ll c = z[i] * (bit & 4 ? 1 : -1);
            res.push_back(a+b+c);
        }

        sort(begin(res), end(res), greater<ll>());
        ll now = 0;
        for (int i = 0; i < M; i++) now += res[i];
        ans = max(ans, now);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <queue>
using namespace std;
struct line{
    int e;
    int lim;
};
line make_line(int a,int b){
    line temp;
    temp.e=a;
    temp.lim=b;
    return temp;
}
struct cmp{
    bool operator()(const line &a,const line &b){
        return a.lim>b.lim;
    }
};
int main(){
    int n,t[1000],v[1000],s=0;
    double ans=0;
    priority_queue<line,vector<line>,cmp>pq;
    queue<line>q;
    scanf("%d",&n);
    t[0]=v[0]=0;
    for(int i=1;i<=n;i++){
        scanf("%d",&t[i]);
        t[i]+=t[i-1];
    }
    for(int i=1;i<=n;i++){
        scanf("%d",&v[i]);
        q.push(make_line(t[i],v[i]));
    }
    v[n+1]=0;
    pq.push(make_line(1000000,1000000));
    q.push(make_line(1000000,0));
    for(int i=1;i<=n;i++)pq.push(make_line(t[i],v[i+1]+t[i]));
    for(int i=0;i<t[n];i++){
        while(pq.top().e<=i)pq.pop();
        while(q.front().e<=i)q.pop();
        if(s+1<=q.front().lim&&s+i+2<=pq.top().lim){
            s++;
            ans+=(s+s-1)*5;
        }
        else if(s+1<=q.front().lim&&s+i+1<=pq.top().lim){
            ans+=s*10+2.5;
        }
        else if(s<=q.front().lim&&s+i+1<=pq.top().lim){
            ans+=s*10;
        }
        else{
            s--;
            ans+=(s+s+1)*5;
        }
    }
    printf("%lf\n",ans/10);
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

counter = 0
for i in range(0,a+1):
    for j in range(0,b+1):
        for k in range(0,c+1):
            if (500 * i + 100 * j + 50 * k) == x:
                counter += 1
print(counter)


Measured memory_bytes: 3060
#include<stdio.h>

int main()
{
  int a, b, h;
  int ans;

  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&h);

  if(a<1 || a>100){
    return 1;
  }

  if(b<1 || b>100){
    return 1;
  }

  if(h<1 || h>100 || h%2!=0){
    return 1;
  }

  ans = (a+b)*h/2;

  printf("%d\n",ans);

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<cstring>
#include<algorithm>
#define cdebug() freopen("C:\\Users\\netmaster.ASUS\\Desktop\\123.txt","r",stdin)
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rev(i,a,b) for(int i=(a);i>=(b);i--)
#define clr(a,x) memset(a,x,sizeof a)
#define inf 0x3f3f3f3f
typedef long long LL;
using namespace std;

const int mod=1e9 +7;
const int maxn=2005;
const int maxm=4005;

int done[8][8][8][8][8][8][8];
struct node
{
    int d[8],w,dir;
    node()
    {

    }
    node(int dd[],int di,int ww)
    {
        rep(i,0,8)
        d[i]=dd[i];
        dir=di;
        w=ww;
    }
};
inline int& gbool(int dd[])
{
    return done[dd[0]][dd[1]][dd[2]][dd[3]][dd[4]][dd[5]][dd[6]];
}
int dx[][3]={1,4,-1,0,2,5,1,3,6,2,7,-1,0,5,-1,1,4,6,2,5,7,3,6,-1};
void bfs()
{
    int dd[8];
    queue<node>q;
    clr(done,0);
    rep(i,0,8)
    dd[i]=i;
    q.push(node(dd,0,0));
    gbool(dd)=1;
    while(!q.empty())
    {
        node x=q.front();q.pop();
        rep(i,0,3)
        if(dx[x.dir][i]!=-1)
        {
            node cur=x;
            swap(cur.d[x.dir],cur.d[dx[x.dir][i]]);
            cur.dir=dx[x.dir][i];
            cur.w++;
            if(!gbool(cur.d))
            {
                gbool(cur.d)=x.w+1;
                q.push(cur);
            }
        }
    }
}
int da[8];
int main()
{bfs();
    while(~scanf("%d",&da[0]))
    {
        int sum=0;
        rep(i,1,8)
        scanf("%d",&da[i]),sum+=abs(i-da[i]);

        if(!sum)
        {
            puts("0");
            continue;
        }
        printf("%d\n",gbool(da));
    }
    return 0;
}

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

int main(void)
{
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin >> A.at(i);
    }
    vector<int> d(N, 0);
    ll count = 0ll;
    for(int i=0;i<N;i++){
        if(A[i] >= N) continue;
        int ind = i - A[i];
        if(0<=ind && ind <N) count += ll(d[ind]);
        
        int ind2 = A[i] + i;
        if(0<=ind2 && ind2 < N) d[ind2]++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 4844
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

signed main(){
	int N;
	cin >> N;
	vector<int> a(N);
	for(int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	int cnt = 0;
	for(int i = 1; i < N; ++i) {
		if(a[i-1] == a[i]) {
			a[i] = 10000000;
			++cnt;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 768
#define _GLIBCXX_DEBUG
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
void solve(){
    int n;
    cin >> n;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++) if(i*j == n){
            cout << "Yes";
            return;
        }
    }
    cout << "No";
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    while(t--) solve();
}

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

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

typedef long long ll;
typedef pair<int, int> P;

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  int l, r, d;
  cin >> l >> r >> d;

  int l1 = (l-1)/d*d;
  int r1 = r/d*d;
  cout << (r1-l1)/d << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>

int main(void){
   int N,M;
   int n,m;
   int sum;
   scanf("%d %d",&N,&M);
   n=N*(N-1)/2;
   m=M*(M-1)/2;
   sum=n+m;
   printf("%d",sum);
   return 0;
}
   


Measured memory_bytes: 1736
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[10101][110];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll n;
	cin >> n;
	ll ans = INF;
	for (ll i = 1;i <= sqrt(n);++i) {
		ll amari = n % i;
		if (amari == 0) {
			ll j = n / i;
			ll k = i;
			ll res = 0, res2 = 0;
			while (k>0) {
				k /= 10;
				res++;
			}
			while (j > 0) {
				j /= 10;
				res2++;
			}
			res = max(res, res2);
			ans = min(ans, res);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3680
#include<iostream>
#include<vector>

using namespace std;

int main()
{
	int n;
	int i;
	vector<char> prime;
	
	for(i=0;i<10000000;i++)
	{
		prime.push_back('1');
	}
	
	prime[0]=prime[1]='0';
	
	for(i=0;i<10000000;i++)
	{
		if(prime[i]=='1')
		{
			for(int j=2;j*i<10000000;j++)
			{
				prime[j*i]='0';
			}
		}
	}
	for(i=0;i<10000000;i++)
	{
		if(i+8<10000000)
		{
			if((prime[i]=='1' || prime[i]=='2') && (prime[i+2]=='1' || prime[i+2]=='2') && (prime[i+6]=='1' || prime[i+6]=='2') && (prime[i+8]=='1' || prime[i+8]=='2'))
			{
				prime[i+8]='2';
			}
		}
	}
	
	for(;;)
	{
		cin >> n ;
		if(n==0)
			break;
		
		for(;prime[n]!='2';--n)
		{
		}
		cout << n << endl;
	}
}

Measured memory_bytes: 10000
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N, M;

int main()
{
    int A, B;
    cin >> A >> B;
    cout << max({A + B, A - B, A * B});
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(input[0], 10);
	var b = parseInt(input[1], 10);
	var c = parseInt(input[2], 10);
  
    var count = parseInt(0, 10); 
	//出力
  if(a === 1){count++}
  if(b === 1){count++}
  if(c === 1){count++}
	console.log(count);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

int main(){
    int A,B;
    cin>>A>>B;

    cout<<(A > B ? A + max(A-1,B) : B + max(A, B - 1))<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	ll n,ans=0;
	cin>>n;
	vector<ll> a(n);
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(a[j]==a[i])
			continue;
			for(int k=j+1;k<n;k++){
				if(a[k]==a[i]||a[j]==a[k])
				continue;
				if((a[k]<(a[i]+a[j]))&&(a[i]<(a[k]+a[j]))&&(a[j]<(a[i]+a[k])))
				ans++;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int x;
	cin >> x;

	Int ans, a, b;
	a = x / 11;
	b = x % 11;

	ans = 2 * a;
	if (0 < b && b <= 6)ans++;
	else if (b > 6)ans += 2;

	cout << ans << endl;




}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll N;
ll a[10000];
ll ans = 0;

void act(ll x){
    if(x%2 == 0){
        ll b = x/2;
        ans++;
        act(b);
    }
}

int main(void) {
    // insert code here...
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    
    for(int i = 0; i < N; i++){
        act(a[i]);
    }
    
    
    cout << ans << endl;
    
    return 0;
}


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

long long n,m,A[100001],ans=0;
map<long long, long long> M;

int main(){
	cin>>n>>m;
	A[0]=0;
	M[0]++;
	for(int i=1;i<=n;i++){
		cin>>A[i];
		A[i]+=A[i-1];
		M[A[i]%m]++;
	}
	for(pair<long long, long long> cnt : M){
		ans+=cnt.second*(cnt.second-(long long)1)/(long long)2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  int n = s.length();
  int m = t.length();
  if(m!=n+1){cout << "No"<<endl;return 0;}
  for(int i = 0;i<n;i++){
    if(s[i]!=t[i]){cout <<"No"<<endl;return 0;}
  }
  cout <<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int K;
vector<long long> A;


bool C(long long x, bool t) {
    long long ret = x;
    for(int i=0; i<K; ++i) {
        ret -= ret % A[i];
    }
    if(t) return ret > 2;
    else return ret >= 2;
}

int main() {
    cin >> K;
    A.resize(K);
    for(int i=0; i<K; ++i) cin >> A[i];

    long long l = 1;
    long long r = 1LL << 50;
    while(r - l > 1) {
        long long m = (l + r) / 2;
        if(C(m, false)) r = m;
        else l = m;
    }
    long long N0 = r;

    l = 1;
    r = 1LL << 50;
    while(r - l > 1) {
        long long m = (l + r) / 2;
        if(C(m, true)) r = m;
        else l = m;
    }
    long long N1 = r;

    if(N1 > N0) cout << N0 << ' ' << N1 - 1 << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
//const ll MOD=(ll)998244353;
const ll INF=(ll)1e18+10;
const double PI = 2.0*acos(0);
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; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

int bcnt[2010][2010],wcnt[2010][2010];
int bruiseki[2010][2010],wruiseki[2010][2010];

void solve(int ca){
    int N,K;cin>>N>>K;
    int x,y; char c;
    int white=0;
    for (int i = 0; i < N; ++i) {
        cin>>x>>y>>c;
        if(c=='B') bcnt[x%(2*K)][y%(2*K)]++;
        else {
            wcnt[x % (2 * K)][y % (2 * K)]++;
            white++;
        }
    }

    for (int i = 0; i < 2 * K; ++i) {
        for (int j = 0; j < 2 * K; ++j) {
            bruiseki[i+1][j+1]=bcnt[i][j]+bruiseki[i+1][j]+bruiseki[i][j+1]-bruiseki[i][j];
            wruiseki[i+1][j+1]=wcnt[i][j]+wruiseki[i+1][j]+wruiseki[i][j+1]-wruiseki[i][j];
        }
    }

    int ans=0;
    for (int i = 0; i < K; ++i) {
        for (int j = 0; j < K; ++j) {
            int btmp=0,wtmp=0;
            //black

            btmp+=bruiseki[i+K][j+K]-bruiseki[i][j+K]-bruiseki[i+K][j]+bruiseki[i][j];
            btmp+=bruiseki[2*K][2*K]-bruiseki[i+K][2*K]-bruiseki[2*K][j+K]+bruiseki[i+K][j+K];
            btmp+=bruiseki[i][j];
            btmp+=bruiseki[i][2*K]-bruiseki[i][K+j];
            btmp+=bruiseki[2*K][j]-bruiseki[K+i][j];
            //white
            wtmp+=wruiseki[i+K][j+K]-wruiseki[i][j+K]-wruiseki[i+K][j]+wruiseki[i][j];
            wtmp+=wruiseki[2*K][2*K]-wruiseki[i+K][2*K]-wruiseki[2*K][j+K]+wruiseki[i+K][j+K];
            wtmp+=wruiseki[i][j];
            wtmp+=wruiseki[i][2*K]-wruiseki[i][K+j];
            wtmp+=wruiseki[2*K][j]-wruiseki[K+i][j];

            ans=max(ans,max(btmp+white-wtmp,wtmp+N-white-btmp));
        }
    }

    cout<<ans<<endl;


}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(0);
#endif
    return 0;
}


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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    list<char> l;
    for(auto is:s) {
        if(is=='B'&&!l.empty()) l.pop_back();
        else if(is=='B'&&l.empty()) continue;
        else l.push_back(is);
    }

    for(auto il:l) cout << il;
    cout << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    ll acCount=0;
    ll waCount=0;
    ll tleCount=0;
    ll reCount = 0;
    while(t--){
        string s;
        cin>>s;
        if(s=="AC") acCount++;
        if(s=="WA") waCount++;
        if(s=="TLE") tleCount++;
        if(s=="RE") reCount++;
    }
    cout<<"AC x "<<acCount<<"\n";
    cout<<"WA x "<<waCount<<"\n";
    cout<<"TLE x "<<tleCount<<"\n";
    cout<<"RE x "<<reCount<<"\n";

    return 0;
}

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

using namespace std;

const int MAX = 2147483647;


int tree[131072 * 4];

int query(int x, int y, int k, int l, int r) {
	if (y <= l || x >= r) {
		return INT_MAX;
	}
	if (x <= l && r <= y) {
		return tree[k];
	}
	else {
		int vl = query(x, y, k * 2 + 1, l, (l + r) / 2);
		int vr = query(x, y, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}

}

int main()
{
	int n, q, N = 1;
	cin >> n >> q;
	for (int i = 0; i < 100000 * 4; i++) {
		tree[i] = MAX;
	}
	while (N < n)
	{
		N *= 2;
	}


	for (int i = 0; i < q; i++) {
		int com, x, y;
		cin >> com >> x >> y;

		if (com == 0) {
			int index = N + x - 1;
			tree[index] = y;
			while (index > 0)
			{
				index = (index - 1) / 2;
				tree[index] = min(tree[index * 2 + 1], tree[index * 2 + 2]);
			}
		}
		else {
			cout << query(x, y + 1, 0, 0, N) << '\n';
		}

	}



	return 0;
}

Measured memory_bytes: 4660
# Problem B - Five Dishes

import itertools
import math

# input process
cost_list = []
for i in range(5):
    cost_list.append(int(input()))

# initialization
min_ans = 1000

# count process
perm_list = list(itertools.permutations(cost_list))
for p in perm_list:
    p = list(p)
    # cost calc
    tmp = 0
    for i in range(len(p)):
        if i==4:
            tmp += p[i]
            break
        tmp += p[i]
        tmp = math.ceil((tmp/10))*10

    min_ans = min(min_ans, tmp)

# output process
print(min_ans)


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <complex>
#include <cstdio>
#include <utility>
#include <vector>
#include <cassert>
using namespace std;
typedef complex<long double> P;
typedef pair<P,P> L;
typedef pair<P,double> C;
typedef vector<P> Poly;
#define X real()
#define Y imag()
#define EPS (1e-10)
#define INF (1e15)

//2D version
namespace std{
  bool operator < (const P& a, const P& b){
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
  bool operator == (const P& a, const P& b){
    return abs(a-b) < EPS;
  }
}

P n_vector(P a){
  //aベクトルに垂直な単位ベクトル
  long double l = abs(a);
  return (long double)1000.0*a*P(0.0,1.0)/l;
}

int main(){
  int N;
  cin >> N;
  vector<P> V(N);
  long double x, y;
  for(int i = 0; i < N; ++i){
    cin >> x >> y;
    V[i] = P(x,y);
  }
  vector< vector<long double> > A(N);
  long double pi = acos(-1.0);
  for(int i = 0; i < N; ++i){
    for(int j = 0; j < N; ++j){
      if(i == j) continue;
      long double theta = arg(n_vector((long double)100.0*(V[j]-V[i])));
      //if(theta < 0) theta += 2*pi;
      A[i].push_back(theta);
    }
  }
  for(int i = 0; i < N; ++i){
    long double m = A[i][0], M = A[i][0] + pi;
    for(int j = 0; j < A[i].size(); ++j){
      long double m_ = A[i][j], M_ = A[i][j] + pi;
      if(M_ > pi && M_ - 2*pi > m){
        M_ -= 2*pi;
        m_ -= 2*pi;
      }if(m_ + 2*pi < M){
        m_ += 2*pi;
        M_ += 2*pi;
      }
      m = max(m,m_);
      M = min(M,M_);
    }
    printf("%.20Lf\n",max((long double)0.0,(M-m)/pi/2.0));
  }

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>

using namespace std;
namespace mp = boost::multiprecision;

const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.14159265;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); ++i)
#define RFOR(i,n,r) for(ll i = (ll)(n-1); i >= r; --i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n,0)
#define ALL(x) x.begin(),x.end()
#define CALL(x) x.cbegin(),x.cend()
#define RALL(x) x.rbegin(),x.rend()
#define CRALL(x) x.crbegin(),x.crend()

#define cout cout << setprecision(12)

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using vp = vector<pair<ll, ll>>;
using vs = vector<string>;
using vc = vector<char>;
using lst = list<ll>;
using pq = priority_queue<ll>;

template < typename T >
inline void dbg(T a) { cout << a << ' '; }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main() {
    cin >> n >> m >> k;
	mp::cpp_dec_float_100 d = mp::sqrt(static_cast<mp::cpp_dec_float_100>(n));
	mp::cpp_dec_float_100 e = mp::sqrt(static_cast<mp::cpp_dec_float_100>(m));
	mp::cpp_dec_float_100 f = mp::sqrt(static_cast<mp::cpp_dec_float_100>(k));
	//dbg(d); dbg(e); dbg(f);
    cout << ((d+e<f) ? "Yes" : "No") << endl;
}


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

typedef struct Node
{
	int key;
	Node *parent, *left, *right;
}Node;

Node *root, *NIL;

void insert(int key)
{
	Node *y = NIL;
	Node *x = root;
	Node *z;
	z = (Node *)malloc(sizeof(Node));
	z->key = key, z->left = NIL, z->right = NIL;

	while (x != NIL)
	{
		y = x;
		if (z->key < x->key)
			x = x->left;
		else
			x = x->right;
	}
	z->parent = y;

	if (y == NIL)
		root = z;
	else if (z->key < y->key)
		y->left = z;
	else
		y->right = z;
}

void inOrder(Node *node)
{
	if (node == NIL) return;
	inOrder(node->left);
	cout << " " << node->key;
	inOrder(node->right);
}

void preOrder(Node *node)
{
	if (node == NIL) return;
	cout << " " << node->key;
	preOrder(node->left);
	preOrder(node->right);
}

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		string order;
		cin >> order;
		if (order == "insert")
		{
			int key;
			cin >> key;
			insert(key);
		}
		else if (order == "print")
		{
			inOrder(root);
			cout << endl;
			preOrder(root);
			cout << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 26452
import math

n = int(input())
mp = [[0 for _ in range(10)] for _ in range(10)]

for i in range(1, n + 1):
    mp[int(str(i)[0])][int(str(i)[-1])] += 1

sm = 0
for i in range(10):
    for j in range(10):
        sm += mp[i][j] * mp[j][i]

print(sm)

# c = 0
# for i in range(1, n):
#     for j in range(1, n):
#         si, sj = str(i), str(j)
#         if si[0] == sj[-1] and si[-1] == sj[0]:
#             c += 1


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,t,a;
    cin>>n>>t>>a;
    ll h[n+1];
    rep(i,1,n+1)
    cin>>h[i];
    double dif=M;
    ll ans=0;
    rep(i,1,n+1)
    {
    	double tp=t-(double)h[i]*0.006;
    	if(abs(tp-a)<dif)
    	{
    		dif=abs(tp-a);
    		ans=i;
    	}
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

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

Measured memory_bytes: 1216
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N;
        cin >> N;
        vector<vector<int>> a(N, vector<int>(N));
        rep(i, 0, N)rep(j, 0, N)cin >> a[i][j];

        vector<vector<ll>> dp(N, vector<ll>(1 << N));

        //男性0の組み合わせ
        for (int j = 0; j < N; ++j) {
            if (a[0][j]) {
                dp[0][1 << j] = 1;
            }
        }
        //男性1~N-1
        for (int i = 0; i + 1 < N; ++i) {
            for (int bit = 0; bit < 1 << N; ++bit) {
                int cnt = 0;
                for (int j = 0; j < N; ++j) {
                    if (bit >> j & 1) cnt++;
                }

                if (i + 1 != cnt) continue;


                for (int j = 0; j < N; ++j) {
                    if (!(bit >> j & 1) && a[i + 1][j]) {
                        (dp[i + 1][bit | (1 << j)] += dp[i][bit]) %= MOD;
                    }
                }
            }
        }

        ll ans = dp[N - 1][(1 << N) - 1];
        cout << ans << endl;
    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 360832
import math

s = input().split()

a = int(s[0])
b = int(s[1])
c = int(s[2])

if a + b >= c :
  print('No')
else:
  if 4*a*b < ( c - a - b ) ** 2 :
    print('Yes')
  else:
    print('No')


Measured memory_bytes: 2940
N,M,X=map(int,input().split())
C=[[*map(int,input().split())] for _ in range(N)]

ans=inf=float('inf')
for perm in range(1,1<<N):
    tt,lvls=0,[0]*M
    for i in range(N):
        if perm&(1<<i)==0:
            continue
        tt+=C[i][0]
        for j in range(M):
            lvls[j]+=C[i][j+1]
        for j in range(M):
            if lvls[j]<X:
                break
        else:
            ans=min(ans,tt)
            break

print(ans if ans<inf else -1)


Measured memory_bytes: 74308
#include <bits/stdc++.h>
using namespace std;
#define min(a, b) ((a<b)?a:b)
#define max(a, b) ((a<b)?b:a)
#define pb push_back
#define endl "\n"
typedef long long ll;

#define max_element mmmmm
#define min_element nnnnn

#define int long long

template<class T>
class BIT {
	public:
		int BIT_size;
		vector<T> BIT_array;
		BIT(int BIT_size) {
			this->BIT_size = BIT_size;
			BIT_array = vector<T>(BIT_size+1);
			fill(BIT_array.begin(), BIT_array.end(), 0);
		}
		void BIT_update(int i, T d) {
			for(; i<=BIT_size; i+=(i&-i)) {
				BIT_array[i] += d;
			}
		}
		T BIT_sum(int i) {
			T BIT_sum_result = 0;
			for(; i>0; i-=(i&-i)) {
				BIT_sum_result += BIT_array[i];
			}
			return BIT_sum_result;
		}				
};

ll pow(ll a, ll b, ll m) {
	a %= m;
	ll result = 1;
	while(b > 0) {
		if(b & 1) {
			result = result*a%m;
		}
		a = a*a%m;
		b /= 2;		
	}
	return result;
}

signed main() {
	int n; cin >> n;
	vector<int> values;
	set<int> no_repeat;
	map<int, vector<int>> m;
	for(int i=0; i<n; i++) {
		int x; cin >> x;
		m[x].push_back(i);
		values.push_back(x);
		no_repeat.insert(x);
	}
	sort(values.begin(), values.end());
	reverse(values.begin(), values.end());
	int pos[n];
	for(int i=0; i<n; i++) {
		pos[i] = m[values[i]][0];
		m[values[i]].erase(m[values[i]].begin());
	}
	int dp[n+1][n+1];
	for(int i=0; i<=n; i++) {
		for(int j=0; j<=n; j++) dp[i][j] = 0;
	}
	for(int len = 1; len <= n; len++) {
		for(int i=0; i<=len; i++) {
			int j = len - i;
			//cout << "ij " << i << " " << j << endl;
			if(i > 0) {
				dp[i][j] = max(dp[i][j], 
				dp[i-1][j]+abs(pos[i+j-1]+1-i)*values[i+j-1]);
				//cout << "A " << pos[i+j-1]+1-i << " " <<
				//values[i+j-1] << endl;
			}
			if(j > 0) {
				dp[i][j] = max(dp[i][j],
				dp[i][j-1]+abs(pos[i+j-1]-(n-j))*values[i+j-1]);
				//cout << "B " << pos[i+j-1]+1-j << " " << 
				//values[i+j-1] << endl;
				
			}
			//cout << dp[i][j] << endl;
		}
	}
	int solution = 0;
	for(int i = 0; i <= n; i++) solution = max(solution, dp[i][n-i]);
	cout << solution << endl;
	return 0;
}







































































Measured memory_bytes: 35248
# ABC136D - Gathering Children
def main():
    # children gather on the border of "RL"
    S = input()
    # decompose into partial strings (RR...LL)
    P = S.replace("LR", "L R").split()
    ans = []
    for p in P:
        # children on even numbers -> even, odds -> odd
        e, o = len(p) // 2, len(p) // 2 + len(p) % 2
        l, r = (e, o) if p.index("L") % 2 == 0 else (o, e)
        ans += [0] * (p.count("R") - 1) + [l] + [r] + [0] * (p.count("L") - 1)
    print(*ans)


if __name__ == "__main__":
    main()

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

import itertools

N, M ,X  =  [int(i) for i in input().split()]
Cs = []
for i in range(N):
    Cs.append([int(i) for i in input().split()])


min_a = 10000000000000

for i in range(1, N+1):
    for team in itertools.combinations(Cs, i):
        money = [0] * (M+1)
        for t in team:
            money = [i+j for i,j in zip(money,t)]
        flag = 1
        for m in money[1:]:
            if m < X:
                flag = 0
        if flag == 1 and min_a > money[0]:
            min_a = money[0]
if min_a == 10000000000000:
    print(-1)
else:
    print(min_a)


Measured memory_bytes: 9220
class PriorityQueue
  MIN = -(2 << 60)

  attr_reader :size

  def initialize(&block)
    @size = 0
    @heap = Array.new
    @get_key = block || :itself.to_proc
  end

  def empty?
    size == 0
  end

  def pop
    return nil if @size <= 0
    max = @heap[1]
    @heap[1] = @heap[@size]
    @size -= 1
    max_heapify(1)
    max
  end

  def push(x)
    @size += 1
    i = @size
    @heap[i] = x
    while i > 1 && @get_key.call(@heap[i / 2]) < @get_key.call(@heap[i])
      t = @heap[i / 2]
      @heap[i / 2] = @heap[i]
      @heap[i] = t
      i = i / 2
    end
  end

  def top
    return nil if @size <= 0
    @heap[1]
  end

  def to_a
    return [] if @size == 0
    @heap[1..@size]
  end

  private

  def max_heapify(i)
    l = 2 * i
    r = 2 * i + 1
    largest =
      l <= @size && @get_key.call(@heap[l]) > @get_key.call(@heap[i]) ? l : i
    largest = r \
      if r <= @size && @get_key.call(@heap[r]) > @get_key.call(@heap[largest])
    unless largest == i
      t = @heap[i]
      @heap[i] = @heap[largest]
      @heap[largest] = t
      max_heapify(largest)
    end
  end
end

N, M = gets.split.map(&:to_i)
a_list = gets.split.map(&:to_i)
bc_list = M.times.map { gets.split.map(&:to_i) }
sorted = bc_list.sort_by { |(_, c)| -c }
pq = PriorityQueue.new { |a| -a } # 小さい値を優先
a_list.each { |a| pq.push(a) }
sorted.each do |(b, c)|
  while b > 0 && c > pq.top
    pq.pop
    pq.push(c)
    b -= 1
  end
end
ans = pq.to_a.reduce(&:+)
puts ans


Measured memory_bytes: 19984
#include<bits/stdc++.h>
#define ll long long
#define R register
#define int long long
using namespace std;
const int N =2e6+200;
template <class Ruby_Rose> inline void read(Ruby_Rose &x)
{
 	x=0;
	char ch=getchar(), w=0;
	while(!isdigit(ch))w=(ch=='-'), ch=getchar();
	while(isdigit(ch))x=(x<<1)+(x<<3)+(ch^48), ch=getchar();
	x=w?-x:x;
}
int n, k, val[N], tot;
signed main()
{
	read(n);
	ll ans=n/500*1000;
	n%=500; 
	ans+=n/5*5;
	cout<<ans; return 0;
}

Measured memory_bytes: 256
def number():
    return int(input())


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


def seq_space(n):
    return [list(map(int, input().split())) for _ in range(n)]


N, W = space()
WV = seq_space(N)

DP = [[0] * (W+1) for _ in range(N+1)]

for i in range(1, N+1):
    w, v = WV[i-1]
    for j in range(W+1):
        if j-w < 0:
            DP[i][j] = DP[i-1][j]
        else:
            DP[i][j] = max(DP[i-1][j-w] + v, DP[i-1][j])

print(max(DP[-1]))


Measured memory_bytes: 121460
#include<bits/stdc++.h>
using namespace std;
#define int long long
void Digvijay()
{
   int a,b,x;
   cin>>a>>b>>x;
   int val1=a/x;
   if(a%x==0)val1--;
   int ans = (b/x)-val1;
   cout<<ans<<"\n";
}
signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _=1;
    //cin>>_;
    for(int __=0;__<_;__++)
    {
        Digvijay();
    }
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>

constexpr int Inf = std::numeric_limits<int>::max();

template<typename F>
constexpr decltype(auto) fix(F&& f) {
	return[f = std::forward<F>(f)](auto&&... args) {
		return f(f, std::forward<decltype(args)>(args)...);
	};
}

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

	std::vector<int> vec(n);
	for (auto&& e : vec)
		std::cin >> e;

	std::vector<std::vector<int>> edges(n);
	for (int i = 0; i < n - 1; ++i) {
		int u, v;
		std::cin >> u >> v;
		--u, --v;

		edges[u].push_back(v);
		edges[v].push_back(u);
	}

	std::vector<int> depth(n, -1);
	std::vector<int> ans(n);
	auto dfs = fix([&](auto f, int x, int d, int curMax, std::vector<int>& dp) -> void {
		depth[x] = d;

		auto it = std::lower_bound(dp.begin(), dp.end(), vec[x]);
		int old = *it;

		curMax = std::max<int>(curMax, it - dp.begin() + 1);
		ans[x] = curMax;

		*it = vec[x];
		for (auto&& dist : edges[x]) {
			if (depth[dist] != -1)
				continue;

			f(f, dist, d + 1, curMax, dp);
		}
		*it = old;
	});

	std::vector<int> dp(n + 1, Inf);
	dfs(0, 1, 0, dp);

	for (auto&& e : ans)
		std::cout << e << std::endl;
}

Measured memory_bytes: 37544
n,m = map(int,input().split())
a = list(map(int,input().split()))
suma = sum(a)
bunbo = 4*m
ans = 0
for i in range(n):
    if a[i] >= suma / bunbo:
        ans += 1
if ans >= m:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    ll N, K, ans=0, tmp;

    cin >> N >> K;

    while(N>0) {
        tmp = N/K;
        N = tmp;
        ans++;
    }
    
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline().rstrip()

n = int(input())
h = list(map(int, input().split()))
k = []
ans = 0
for i in range(n):
    c = 0
    if i+1 <= n-1 and h[i] >= h[i+1]:
        ans += 1
    else:
        k.append(ans)
        ans = 0
print(sorted(k, reverse=True)[0])

Measured memory_bytes: 15020
#include <stdio.h>

int main(){
  int S, h, m, s;

  scanf("%d", &S);

  s = S % 60;
  m = (S / 60) % 60;
  h = (S / 60) / 60;
    
  printf("%d:%d:%d\n", h, m, s);

  return 0;
}

Measured memory_bytes: 592
using System;
using System.Collections.Generic;

public class CSharp
{
    public static void Main()
    {
        Kyopuro chokudai = new Kyopuro();
        chokudai.AtCoder();
    }
}

public class Kyopuro
{

    int n, m, k;

    public void AtCoder()
    {
        string[] input;
        input = Console.ReadLine().Split(' ');
        n = int.Parse(input[0]);
        k = int.Parse(input[1]);
        const int p = 1000000007;
        Mod mod = new Mod(3000);
        long ans = 0;
        for(int i=1; i<=k; i++)
        {
            if (i > n - k + 1)
            {
                Console.WriteLine(0);
                continue;
            }
            ans = mod.Ncr(n - k + 1, i);
            ans = ans * mod.Ncr(k - 1, k - i);
            ans %= p;
            Console.WriteLine(ans);
        }
    }
    public static void DebugWL(object x) { System.Diagnostics.Debug.WriteLine(x); }
}

// Mod(int n)
// int[] fac: factors (1-indexed)
// int n: the length of fac

// int .Ncr(n,r): nCr
// int .Fac(n): n!%p
// int .Pow(n,m): n^m%p

public class Mod
{
    const int p = 1000000007;
    int[] fac;

    public Mod(int n)
    {
        fac = new int[n + 1];
        for (int i = 1; i <= n; i++) fac[i] = -1;
        fac[0] = 1;
    }

    public int Ncr(int n, int r)
    {
        if (n < r) return 0;
        if (r == 0 | n == r) return 1;
        long a = Fac(n);
        a = a * Pow(Fac(n - r), p - 2) % p;
        a = a * Pow(Fac(r), p - 2) % p;
        return (int)a;
    }

    public int Fac(int n)
    {
        if (fac[n] >= 0) return fac[n];
        long k = 1;
        for (long i = 1; i <= n; i++)
        {
            k = k * i % p;
        }
        fac[n] = (int)k;
        return fac[n];
    }

    public int Pow(int n, int m)
    {
        if (m == 0) return 1;
        if (m == 1) return n;
        long a = 1;
        if (m % 2 == 0)
        {
            a = Pow(n, m / 2);
            a = a * a % p;
        }
        else
        {
            a = Pow(n, m / 2);
            a = a * a % p;
            a = a * n % p;
        }
        return (int)a;
    }
}


Measured memory_bytes: 13248
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

vector<vi> adj;
vi vis,ans;

void dfs(int root)
{
	vis[root]=1;
	for(auto i:adj[root])
	{
		if(!vis[i])
			dfs(i);
		ans[root]=max(ans[root],ans[i]+1);
	}
}


int32_t main()
{
	fastIO
	//inp_out();
	int n,m;
	cin>>n>>m;
	adj=vector<vi>(n+1);
	vis=ans=vi(n+1);
	for(int i=0;i<m;++i)
	{
		int x,y;
		cin>>x>>y;
		adj[x].pb(y);
	}

	for(int i=1;i<=n;++i)
		if(!vis[i])
			dfs(i);
	int fa=0;
	for(int i=1;i<=n;++i)
		fa=max(fa,ans[i]);
	cout<<fa;

	return 0;
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin >> n;
    set<ll> st;
    rep(i,n)
    {
        ll tmpx;
        cin >> tmpx;
        st.insert(tmpx);
    }
    if (st.size()==n)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }


    
}




Measured memory_bytes: 9600