akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 1e6 + 10;
const ll mod = 1e9 + 7;
int n, m;
ll a[maxn], b[maxn];
double c[maxn];
int ans=0;
void solve() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i];
        c[i]=sqrt(a[i]*a[i]+b[i]*b[i]);
        //cout<<c[i]<<endl;
        if(c[i]<=m)
            ans++;
    }
    cout<<ans<<endl;
}




int main() {
    std::ios::sync_with_stdio(false);
    int test = 1;
    while (test--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 8392
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    long t[50];
    string s[50];
    int N;
    cin >> N;
    
    for(int i = 0;i < N;i++){
        getline(std::cin, s[i],' ');
        s[i].erase(s[i].begin());
        cin >> t[i];
    }
    
    string X = "";
    
    cin >> X;
    
    long ans = 0;
    for(int i = N;i > 0;i--){
        
        if(s[i - 1] == X){
            break;
        }else{
            ans += t[i - 1];
        }
    }
    
    cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>

using namespace std;
int in[300], R[300], out[300];
const int M=256;
int cnt[300];
const double eps=1e-9;
int s, a, c;
void hoge(int N){

    for(int i=1; i<=N; i++) cin>> in[i];

    double h=10000000;
    for(int S=0; S<=15; S++){
        R[0]=S;
        for(int A=0; A<=15; A++){
            for(int C=0; C<=15; C++){
                for(int i=1; i<=N; i++){
                    (R[i]=A*R[i-1]+C)%=M;
                }
                for(int i=1; i<=N; i++){
                    (out[i]=in[i]+R[i])%=M;
                }
                for(int i=0; i<=M; i++) cnt[i]=0;
                for(int i=1; i<=N; i++) cnt[out[i]]++;

                double H=0;
                for(int i=0; i<=M; i++){
                    if(cnt[i]) H-=((1.*cnt[i]/N)*log(1.*cnt[i]/N));
                }
                if(H+eps<h){
                    h=H;
                    s=S;
                    a=A;
                    c=C;
                }
            }
        }
    }

    cout<< s<< " "<< a<< " "<< c<< endl;

}

int main(){

    while(1){
        int N;
        cin>> N;
        if(!N) break;

        hoge(N);
    }

    return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    vector<vector<int>>dp1(n+1,vector<int>(k));
    vector<vector<int>>dp2(n+1,vector<int>(k));
    dp1[0][0]=1,dp2[0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<k;j++){
            dp1[i+1][j]=max(dp1[i+1][j],dp1[i][j]);
            if(j+a[i]<k)dp1[i+1][j+a[i]]=max(dp1[i+1][j+a[i]],dp1[i][j]);
            dp2[i+1][j]=max(dp2[i+1][j],dp2[i][j]);
            if(j+a[n-i-1]<k)dp2[i+1][j+a[n-i-1]]=max(dp2[i+1][j+a[n-i-1]],dp2[i][j]);
        }
    }
    int ans=n;
    for(int i=0;i<n;i++){
        vector<int>l;
        vector<int>r;
        for(int j=0;j<k;j++){
            if(dp1[i][j])l.push_back(j);
            if(dp2[n-i-1][j])r.push_back(j);
        }
        for(int j=0;j<l.size();j++){
            if(l[j]+r.back()>=k-a[i] && 
            *lower_bound(r.begin(),r.end(),k-a[i]-l[j])<k-l[j]){
                ans--;
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 198964
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).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 (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  int x;cin>>x;
  int min=1e9+7;
  int res=0;
  rep(i,n)
  {
    int t;cin>>t;
    chmin(min,t);
    res+=1;
    x-=t;

  }
  cout<<res+(x)/min<<endl;


  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const double PI  = 3.1415926535897932384626433832795028841971;
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
string str[50];

int dfs(int dep, int st, int ope){
	int ret;
	if(ope == 0) ret = 0;
	else ret = 1;
	for(int i = st; i < n; i++){
		int cnt = 0;
		char tmp = str[i][str[i].size()-1];
		rep(j,str[i].size()){
			if(str[i][j]=='.')cnt++;
			else break;
		}
		if(cnt < dep) break;
		if(cnt > dep) continue;
		if(0<=tmp-'0'&&tmp-'0'<=9){
			if(ope) ret = ret*(tmp-'0');
			else ret = ret+(tmp-'0');
		} else if(tmp == '+'){
			if(ope) ret = ret*dfs(dep+1,i+1,0);
			else ret = ret+dfs(dep+1,i+1,0);
		} else{
			if(ope)ret = ret*dfs(dep+1,i+1,1);
			else ret = ret+dfs(dep+1,i+1,1);
		}
	}
	return ret;
}

void solve(){
	rep(i,n) cin >> str[i];
	cout << dfs(0,0,0) << endl;
}

int main(){
	while(cin >> n){
		if(n == 0) break;
		solve();
	}
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
#define int long long
#define re(i,n) for(i=0;i<n;i++)
#define bre(i,n) for(i=n;i>0;i--)
#define rep(i,l,r) for(i=l;i<r;i++)
#define brep(i,l,r) for(i=r;i>l;i--)
const int inf=1145141919810893;
const int mod=1000000007;
using namespace std;
template<class T>bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}
template<class T>bool chmax(T &a,const T &b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}
template<class T>void debug(T *a,int l,int r,const char *name){
	for(int i=l;i<r;i++)
		cout<<name<<"["<<i<<"]="<<a[i]<<endl;
}
int A,B,C,D,N,M,T;
int p[114514],q[114514],t[114514];
string s;
signed main(){
	int i,j;
	cin>>N;
	re(i,N){
		cin>>t[i]>>p[i]>>q[i];
	}
	int x=0,y=0,tt=0;
	re(i,N){
		int d=abs(x-p[i])+abs(y-q[i]);
		if(d>t[i]-tt||(t[i]-tt-d)%2){
			cout<<"No"<<endl;
			return 0;
		}
		tt=t[i];
		x=p[i];
		y=q[i];
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

int main() {
	int n; cin >> n;
	int64_t a[n]; for(int i = 0; i < n; ++i) cin >> a[i];
	int64_t b[n]; for(int i = 0; i < n; ++i) cin >> b[i];
	priority_queue<pair<int, int>, vector<pair<int, int>>> pq;
	for(int i = 0; i < n; ++i) {
		pq.emplace(b[i], i);
	}
	int64_t ans = 0;
	while(not pq.empty()) {
		int _, i;
		tie(_, i) = pq.top();
		pq.pop();
		if(b[i] == a[i]) continue;
		int64_t l = b[(i - 1 + n) % n];
		int64_t r = b[(i + 1) % n];
		if(b[i] <= l + r) {
			cout << -1 << '\n';
			return 0;
		}
		if((b[i] - a[i]) % (l + r) == 0) {
			ans += (b[i] - a[i]) / (l + r);
			b[i] = a[i];
			continue;
		}
		int k = (b[i] + (l + r) - 1) / (l + r) - 1;
		ans += k;
		b[i] = b[i] - k * (l + r);
		pq.emplace(b[i], i);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 5492
#include<bits/stdc++.h>
using namespace std;
 
#define IOS 		ios_base::sync_with_stdio(false);; cin.tie(0); cout.tie(0)
#define sd(n)       scanf("%d", &n)
#define sdd(a,b)    scanf("%d %d", &a, &b)
#define sddd(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sld(n)      scanf("%lld", &n)
#define slld(a,b)   scanf("%lld %lld", &a, &b)
#define sllld(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define slu(n)      scanf("%llu", &n)
#define sllu(a,b)   scanf("%llu %llu", &a, &b)
#define slllu(a,b,c) scanf("%llu %llu %llu", &a, &b, &c)
#define ss(a)		scanf("%s", a)
#define inStrAftInSome cin.ignore(numeric_limits<streamsize>::max(),'\n')		//input string(with whitespace) after input something(char, int, bool, str)
#define all(a) 		a.begin(),a.end()
#define unq(x)      x.erase(unique(all(x)), x.end()
#define mp 			make_pair
#define mt 			make_tuple
#define sz(av) 		int((av).size())					//return size of vec
#define CLR(arr)    memset(arr, 0, sizeof(arr))			//assign 0 to whole arr
#define SET(vec)    memset(arr, -1, sizeof(arr))		//assign -1 to whole arr
#define CLRV(vec)	fill(vec.begin(), vec.end(), 0)		//assign 0 to whole vec
#define SETV(vec,n,a) vec.assign(n, a)	
#define vtd(rowsize,colsize,type,name) 		vector < vector <type> > name(rowsize,vector <type> (colsize)); 	//assign to first n elements value a in vec
#define SETB(a)		memset(a, true, sizeof(a))			//boolean array initialize by true value
#define CLRB(a)		memset(a, false, sizeof(a))			//boolean array initialize by false value
#define vintitr 	vector<int>::iterator
#define vlnlnitr 	vector<long long>::iterator
#define sintitr 	set<int>::iterator
#define slnlnitr 	set<long long>::iterator
#define aa			first
#define bb			second
#define MOD 		1000000007
#define PI 			acos(-1.00)
#define psb 		push_back
#define ppb			pop_back
#define ppb			pop_back
#define psf			push_front
#define ppf			pop_front
#define in 			inset
#define rep(i, n) 	for(int i=0; i<n; i++)
#define repi(i,j,n) for(int i=j; i<n; i++)
#define rof(i, n)   for(int i=n-1; i>=0; i--)
#define roff(i, n, f)	for(int i = n-1; i>=f; i--)
#define min3(a,b,c) (min((c),min((a),(b))))
#define max3(a,b,c) (max((a),max((b),(c))))
#define __lcm(a, b)	a*b / __gcd(a, b)
#define __builtin_zerocount(a)	8*sizeof(a)-__builtin_popcount(a)-__builtin_clz(a)-__builtin_ctz(a)
#define D(t)        cerr << #t " = " <<t  << '\n'
#define DBG         cerr << "Hi!" << '\n'
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
 
 
typedef long long	 		ll;
typedef unsigned long long	llu;
typedef long double			ld;
typedef vector< int > 		vi;
typedef vector<llu>         vlu;
typedef vector< vi >		vvi;
typedef pair<int, int> 		pii;
typedef tuple<int,int,int>  tiii;

int main()
{
	IOS;
	int n, mw;	cin >> n >> mw;
	vlu dp(mw+1, 0);
	rep(i, n){
		int w, v;	cin >> w >> v;
		rof(j, mw-w+1)
			dp[j+w] = max(dp[j+w], dp[j]+v);
	}
	cout << dp[mw] << endl;
	
    return 0;
}


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

using namespace std;

#define ll long long

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

	if (a == 'H') {
		cout << b << endl;
	} else {
		if (b == 'H') cout << a << endl;
		else cout << "H" << endl;
	}

	return (0);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <queue>

using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using u16 = std::uint16_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
using usize = std::size_t;

i32 mid[100000];
i64 xmax[100001];
i64 ymin[100001];

auto main() -> i32 {
	i32 n;
	scanf("%d", &n);
	std::priority_queue<i32, std::vector<i32>, std::greater<i32>> x;
	i64 xsum = 0;
	for (i32 i = 0; i < n; i += 1) {
		i32 a;
		scanf("%d", &a);
		x.emplace(a);
		xsum += (i64)a;
	}
	for (i32 i = 0; i < n; i += 1) {
		i32 a;
		scanf("%d", mid + i);
	}
	std::priority_queue<i32, std::vector<i32>> y;
	i64 ysum = 0;
	for (i32 i = 0; i < n; i += 1) {
		i32 a;
		scanf("%d", &a);
		y.emplace(a);
		ysum += (i64)a;
	}

	xmax[0] = xsum;
	ymin[n] = ysum;

	for (i32 i = 0; i < n; i += 1) {
		x.emplace(mid[i]);
		xsum += (i64)mid[i] - (i64)x.top();
		x.pop();
		y.emplace(mid[n - 1 - i]);
		ysum += (i64)mid[n - 1 - i] - (i64)y.top();
		y.pop();
		xmax[i + 1] = xsum;
		ymin[n - 1 - i] = ysum;
	}

	i64 ans = -123456123456123456;
	for (i32 i = 0; i <= n; i += 1) {
		if (xmax[i] - ymin[i] > ans) {
			ans = xmax[i] - ymin[i];
		}
	}
	printf("%ld\n", ans);
	return 0;
}


Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define rdis 15.707963267948966192313216916398
const int maxn = 200035;

struct node
{
	int x,y;
	bool operator < (node a) const
	{
		return x < a.x;
	}
}a[maxn],t[maxn];
int n,cnt,Sx,Sy,Tx,Ty,Mnx,Mny,Mxx,Mxy,f[maxn],g[maxn];
double ans;

int read()
{
	char ch = getchar();
	int num = 0, fl = 1;
	for (; !isdigit(ch); ch=getchar())
		if (ch=='-') fl = -1;
	for (; isdigit(ch); ch=getchar())
		num = (num<<1)+(num<<3)+ch-48;
	return num*fl;
}
int main()
{
	Sx = read(), Sy = read(), Tx = read(), Ty = read(), n = read();
	Mxx = std::max(Sx, Tx), Mxy = std::max(Sy, Ty);
	Mnx = std::min(Sx, Tx), Mny = std::min(Sy, Ty);
	for (int i=1; i<=n; i++)
		a[i].x = read(), a[i].y = read();
	std::sort(a+1, a+n+1);
	for (int i=1; i<=n; i++)
		if (a[i].x >= Mnx&&a[i].x <= Mxx&&a[i].y >=Mny&&a[i].y <= Mxy) t[++cnt] = a[i];
	if (Sy==Ty){
		bool chk = false;
		ans = (Mxx-Mnx)*100.0;
		for (int i=1; i<=cnt; i++)
			if (t[i].y==Sy) chk = true;
		if (chk) ans = ans-20+2.0*rdis;
		printf("%.13lf\n",ans);
		return 0;
	}
	if (Sx==Tx){
		bool chk = false;
		ans = (Mxy-Mny)*100.0;
		for (int i=1; i<=cnt; i++)
			if (t[i].x==Sx) chk = true;
		if (chk) ans = ans-20+2.0*rdis;
		printf("%.13lf\n",ans);
		return 0;
	}
	if (Sx > Tx) std::swap(Sx, Tx), std::swap(Sy, Ty);
	if (Sy < Ty){
		int sum = 0;
		memset(f, 0x3f3f3f3f, sizeof f);
		f[0] = 0;
		for (int i=1; i<=cnt; i++)
		{
			int pos = std::lower_bound(f+1, f+cnt+1, t[i].y)-f;
			f[pos] = std::min(f[pos], t[i].y);
		}
		for (int i=1; i<=cnt; i++)
			if (f[i]!=0x3f3f3f3f) sum = i;
		ans = 100.0*(Mxy-Mny+Mxx-Mnx)+1.0*sum*(-20.0+rdis);
		if (sum==std::min(Mxx-Mnx, Mxy-Mny)+1) ans = ans+rdis;
		printf("%.13lf\n",ans);
		return 0;
	}
	if (Sy > Ty){
		int sum = 0;
		memset(f, 0x3f3f3f3f, sizeof f);
		f[0] = -0x3f3f3f3f;
		for (int i=1; i<=cnt; i++)
		{
			int pos = std::lower_bound(f+1, f+cnt+1, -t[i].y)-f;
			f[pos] = std::min(f[pos], -t[i].y);
		}
		for (int i=1; i<=cnt; i++)
			if (f[i]!=0x3f3f3f3f) sum = i;
		ans = 100.0*(Mxy-Mny+Mxx-Mnx)+1.0*sum*(-20.0+rdis);
		if (sum==std::min(Mxx-Mnx, Mxy-Mny)+1) ans = ans+rdis;
		printf("%.13lf\n",ans);
		return 0;
	}
	return 0;
}


Measured memory_bytes: 4096
/*
AizuOnline A0143
Title Altair and Vega
@kankichi573
*/
#include <stdio.h>
#include <float.h>

int N;
int xp1,yp1,xp2,yp2,xp3,yp3,xk,yk,xs,ys;
int a[2][2];
int b[2];
double result[2];

void renritu_solve()
{
        int det;
        
        det=a[0][0]*a[1][1]-a[1][0]*a[0][1];
        result[0]=(double)(a[1][1]*b[0]-a[0][1]*b[1]);
        result[1]=(double)(-a[1][0]*b[0]+a[0][0]*b[1]);
        result[0] /= ((double)det);
        result[1] /= ((double)det);

}
//
main()
{
        int i,n,r1,r2;


        while(EOF!=scanf("%d ",&N) && N)
        {
                for(i=0;i<N;i++)
                {
                        scanf("%d %d %d %d %d %d %d %d %d %d",
                              &xp1,&yp1,&xp2,&yp2,&xp3,&yp3,&xk,&yk,&xs,&ys);
                                
                        a[0][0]=xp2-xp1;
                        a[0][1]=xp3-xp1;
                        a[1][0]=yp2-yp1;
                        a[1][1]=yp3-yp1;

                        b[0]=xk-xp1;
                        b[1]=yk-yp1;
                        renritu_solve();
                        
                        r1=((result[0]>0.0) && (result[1]>0.0) && (result[0]+result[1]<1.0))?1:0;
                        b[0]=xs-xp1;
                        b[1]=ys-yp1;
                        renritu_solve();
                        
                        r2=((result[0]>0.0) && (result[1]>0.0) && (result[0]+result[1]<1.0))?1:0;
                        
                        printf("%s\n",(r1+r2==1)?"OK":"NG");
                }        
        }

        return(0);
}

Measured memory_bytes: 584
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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 main()
{
  int n; cin >> n;
  vector<int> l(n);
  rep(i,n) cin >> l[i];

  sort(l.begin(), l.end());
  int res = 0;
  rep(i,n) {
    rep(j,n) {
      if(i >= j) continue;
      int sum = l[i] + l[j];
      int lb = j, ub = n;
      while(ub - lb > 1) {
	int mid = (ub + lb) / 2;
	(l[mid] < sum ? lb : ub) = mid;
      }
      res += lb - j;
    }
  }
  
  cout << res << "\n";
  
  return 0;
}


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

int main(){
	int n, ans;

	while(cin >> n){
		ans = 0;

		if(n <= 36){
			for(int a = 0; a <= 9; a++){
				for(int b = 0; b <= 9; b++){
					for(int c = 0; c <= 9 ; c++){
						for(int d = 0 ; d <= 9; d++){
							if((a + b + c + d ) == n){
								ans++;
							}
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  int sum = 0, ma = 0;
  rep(i, n) {
    int l; std::cin >> l;
    sum += l;
    chmax(ma, l);
  }
  sum -= ma;
  std::cout << (ma < sum ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 256
import java.util.Scanner;


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

		while(true) {
			int n=sc.nextInt(),x=sc.nextInt();
			if(n==0 && x==0) {
				break;
			}
			int ans=0;
			for(int i=1; i<=n; i++) {
				for(int j=i+1; j<=n;j++) {
					for(int k=j+1; k<=n;k++) {
						if((i+j+k)==x) {
							ans++;
						}
					}
				}
			}
			System.out.println(ans);

		}

	}
}


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

int main() {
  vector<int> v(5);
  for (int i = 0; i < 5; i++) cin >> v[i];

  for (int i = 1; i < 5; i++) {
    if (v[i]%10 == 0) swap(v[i-1], v[i]);
    else if (v[i-1]%10 < v[i]%10) swap(v[i-1], v[i]);
  }

  int ans = 0;
  for (int i = 0; i < 5; i++) {
    if (v[i]%10 == 0) ans += v[i];
    else if (i != 4) ans += v[i] + (10-v[i]%10);
    else ans += v[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import fractions
#from functools import reduce
N,*a=map(int,open(0).read().split())
L=[]
L_base=a[0]
b=a[:]
b.reverse()
R=[]
R_base=b[0]
for i in range(N-1):
    L_base=fractions.gcd(L_base,a[i])
    L.append(L_base)
    R_base=fractions.gcd(R_base,b[i])
    R.append(R_base)
LR=[R[-1]]
for i in range(N-2):
    LR.append(fractions.gcd(L[i],R[-2-i]))
LR.append(L[-1])
print(max(LR))

Measured memory_bytes: 16120
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <algorithm>

using namespace std;

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

    int i = 0;
    while(i < S.length()){
        cout << S[i];
        i += 2;
    }

    cout << endl;
    
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1005

ll N;
char buf[NUM];
int length;
ll dp[NUM][NUM];

int main(){

	scanf("%lld",&N);
	scanf("%s",buf);

	for(length = 0; buf[length] != '\0'; length++);

	buf[length+1] = '\0';
	for(int i = length; i >= 1; i--){
		buf[i] = buf[i-1];
	}
	buf[0] = '+';

	length++;

	for(int i = 0; i <= length; i++){
		for(int k = 0; k <= length; k++){
			dp[i][k] = HUGE_NUM;
		}
	}

	dp[0][0] = 0;

	ll add_value,add_change;

	for(int base_loc = 0; base_loc <= length-2; base_loc++){
		for(int changed_num = 0; changed_num <= length; changed_num++){
			if(dp[base_loc][changed_num] > N)continue;
			for(int len = 2; len <= 12 && base_loc+len <= length; len++){
				for(int num = 0; num <= len; num++){

					if(buf[base_loc] == '+'){
						add_change = 0;
					}else{
						add_change = 1;
					}

					for(int i = 1; i < len; i++){
						if(buf[base_loc+i] == '+'){
							add_change++;
						}
					}

					add_value = 0;

					for(int i = 1; i < len; i++){

						add_value *= 10;

						if(buf[base_loc+i] == '+'){

							if(i == 1 && len >= 3){
								add_value += 1;
							}

						}else if(i == 1 && len >= 3 && buf[base_loc+i] == '0'){

							add_value++;
							add_change++;

						}else if(num+1 <= i){

							add_value += buf[base_loc+i]-'0';

						}else{

							if(i == 1 && len >= 3){
								add_value += 1;
								if(buf[base_loc+i] != '1'){
									add_change++;
								}
							}else{ //0
								if(buf[base_loc+i] != '0'){
									add_change++;
								}
							}
						}
					}

					dp[base_loc+len][changed_num+add_change] = min(dp[base_loc+len][changed_num+add_change],dp[base_loc][changed_num]+add_value);

				}
			}
		}
	}

	ll ans = length+1;

	for(int i = 0; i <= length; i++){
		if(dp[length][i] <= N){
			ans = i;
			break;
		}
	}

	if(ans == length+1){

		printf("-1\n");
	}else{

		printf("%lld\n",ans);
	}

	return 0;
}



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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;

    cin >> N;
    vector<ll> a(N, 0);

    ll X = 0;
    REP(i, N){ cin >> a[i];
        X ^= a[i];
    }

    REP(i, N){
        cout << (X ^ a[i]) << endl;
    }
}


Measured memory_bytes: 4836
#include "bits/stdc++.h"
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    long long x;
    cin>>x;
    long long ans=(x/11)*2;
    if(x%11>0){
        ans++;
        if(x%11>6)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

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

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;

int main() {
	int N;
	cin >> N;
	REP(i, N) {

		vector<int> v(3, 0);
		cin >> v[0] >> v[1] >> v[2];
		SORT(v);
		if (v[0] * v[0] + v[1] * v[1] == v[2] * v[2]) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}

Measured memory_bytes: 3000
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

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

int main(void){
  int N;
  cin>>N;
  cin.ignore();
  while(N--){
    string buf;
    getline(cin,buf);
    int M;
    cin>>M;
    cin.ignore();
    string::iterator it = buf.begin();
    while(M--){
      /*
      {
      int dist = distance(buf.begin(),it);
      REP(i,buf.size()){
        if(i==dist)putchar('^');
        putchar(buf[i]);
      }
      if(it==buf.end())putchar('^');
      putchar('\n');
      }
      */
      string command;
      getline(cin,command);
      if(command=="forward char"&&it!=buf.end()) it++;
      if(command=="backward char"&&it!=buf.begin()) it--;
      if(command=="forward word"){
        while(it!=buf.end()&&*it==' ')it++;
        while(it!=buf.end()&&*it!=' ')it++;
      }
      if(command=="backward word"){
        if(it!=buf.begin())it--;
        while(it!=buf.begin()&&(*it)==' ')it--;
        while(it!=buf.begin()&&(*it)!=' ')it--;
        if(*it==' ') it++;
      }
      if(command=="delete char"&&it!=buf.end()) it = buf.erase(it);
      if(command=="delete word"){
        string::iterator it2 = it; 
        while(it2!=buf.end()&&*it2==' ')it2++;
        if(it2!=buf.end()){
          while(it2!=buf.end()&&*it2!=' ')it2++;
          //if(it2!=buf.end())it2++;
          it = buf.erase(it,it2);
        }
      }
      if(command.find("insert",0)!=string::npos){
        string ins = command.substr(8);
        string::iterator ir = ins.end()-1;
        ins.erase(ir);
        //cout<<ins<<endl;
        REP(i,ins.size()){
          it = buf.insert(it,ins[i]);
          it++;
        }
      }
    }
    int dist = distance(buf.begin(),it);
    REP(i,buf.size()){
      if(i==dist)putchar('^');
      putchar(buf[i]);
    }
    if(it==buf.end())putchar('^');
    putchar('\n');
  }
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--ModInt
//-------------------------------------------------
const ::std::uint_fast64_t MOD = 1e9+7;

class mint{
private:
    using value_type = ::std::uint_fast64_t;
    value_type n;
public:
    mint():n(0){}
    mint(value_type _n):n(_n%MOD){}
    mint(const mint &m):n(m.n){}

    friend ::std::ostream& operator<<(::std::ostream &os, const mint &a){
		return os << a.n;
	}
    friend ::std::istream& operator>>(::std::istream &is, mint &a){
        value_type temp; is>>temp;
        a = mint(temp);
        return is;
    }

    mint& operator+=(const mint &m){n+=m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator-=(const mint &m){n+=MOD-m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator*=(const mint &m){n=n*m.n%MOD; return *this;}
    mint& operator/=(const mint &m){return *this*=m.inv();}
    mint& operator++(){return *this+=1;}
    mint& operator--(){return *this-=1;}

    mint operator+(const mint &m) const {return mint(*this)+=m;}
    mint operator-(const mint &m) const {return mint(*this)-=m;}
    mint operator*(const mint &m) const {return mint(*this)*=m;}
    mint operator/(const mint &m) const {return mint(*this)/=m;}
    mint operator++(int){mint t(*this); *this+=1; return t;}
    mint operator--(int){mint t(*this); *this-=1; return t;}

    mint operator==(const mint &m) const {return n==m.n;}
    mint operator!=(const mint &m) const {return n!=m.n;}
    mint operator-() const {return mint(MOD-n);}

    mint pow(value_type b) const {
        mint ret(1), m(*this);
        while(b){
            if (b & 1) ret*=m;
            m*=m;
            b>>=1;
        }
        return ret;
    }

    mint inv() const {return pow(MOD-2);}
};

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    mint ans(1);
    int r=0,b=0,g=0;
    rep(i,n){
        int a; cin>>a;
        int cnt=0, p=-1;
        if (a==r){
            cnt++;
            p = 0;
        }
        if (a==b){
            cnt++;
            p = 1;
        }
        if (a==g){
            cnt++;
            p = 2;
        }
        if (p==0) r++;
        if (p==1) b++;
        if (p==2) g++;
        ans*=cnt;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

int main() {
    string s;
    cin >> s;
    if(s == "Sunny") cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
	return 0;
}


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

int main(void) {
    regex re1("^.*keyence$");
    regex re2("^k.*eyence$");
    regex re3("^ke.*yence$");
    regex re4("^key.*ence$");
    regex re5("^keye.*nce$");
    regex re6("^keyen.*ce$");
    regex re7("^keyenc.*e$");
    regex re8("^keyence.*$");
    string S;cin>>S;
    if (regex_search(S, re1)||regex_search(S, re2)||regex_search(S, re3)||regex_search(S, re4)||regex_search(S, re5)||regex_search(S, re6)||regex_search(S, re7)||regex_search(S, re8)) {
        cout << "YES" << endl;
    } else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created by zhangrunfeng on 2/17/20
 */
public class Main {
    private int N;
    private int[] arr;

    public Main(Scanner sc) {
        N = sc.nextInt();
        arr = new int[N];
        for (int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }
    }

    public int partition(int p, int r) {
        int pivot = arr[r];
        int i = p - 1;
        for (int j = p; j < r; j++) {
            if (arr[j] <= pivot) {
                i++;
                int tmp = arr[i];
                arr[i] = arr[j];
                arr[j] = tmp;
            }
        }
        arr[r] = arr[i + 1];
        arr[i + 1] = pivot;
        return i + 1;
    }

    public void printResult(int startIx, int endIx, int partitionIx) {
        for (int ix = startIx; ix < endIx-1; ix++) {
            if (ix == partitionIx) {
                System.out.print("[");
            }
            System.out.print(arr[ix]);
            if (ix == partitionIx) {
                System.out.print("]");
            }
            System.out.print(" ");
        }
        if (endIx-1 == partitionIx) {
            System.out.print("[");
        }
        System.out.println(arr[endIx-1]);
        if (endIx-1 == partitionIx) {
            System.out.print("]");
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        int partitionIx = m.partition(0, m.N - 1);
        m.printResult(0, m.N, partitionIx);
    }
}



Measured memory_bytes: 69076
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <bitset>

using namespace std;
using ll = long long;

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    h.resize(max(0, n - k));
    cout << accumulate(h.begin(), h.end(), 0ll) << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

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

  if(x==1) {
    cout<<"1"<<endl;
    return 0;
  }

  int maxPow = 1;
  for(int i=2; pow(i,2)<=x; i++) {
    for(int j=2; pow(i,j) <= x; j++) {
      maxPow = max(maxPow, (int)pow(i,j));
    }
  }
  cout<<maxPow<<endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
 
 
int main(int argc, char** argv){
	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5]){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
Sa = S.replace('?', 'a')

def match(N):
  St = S[N:N + len(T)]
  for st, t in zip(St, T):
    if st == '?':
      continue
    elif t != st:
      return False
  return True

point = -1
for i in range(len(S) - len(T) + 1):
  if match(i):
    point = i
    
if point != -1:
  print(Sa[:point] + T + Sa[point + len(T):])

else:
  print('UNRESTORABLE')

  

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

int main()
{
    int n;
    cin >> n;
    long long int ans = 0;
    for(int i = 1; i <= n; i++){
        if(i % 3 == 0 || i % 5 == 0){

        }
        else ans += i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
def solve():
    R,G,B,N = list(map(int,input().split())) 
    RGBs = sorted([R,G,B],reverse=True)
    count = 0
    if N < min(R,G,B):
        pass
    else:
        for i in range(int(N/RGBs[0])+1):
            O = N - i*RGBs[0]
            for j in range(int(O/RGBs[1])+1):
                P = O - j*RGBs[1]
                if P%RGBs[2] == 0:
                    count += 1
    print(count)


solve()

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:128777216")
  
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <sstream>
  
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
  
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <string.h>
  
#include <memory.h>
#include <cassert>
#include <time.h>
  
using namespace std;
  
#define forn(i,n) for (int i = 0; i < (int)(n); i++)
#define fornd(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define forab(i,a,b) for (int i = (int)(a); i <= (int)(b); i++)
#define forabd(i, b, a) for (int i = (int)(b); i >= (int)(a); i--)
#define forit(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
  
#define _(a, val) memset (a, val, sizeof (a))
#define sz(a) (int)((a).size())
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
  
typedef long long lint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vii;
  
const lint LINF = 1000000000000000000LL;
const int INF = 1000000000;
const long double eps = 1e-9;
const long double PI = 3.1415926535897932384626433832795l;
  
#ifdef MY_DEBUG
#define dbgx( x ) { cerr << #x << " = " << x << endl; }
#define dbg( ... ) { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#else
#define dbgx( x ) {  } 
#define dbg( ... ) {  } 
#endif
  
void prepare(string s)
{
#ifdef MY_DEBUG
    freopen ("input.txt", "r", stdin);
    //freopen ("output.txt", "w", stdout);
#else
    if (s.length() != 0)
    {
        freopen ((s + ".in").c_str(), "r", stdin);
        freopen ((s + ".out").c_str(), "w", stdout);
    }
#endif
}

int a, b, c, k;

void read() {
  scanf("%d %d %d %d", &a, &b, &c, &k);
}

void solve() {
  lint ans = 1 * min(a, k) + -1 * min(c, max(0, k - a - b));
  printf("%lld\n", ans);
}

int main() {
  prepare("");

  read();
  solve();
  return 0;
}

Measured memory_bytes: 3768
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include <string>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;
int main(){
	int n; cin >>n;
	vector<ll> a(n);
	cinf(n,a);
	for(int i=0;i<n;i++){
		if(a[i]%2==0){
		}
		else{
			cout << "first" << endl;
			return 0;
		}
	}
	cout << "second" << endl;
}

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

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

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

int main() {
    double x;
    while(cin >> x, x >= 0){
        int val = int(x*16);
        if(x == val/16.0 && val < 4096){
            cout << bitset<8>(val >> 4) << "." << bitset<4>(val&15) << "\n";
        }else puts("NA");
    }
    return 0;
}


Measured memory_bytes: 3144
/**
 *    author:  math2do
 *    created: 03.03.2020 11:41:23
**/

#include <bits/stdc++.h>

using namespace std;

template <typename T> 
inline void read(T &x) {
  char c = (char) getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = (char) getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = (char) getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

const int pinf = std::numeric_limits<int>::max();

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  read(n); read(m);
  vector <int> arr(n, pinf);
  bool found = false;
  for (int i = 0; i < m; i++) {
    int pos, val;
    read(pos); pos--;
    read(val);
    if (arr[pos] != pinf && arr[pos] != val) {
      found = true;
      break;
    } 
    arr[pos] = val;
  }
  if (arr[0] == 0 && n != 1) found = true;
  if (found) cout << -1 << endl;
  else {
    if (arr[0] == pinf) {
      arr[0] = n > 1 ? 1 : 0;
    }
    for (int i = 1; i < n; i++) {
      if (arr[i] == pinf) {
        arr[i] = 0;
      }
    } 
    for (int i = 0; i < n; i++) {
      cout << arr[i];
    } 
    cout << endl;
  } 
  return 0;
}


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

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

int main(void) {
  ll x;
  cin >> x;

  prt((x/500)*1000+((x%500)/5)*5);
}


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

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

    vector<long long> a(n);
    

    for(long long i = 0; i < n; i++) cin >> a[i];


    long long cnt = 0;
    long long i = 0;

    while(i < n){
        if(i+1 < n and a[i] == a[i+1]){
            long long length = 1;

            while(i+1 < n and a[i] == a[i+1]){
                i++;
                length++;
            }
            cnt += length/2;
        }
        i++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int d = a + b;
    int e = b + c;
    int f = c + a;
    int ans = min(d, e);
    ans = min(ans, f);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////


int main(){fastio
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll k=0;
    rep(i,0,n-2){
        if(i%2==0)k-=a[i];
        else k+=a[i];
    }
    ll ans[n];
    ans[0]=(a[n-1]-k)/2;
    rep(i,1,n-1){
        ans[i]=a[i-1]-ans[i-1];
    }
    rep(i,0,n-1){
        cout<<ans[i]*2<<" ";
    }
    
    return 0;
}





Measured memory_bytes: 2944
#include <bits/stdc++.h>
 
#define A_MAX 1000000
#define A_MAX_HALF 500000
#define SQRT_A_MAX 1000
 
using namespace std;
 
int scanint() { 
	char c = getchar_unlocked();
    int x = 0;
    for(; (c<48)||(c>57);c = getchar_unlocked());
    for(; (c>47)&&(c<58);c = getchar_unlocked())
        x = 10 * x + c - 48;
    return x;
} 
 
int min_factor[A_MAX + 1];
int q[A_MAX + 1];
int a[A_MAX + 1];
 
int main() {
 
    vector<int> primes;
    for (int i = 2; i <= A_MAX; ++i) {
        if (!min_factor[i]) {
            min_factor[i] = i;
            if (i <= SQRT_A_MAX)
            	primes.push_back(i);
        }
        for (int p : primes) {
            int n = i * p;
            if (n > A_MAX) {
                break;
            }
            min_factor[n] = p;
            if (p == min_factor[i]) {
                q[n] = q[i];
                break;
            } else {
                q[n] = i;
            }
        }
    }
 
    int N = scanint();
    for (int i = 0; i < N; ++i) {
        ++a[scanint()];
    }
 
    bool is_pairwise_coprime = true;
    for (int n = A_MAX; n > 1; --n) {
        int an = a[n];
        if (an) {
            if (an > 1) {
                if (an == N) {
                    printf("not coprime\n");
                    return 0;
                }
                is_pairwise_coprime = false;
            }
            a[min_factor[n]] += an;
            a[q[n]] += an;
        }
    }
    if (is_pairwise_coprime) {
        printf("pairwise coprime\n");
    } else {
        printf("setwise coprime\n");
    }
 
    return 0;
}

Measured memory_bytes: 15336
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;

ll f(ll b,ll n){
  if(b>n) return n;
  ll ret=-1;
  ret = f(b,n/b)+n%b;
  return ret;
}

int main() {
  ll n,s;
  cin >> n >> s;
  //debug(f(160,n));
  if(s>n){
    cout << -1 << endl;
    return 0;
  }
  ll b=2;
  for(;b*b<=n;b++){
    if(f(b,n) == s){
      //cerr << "!!!!!!!!!!" << endl;
      cout << b << endl;
      return 0;
    }
  }
  debug(b);
  int q = b;
  for(;q>0;q--){
    if(s<q) continue;
    if((s-q)*q<n-s+q && (n-s+q)%q==0){
      //cerr << q << endl;
      ll b = (n-s+q)/q;
      if(2<=b && f(b,n)==s){
        cout << b << endl;
        return 0;
      }
    }
  }
  if(n==s){
    cout << n+1 << endl;
    return 0;
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>

using namespace std;

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

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define ALL(a)  (a).begin(),(a).end()
#define UNIQUE(a)  (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_buck
#define EACH(i,c) REP(i,(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,n,0)

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";

const int INF = 1e9;
const double EPS = 1e-10;

int n, m, k, s, t;
VI es;
string str;
P r[100000];

int main() {
	cin >> n;
	P M = P(0,0);
	REP(i,n){
		cin>>s>>t;
		M=max(M,P(s,t));
	}
	cout<<M.first + M.second<<endl;
}


Measured memory_bytes: 256
s = input()
n = len(s)
c0 = 0
c1 = 0
for i in range(n):
  if i % 2 == 0 and s[i] == '1':
    c0 += 1
  elif i % 2 == 1 and s[i] == '0':
    c0 += 1    
for i in range(n):
  if i % 2 == 1 and s[i] == '1':
    c1 += 1
  elif i % 2 == 0 and s[i] == '0':
    c1 += 1    
print(min(c0,c1))

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

const int mn=2e5+7;
int a[mn],n,k;

bool check(int x)
{
    int cnt=0;
    for(int i=1;i<=n;++i) cnt+=(a[i]-1)/x;
    if(cnt<=k) return 1;
    return 0;
}

int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;++i) {
        scanf("%d",&a[i]);
        a[n+1]=max(a[i],a[n+1]);
    }
    int l=1,r=a[n+1];
    while(l<r) {
        int mid=(l+r)>>1;
        if(check(mid)) r=mid;
        else l=mid+1;
    }
    cout<<l;
}

Measured memory_bytes: 4428
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,k,arr[1005];
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+n);
    ll sum=0;
    for(int i=0;i<k;i++)
    {
        sum+=arr[i];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<queue>
#define int long long
using namespace std;
int test[123456], uiop[123456];
signed main() {
	int n, k, s; cin >> n >> k >> s;
	for (int h = 0; h < k; h++) {
		cout << s << endl;
	}
	for (int h = k; h < n; h++) {
		if (s == 1000000000) { cout << 1 << endl; }
		else cout << s + 1 << endl;
	}
}

Measured memory_bytes: 1280
def pfact(m):
	pf = {}
	for i in range(2,int(m**0.5)+1):
		while m%i == 0:
			pf[i] = pf.get(i,0) + 1
			m //= i
	if m>1 : pf[m]=1
	return pf

def euler(m):
	tmp = pfact(m)
	ans = 1
	for i, j in tmp.items():
		ans = ans * (i**(j-1)) * (i-1)
	return ans

n = int(input())
print(euler(n))


Measured memory_bytes: 5640