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

using namespace std;

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

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

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

    rep(i,1e7){
        bool ok=true;
        if(int(i*0.08)!=A)ok=false;
        if(int(i*0.1)!=B)ok=false;
        if(ok){
            cout<<i<<endl;
            return 0;
        }
    }

    cout<<-1<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<utility>
#include<algorithm>
#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 srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
typedef long long ll;

using namespace std;



int main() {
    int n,l;
    cin>>n>>l;
    vector<pair<int,int>>t(n);
    rep(i,n) t[i]=pair<int,int>(-abs(l+i),l+i);
    sort(rng(t));
    t.pop_back();
    int ans=0;
    rep(i,n-1) ans += t[i].second;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3600
#
import sys
import math
import numpy as np
import itertools
# いくつか入力
x,y = (int(i) for i in input().split())  

MOD = 1000000007

if (x+y) % 3 != 0:
    print(0)
    exit()

if (x > y*2) or (y > x*2):
    print(0)
    exit()


a = x - (x+y) // 3
b = y - (x+y) // 3

upper=1
lower=1

for i in range(1,a+b+1,1):
    upper *= i
    upper %= MOD

for i in range(1,a+1,1):
    lower *= i
    lower %= MOD

for i in range(1,b+1,1):
    lower *= i
    lower %= MOD

# karimono
# https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
def mul(a, b):
    return ((a % MOD) * (b % MOD)) % MOD

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % MOD
    elif y % 2 == 0 : return power(x, y//2)**2 % MOD
    else            : return power(x, y//2)**2 * x % MOD

def div(a, b):
    return mul(a, power(b, MOD-2))

answer = div(upper,lower)

print(answer)





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

int main() {
  int n,m;
  while(cin >> n >> m && (n||m)) {
    int a[m],b[m];
    for(int i=0; i<m; i++) {
      cin >> a[i];
      b[i]=0;
    }
    for(int i=0; i<n; i++) {
      for(int j=0; j<m; j++) {
	int x;
	cin >> x;
	b[j]+=x;
      }
    }
    bool ck=true;
    for(int i=0; i<m; i++) {
      if(a[i]<b[i]) ck=false;
    }
    if(ck) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<queue>
#include<cmath>
#include<map>
#include<vector>
#include<iomanip>
using namespace std;
typedef long long ll;
ll inf = 100000000;
ll v[205];
ll t[20000005];
ll a[10000005];
ll b[10000005];
ll dp[10005][10005];
ll ex = 1000000007;
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };
typedef pair<ll, ll> P;
double q[200005];
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
	ll n;
	cin >> n;
	ll ans =  n * (n - 1)/2;
	cout << ans<< endl;
	return 0;
}

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

using namespace std;

typedef long long ll;

const ll mod = 1000000007;

int ban4[][4] = {{0,1,2,1},{0,2,2,1},{0,3,2,1},{0,2,0,1},{0,2,2,1},{0,2,3,1}};
int ban3[][3] = {{0,1,2},{0,2,1},{2,0,1}};

ll dp[105][4][4][4];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin >> N;
	if (N == 1) cout << 4 << '\n';
	else if (N == 2) cout << 16 << '\n';
	else if (N == 3) cout << 61 << '\n';
	else{
		N -= 3;
		for (int i = 0; i < 4; ++i){
			for (int j = 0; j < 4; ++j){
				for (int k = 0; k < 4; ++k){
					if ((i == 0 && j == 1 && k == 2) || (i == 0 && j == 2 && k == 1) || (i == 2 && j == 0 && k == 1)){
						dp[0][i][j][k] = 0;
					}
					else dp[0][i][j][k] = 1;
				}
			}
		}
		for (int i = 1; i <= N; ++i){
			for (int a = 0; a < 4; ++a){
				for (int b = 0; b < 4; ++b){
					for (int c = 0; c < 4; ++c){
						int check = 0;
						for (int j = 0; j < 3; ++j){
							if (c == ban3[j][0] && b == ban3[j][1] && a == ban3[j][2]){
								check = 1;
								break;
							}
						}
						if (check == 1) continue;
						for (int d = 0; d < 4; ++d){
							check = 0;
							for (int j = 0; j < 3; ++j){
								if (d == ban3[j][0] && c == ban3[j][1] && b == ban3[j][2]){
									check = 1;
									break;
								}
							}
							if (check) continue;
							for (int j = 0; j < 6; ++j){
								if (d == ban4[j][0] && c == ban4[j][1] && b == ban4[j][2] && a == ban4[j][3]){
									check = 1;
									break;
								}
							}
							if (check) continue;
							dp[i][c][b][a] += dp[i-1][d][c][b];
							dp[i][c][b][a] %= mod;
						}
					}
				}
			}
		}
		ll sum = 0;
		for (int a = 0; a < 4; ++a){
			for (int b = 0; b < 4; ++b){
				for (int c = 0; c < 4; ++c){
					sum += dp[N][a][b][c];
					sum %= mod;
				}
			}
		}
		cout << sum << '\n';
	}
	cout << flush;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define DBL(x) ((x)*(x))
#define EPS 1e-10

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int memoY[1000*1000];
int memoT[1000*1000];
int memo[1000*1000];
char buff[1000][1010];

int main(){
  int n;
  while(scanf("%d ",&n), n){
    memset(memoY,0,sizeof(int)*n*n);
    memset(memoT,0,sizeof(int)*n*n);
    memset(memo, 0,sizeof(int)*n*n);
    REP(i,n) fgets(buff[i],sizeof(buff[i]),stdin);
    REP(i,n){
      int tmp1 = 1, tmp2 = 1;
      for(int j=0; j<n; j++){
	if(buff[i][j] == '*') tmp1 = 0;
	memoY[i*n+j] = tmp1++;
	if(buff[j][i] == '*') tmp2 = 0;
	memoT[j*n+i] = tmp2++;
      }
    }
    int ans = 0;

    for(int i=0; i<n; i++){
      if(buff[i][0] == '.')
	ans = max(ans, memo[i*n] = 1);
      if(buff[0][i] == '.')
	ans = max(ans, memo[i] = 1);
    }

    for(int i=1; i<n; i++){
      for(int j=1; j<n; j++){
	if(buff[i][j] == '.'){
	  int tmpm = INT_MAX;
	  tmpm = min(tmpm, memoY[i*n+j-1]);
	  tmpm = min(tmpm, memoT[(i-1)*n+j]);
	  tmpm = min(tmpm, memo[(i-1)*n+j-1]);
	  ans = max(ans, memo[i*n+j] = tmpm + 1);
	}
      }
    }

    /*
    REP(i,n) {REP(j,n) printf("%c ",buff[i][j]); puts("");}
    puts("[memoY]");
    REP(i,n) {REP(j,n) printf("%d ",memoY[i][j]); puts("");}
    puts("[memoT]");
    REP(i,n) {REP(j,n) printf("%d ",memoT[i][j]); puts("");}
    puts("[memo]");
    REP(i,n) {REP(j,n) printf("%d ",memo[i][j]); puts("");}
    */

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

Measured memory_bytes: 0
#include <queue>
#include <set>
#include <unordered_set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef pair<int,int> pii;

/// pair<int,int> hasher
namespace std{
	template<typename I>
	class hash<pair<I,I>>{
		public:
		size_t operator()(const pair<I,I> &p) const {return hash<long long>() (((long long)(p.first))<<32|p.second);}
	};
}

double solve(const vector<pii> &a){
	set<int>ys;
	for(auto &e:a)ys.insert(e.second);
	int n=a.size();
	vector<double>mx,my;
	for(int i=0;i<n;i++){
		mx.push_back(a[i].first);
		my.push_back(a[i].second);
		if(i==n-1)continue;
		//??????????????§y??§?¨??????????ys?????????????????????
		if(a[i].second<a[i+1].second){ //??????i????°???§??????
			for(auto it=ys.begin();it!=ys.end();++it){
				if(a[i].second<*it && *it<a[i+1].second){
					double dy=a[i+1].second-a[i].second;
					double dx=(a[i+1].first-a[i].first)/dy*(*it-a[i].second);
					mx.push_back(a[i].first+dx);
					my.push_back(*it);
				}
			}
		}else{ //??????i????±±??§??????
			for(auto it=ys.end();it--!=ys.begin();){
				if(a[i+1].second<*it && *it<a[i].second){
					double dy=a[i+1].second-a[i].second;
					double dx=(a[i+1].first-a[i].first)/dy*(*it-a[i].second);
					mx.push_back(a[i].first+dx);
					my.push_back(*it);
				}
			}
		}
	}
	int m=mx.size();
	priority_queue<pair<double,pii>>q;
	unordered_set<pii>se;
	q.push({0,{0,m-1}});
	for(;!q.empty();){
		double c=q.top().first;
		int l=q.top().second.first;
		int r=q.top().second.second;
		q.pop();
		if(se.find({l,r})!=se.end())continue;
		se.insert({l,r});
		if(l==r)return -c;
		for(int i=-1;i<2;i++)for(int j=-1;j<2;j++){
			if((i||j) && 0<=l+i&&l+i<m && 0<=r+j&&r+j<m && fabs(my[l+i]-my[r+j])<1e-9)
				q.push({c-hypot(mx[l]-mx[l+i],my[l]-my[l+i])-hypot(mx[r]-mx[r+j],my[r]-my[r+j]),{l+i,r+j}});
		}
	}
	abort();
}

int main(){
	int N,x,y;
	for(;scanf("%d",&N),N;){
		vector<pii>a(N);
		for(int i=0;i<N;i++)scanf("%d%d",&a[i].first,&a[i].second);
		printf("%f\n",solve(a));
	}
}

Measured memory_bytes: 4444
def cumsum(xs):
    result = [0,xs[0]]
    for x in xs[1:]:
        result.append(result[-1] + x)
    return result
a,b=map(int,input().split())
c=list(map(int,input().split()))
n=cumsum(c)
ans=[]
for i in range(len(n)):
    if n[i]<=b:
        ans.append(n[i])
print(len(ans))

Measured memory_bytes: 9044
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define MOD (LL)pow(10,9) + 7


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

    LL ans = n / (a + b) * a;
    LL t = n - n / (a + b) * (a + b);
    if(t > a) ans += a;
    else{
        ans += t;
    }

    cout << ans << endl;
}



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

int main(void){
    double r;
    cin >> r;
    
    double pi = acos(-1);
    cout << fixed << setprecision(6);
    double area = r * r * pi;
    double cir = ( r + r ) * pi;
    cout << area << " " << cir << endl;
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

#define MAX_NUM (1000000007)
#define PI 3.14159265358979323846

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

template <typename T>
static inline T ArraySum(vector<T>& A) {
  T res = 0;
  for (auto itr = A.begin(); itr < A.end(); ++itr) res += *itr;
  return res;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

i64 modinv(i64 a, i64 m) {
  i64 b = m, u = 1, v = 0;
  while (b) {
    i64 t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

i64 My_Comb(u64 n, u64 k, i64 m) {
  if (n < k) return 0;
  if (k == 0 || n == k) return 1;
  u64 res = 1;
  k = (n / 2 < k) ? n - k : k;
  for (u64 i = 1; i <= k; ++i)
    res = (((res * (n + 1 - i)) % m) * modinv(i, m)) % m;
  return res;
}

i64 My_Pow(u64 a, u64 n, i64 m) {
  u64 tmp = n, calc = 1;
  while (tmp > 0) {
    if (tmp % 2) {
      tmp--;
      calc *= a;
      calc %= m;
    } else {
      a *= a;
      a %= m;
      tmp /= 2;
    }
  }
  return calc;
}

int main() {
  cout << setprecision(18);
  i64 A, B, K;
  cin >> A >> B >> K;

  vector<u32> res;

  for (u32 i = 100; i >= 1; --i) {
    if (A % i == 0 && B % i == 0) {
      res.push_back(i);
    }
  }

  cout << res[K - 1] << endl;

  return 0;
}


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

using namespace std;

#define int long long

char ans[2007][2007];

string ans1[4];
string ans2[5];
string ans3[7];

int n;

void pr()
{
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            cout << ans[i][j];
        }
        cout << endl;
    }
}

pair<int, int> dp[2007];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    if (n == 2)
    {
        cout << -1 << endl;
        return 0;
    }
    if (n % 3 == 0)
    {
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < n; ++j)
            {
                if (i / 3 == j / 3 && (i % 3 == 0 || j % 3 == 0) && !(i % 3 == 0 && j % 3 == 0))
                {
                    cout << 'a';
                }
                else
                {
                    cout << '.';
                }
            }
            cout << endl;
        }
        return 0;
    }
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            ans[i][j] = '.';
        }
    }
    ans1[0] = "abcc";
    ans1[1] = "abdd";
    ans1[2] = "ccab";
    ans1[3] = "ddab";
    ans2[0] = "aabbc";
    ans2[1] = "dde.c";
    ans2[2] = "a.ebb";
    ans2[3] = "a..nk";
    ans2[4] = ".bbnk";
    ans3[0] = "a...baa";
    ans3[1] = "a...b.c";
    ans3[2] = "b...ddc";
    ans3[3] = "bkaa...";
    ans3[4] = "ck.p...";
    ans3[5] = "cnnp...";
    ans3[6] = ".ddeeff";
    if (n == 7)
    {
        for (int i = 0; i < 7; ++i)
        {
            for (int j = 0; j < 7; ++j)
            {
                ans[i][j] = ans3[i][j];
            }
        }
        pr();
        return 0;
    }
    if (n == 11)
    {
        for (int i = 0; i < 7; ++i)
        {
            for (int j = 0; j < 7; ++j)
            {
                ans[i][j] = ans3[i][j];
            }
        }
        for (int i = 0; i < 4; ++i)
        {
            for (int j = 0; j < 4; ++j)
            {
                ans[7 + i][7 + j] = ans1[i][j];
            }
        }
        pr();
        return 0;
    }
    dp[4] = {1, 0};
    dp[5] = {0, 1};
    for (int i = 0; i < n; ++i)
    {
        if (dp[i].first + dp[i].second > 0)
        {
            dp[i + 4] = {dp[i].first + 1, dp[i].second};
            dp[i + 5] = {dp[i].first, dp[i].second + 1};
        }
    }
    int cur = 0;
    for (int k = 0; k < dp[n].first; ++k)
    {
        for (int i = 0; i < 4; ++i)
        {
            for (int j = 0; j < 4; ++j)
            {
                ans[cur + i][cur + j] = ans1[i][j];
            }
        }
        cur += 4;
    }
    for (int k = 0; k < dp[n].second; ++k)
    {
        for (int i = 0; i < 5; ++i)
        {
            for (int j = 0; j < 5; ++j)
            {
                ans[cur + i][cur + j] = ans2[i][j];
            }
        }
        cur += 5;
    }
    pr();
    return 0;
}


Measured memory_bytes: 3200
N=int(input())
A=list(map(int,input().split()))

R=[[] for _ in range(N)]
L=[[] for _ in range(N)]
for i in range(N):
    L[i].append(i+A[i])
    R[i].append(i-A[i])
L.sort()
R.sort()

i,j=0,0
out=0
while i<N and j<N:
    if L[i]>R[j]:
        j+=1
        continue
    elif L[i]<R[j]:
        i+=1
        continue
    if L[i] == R[j]:
        k=0
        while L[i+k]==R[j]:
            k+=1
            if i+k==N:
                break
        l=0
        while L[i]==R[j+l]:
            l+=1
            if j+l==N:
                break
        out+=k*l
        i,j=i+k,j+l


print(out)

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

using namespace std;


#define PI 3.14159265
#define int long long



main(){

	int n, d; cin >> n >> d;


	

	int current = 1, ans = 0;

	while(current <= n){
		current += 2 * d;
		ans++;
		current++;
	}


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

Measured memory_bytes: 256
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
#ifdef _MSC_VER
	while (true)
#endif
	{
		const int INF = 1 << 30;
		int n = -1, ma, mb, a, b, c;
		cin >> n >> ma >> mb;
		if (n < 0) return 0;
		vector<vector<int>> dp(2001, vector<int>(2001, INF));
		dp[0][0] = 0;
		for (int i = 0; i < n; ++i) {
			cin >> a >> b >> c;
			for (int i = 2000; i >= a; --i) {
				for (int j = 2000; j >= b; --j) {
					dp[i][j] = min(dp[i][j], dp[i - a][j - b] + c);
				}
			}
		}
		int ans = INF;
		for (a = ma, b = mb; a <= 2000 && b <= 2000; a += ma, b += mb) {
			ans = min(ans, dp[a][b]);
		}
		cout << (ans < INF ? ans : -1) << endl;
	}
	return 0;
}


Measured memory_bytes: 18048
N = int(input())
A = list(map(int, input().split()))

ans = 0
while True:
    add = 0
    B = [0] * N
    cut = [0] * N
    for i, a in enumerate(A):
        d, m = divmod(a, N)
        B[i] = m
        cut[i] = d
        add += d

    for i, c in enumerate(cut):
        B[i] += add - c

    if not add:
        break

    ans += add
    A = B

print(ans)

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


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	for (int i = a; i <= b * a; i += a) {
		if (i % b == c) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}


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

using namespace std;

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

    string t = s;
    reverse(t.begin(), t.end());

    bool ans = true;
    if (s != t) {
        ans = false;
    }

    int n = s.length();
    string s1 = s.substr(0, n / 2);
    string t1 = s1;
    reverse(t1.begin(), t1.end());
    if (s1 != t1) {
        ans = false;
    }

    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

int power(int n, int x){
	int temp = x, pw = 0;
	while(n/temp > 0){
		pw += n/temp;
		temp *= x;
	}	
	return pw;
}

int solve(int n){

	int lol = n/2;
	return min(power(lol, 2) + n/2, power(lol, 5));
}

signed main(){
	int n;
	cin>>n;
	if(n%2)
		cout<<0;
	else
		cout<<solve(n);
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

type edge struct {
	to, weight int
}

type node struct {
	dist     int
	visited  bool
	edgeList []edge
}

type graph []node

func DFS(G *graph, K int) {
	(*G)[K].visited = true
	for _, ed := range (*G)[K].edgeList {
		if !(*G)[ed.to].visited {
			(*G)[ed.to].dist = (*G)[K].dist + ed.weight
			DFS(G, ed.to)
		}
	}
}

func main() {
	sc.Split(bufio.ScanWords)

	N := scanInt()
	G := make(graph, N)
	for i := 0; i < N; i++ {
		G[i].edgeList = make([]edge, 0)
	}

	for i := 0; i < N-1; i++ {
		a, b, c := scanInt()-1, scanInt()-1, scanInt()
		G[a].edgeList = append(G[a].edgeList, edge{to: b, weight: c})
		G[b].edgeList = append(G[b].edgeList, edge{to: a, weight: c})
	}

	Q, K := scanInt(), scanInt()-1
	DFS(&G, K)

	for i := 0; i < Q; i++ {
		x, y := scanInt()-1, scanInt()-1
		ans := G[x].dist + G[y].dist
		fmt.Println(ans)
	}
}


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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;++i) cin>>a[i];
    bool dp[100005];
    for(int i=0;i<=k;++i) dp[i]=false;
    for(int i=0;i<=k;++i){
        for(int j=0;j<n;++j){
            if(i-a[j]>=0) dp[i]|=!dp[i-a[j]];
        }
    }

    if(dp[k]) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}

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

using namespace std;

typedef long long ll;

int main(){
  ll n,x;
  cin>>n>>x;
  ll ans=0;
  ll a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  
  for(int i=0;i<n-1;i++){
    ll t=a[i]+a[i+1];
    if(t>x){
      ll diff=t-x;
      if(a[i+1]<diff){
 		a[i+1]=0;
      }else{
        a[i+1]=a[i+1]-diff;
      }
      ans+=diff;
    }
      
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4400
#include <iostream>
#include <cmath>

namespace Geometry {
  using Float = long double;
  using Real = long long;
  constexpr Float eps = 1e-9;

  namespace Plane {
    struct Vec {
      Real x, y;
      constexpr Vec() : x(0), y(0) {}
      constexpr Vec(Real k) : x(k), y(k) {}
      constexpr Vec(Real x, Real y) : x(x), y(y) {}
      static constexpr Real dot(Vec v, Vec w) { return v.x*w.x + v.y*w.y; }
      static constexpr Real cross(Vec v, Vec w) { return v.x*w.y - v.y*w.x; }
      constexpr Real norm2() const { return x*x+y*y; }
      Float norm() const { return std::sqrt(x*x+y*y); }
      Float arg() const { return std::atan2(x, y); }
      constexpr Vec& operator+=(Vec const& v) { x += v.x; y += v.y; return *this; }
      constexpr Vec& operator-=(Vec const& v) { x -= v.x; y -= v.y; return *this; }
      constexpr Vec& operator*=(Real const& k) { x *= k; y *= k; return *this; }
      constexpr Vec& operator*=(Vec const& v) { x *= v.x; y *= v.y; return *this; }
      constexpr Vec operator-() const { return Vec(-x, -y); }
      friend constexpr Vec operator+(Vec const& v, Vec const& w) { return Vec(v) += w; }
      friend constexpr Vec operator-(Vec const& v, Vec const& w) { return Vec(v) -= w; }
      friend constexpr Vec operator*(Real const& k, Vec const& v) { return Vec(v) *= k; }
      friend constexpr Vec operator*(Vec const& v, Vec const& w) { return Vec(v) *= w; }
      constexpr int ort() const { // orthant
        // if(abs(x) < eps && abs(y) < eps) return 0;
        if(  x>0  && !(y<0)) return 1; //  x>0 && y>=0
        if(!(x>0) &&   y>0 ) return 2; // x<=0 &&  y>0
        if(  x<0  && !(y>0)) return 3; //  x<0 && y<=0
        if(!(x<0) &&   y<0 ) return 4; // x>=0 &&  y<0
        return 5;
      }
      friend constexpr bool operator<(Vec const& a, Vec const& b) {
        int ao = a.ort() , bo = b.ort();
        if(ao != bo) return ao < bo;
        return 0 < cross(a, b);
      }
      friend std::istream& operator>>(std::istream& is, Vec& v) noexcept { is >> v.x >> v.y; return is; }
      friend std::ostream& operator<<(std::ostream& os, Vec const& v) noexcept { os << '(' << v.x << ',' << v.y << ')'; return os; }
    };

  }
}
using Geometry::Plane::Vec;

#include <iomanip>
#include <algorithm>
#include <vector>

signed main() {
  using namespace std;

  // abc139_f
  int n;
  cin >> n;

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

  sort(v.begin(), v.end());
  for(int i=0; i<n; ++i) cerr << v[i] << ' ';
  cerr << endl;

  Vec ans{};
  for(int l=0; l<n; ++l) {
    Vec now{};
    for(int r=l, i=0; i<n; ++r, ++i) {
      now += v[r %= n];
      if(ans.norm2() < now.norm2()) ans = now;
    }
  }

  cout << fixed << setprecision(15) << ans.norm() << endl;

  return 0;
}

Measured memory_bytes: 384
program main
  implicit none
  integer :: n, i, j, res
  integer, allocatable :: l(:)
  read (*, *) n
  allocate (l(n))
  read (*, *) l(:)
  res = 0
  call quicksort(l)
  do i = 1, n - 2
    do j = i + 2, n
      res = res + count_larger(l(i + 1:j - 1), l(j) - l(i))
    end do
  end do
  write (*, "(i0)") res
  contains

  integer function count_larger(ary, thres)
    integer, intent(in) :: ary(:), thres
    integer :: n, ma, mi, md, i
    n = size(ary)
    ma = n + 1  ! always larger than thres
    mi = 0  ! no more than thres
    do i = 1, 100
      md = mi + (ma - mi) / 2
      if (ary(md) > thres) then
        ma = md
      else
        mi = md
      end if
      if (ma - mi <= 1) exit
    end do
    count_larger = n - (ma - 1)
  end function count_larger

  recursive subroutine quicksort(a)
    integer, intent(inout) :: a(:)
    integer :: pivot, i, j, k, tmp, n
    real(4) :: r
    n = size(a)
    if (n <= 1) return
    i = 1
    j = n
    call random_number(r)
    k = 1 + floor(r * n)
    k = max(1, min(k, n))
    pivot = a(k)
    do
      do while (.not. pivot <= a(i))
        i = i + 1
      end do
      do while (.not. a(j) <= pivot)
        j = j - 1
      end do
      if (i >= j) exit
      tmp = a(i)
      a(i) = a(j)
      a(j) = tmp
      i = i + 1
      j = j - 1
    end do
    call quicksort(a(1:i - 1))
    call quicksort(a(j + 1:n))
  end subroutine quicksort
end program main


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;


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

	cin >> N >> M >> K;
	vector<vector<long double>>dp(N, vector<long double>(K + 1, -MOD));
	dp[0][0] = 0;
	vector<vector<int>>length(N, vector<int>(N));
	vector<vector<int>>gain(N, vector<int>(N));
	for (int i = 0; i < M; i++) {
		cin >> L >> R >> H >> W;
		L--, R--;
		length[L][R] = H;
		length[R][L] = H;
		gain[R][L] = W;
		gain[L][R] = W;
	}
	vector<long double>stay(N);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (length[i][j]) {
				stay[i] = max(stay[i], (long double)1 * gain[i][j] / length[i][j]);
			}
		}
	}
	for (int i = 0; i < K; i++) {
		for (int j = 0; j < N; j++) {
			dp[j][i + 1] = max(dp[j][i + 1], dp[j][i] + stay[j]);
			for (int k = 0; k < N; k++) {
				if (length[j][k] && i + length[j][k] <= K) {
					dp[k][i + length[j][k]] = max(dp[k][i + length[j][k]], dp[j][i] + gain[j][k]);
				}
			}
		}
	}
	cout << setprecision(20) << dp[0].back() << endl;
}


Measured memory_bytes: 6404
#include<stdio.h>
 
 
typedef struct{
  int id;
  int left;
  int right;
  int p;
  int s;
  int dep;
  int deg;
  int h;
}Tree;
 
Tree A[25];
 
void preParse(int);
void inParse(int);
void postParse(int);
 
 
int main(){
  int in,n,i,s1,s2;
  int pa,pc,hc,he,box;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    A[i].p=-1;
    A[i].s=-1;
    A[i].deg=0;
    A[i].h=0;
  }
  
  for(i=0;i<n;i++){
    scanf("%d",&in);
    A[in].id=in;
    scanf("%d %d",&A[in].left,&A[in].right);
    if(A[in].left!=-1&&A[in].right!=-1){
      A[in].deg=2;
    }else if(A[in].left!=-1||A[in].right!=-1){
      A[in].deg=1;
    }
  
    s1=A[in].left;
    s2=A[in].right;
    A[s1].p=A[in].id;
    A[s2].p=A[in].id;
    A[s1].s=s2;
    A[s2].s=s1;
  }
  
  for(i=0;i<n;i++){
    if(A[i].p==-1){
      A[i].dep=0;
    }else{
      pa=A[i].p;
      pc=1;
      
      while(A[pa].p!=-1){
    pc++;
    pa=A[pa].p;
      }
      A[i].dep=pc;
    }
  }
  
  
  
  for(i=0;i<n;i++){
    if(A[i].deg==0){
      hc=0;
      A[i].h=hc;
      pa=A[i].p;
  
      while(pa!=-1){
    hc++;
    if(A[pa].h<=hc){
      A[pa].h=hc;
      pa=A[pa].p;
    }
      }
    }
  }
 
  for(i=0;i<n;i++){
    if(A[i].p==-1){
      box = i;
      break;
    }
  }
   
  printf("Preorder\n");
  preParse(box);
  printf("\n");
 
  printf("Inorder\n");
  inParse(box);
  printf("\n");
 
  printf("Postorder\n");
  postParse(box);
  printf("\n");
 
   
  return 0;
}
 
void preParse(int u){
  if(u == -1)return;
  printf(" %d",u);
  preParse(A[u].left);
  preParse(A[u].right);
}
 
void inParse(int u){
  if(u==-1)return;
  inParse(A[u].left);
  printf(" %d",u);
  inParse(A[u].right);
}
 
void postParse(int u){
  if(u==-1)return;
  postParse(A[u].left);
  postParse(A[u].right);
  printf(" %d",u);
}

Measured memory_bytes: 1804
#include<bits/stdc++.h> 
typedef double ll;
#define pb push_back
#define MP make_pair

using namespace std;
int maxSum(int arr[], int n, int k) 
{ 
    // k must be greater 
    if (n < k) 
    { 
       cout << "Invalid"; 
       return -1; 
    } 
  
    // Compute sum of first window of size k 
    int res = 0; 
    for (int i=0; i<k; i++) 
       res += arr[i]; 
   
    int curr_sum = res; 
    int p=0;
    for (int i=k; i<n; i++) 
    { 
       curr_sum += arr[i] - arr[i-k];
       if(curr_sum>res)
       {
          p=i-k+1; 
       }
       res = max(res, curr_sum); 
    } 
  
    return p; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int p=maxSum(a, n, k);
   //cout<<p<<" ";
    double s=0,e=0;
     for(int i=p;i<p+k;i++)
    {
        int m=a[i];
        e=(double)(m+1);
        e=(double)e/2;
        s=(double)s+e;
        
    }
  cout<<fixed<<setprecision(12)<<s;
   
    

    
     
    
     return 0;
}


Measured memory_bytes: 4540
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	ll a,v,b,w,t; cin>>a>>v>>b>>w>>t;
	//cout<<1;
	ll k=abs(a-b);
	ll n=0,m=0;
	n+=(t*v);
	m+=(t*w)+k;
	if(n>=m) cout<<"YES";
	else cout<<"NO";
	//cout<<"n:"<<n<<" m:"<<m;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int a, b, k;
    cin >> a >> b >> k;

    if(k > a) {
        k -= a;
        a = 0;       
    } else {
        a -= k;
        k = 0;
    }
    b = max(0, b-k);

    cout << a << " " << b << endl;
    
    return 0;
}

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

typedef long long int ll;
ll n, m, h[100007], a, b;
bool ans[100007];

int main() {
    cin >> n >> m;
    for(ll i = 1; i <= n; ++i) cin >> h[i];
    for(ll i = 0; i < m; ++i) {
        cin >> a >> b;
        if(h[a] > h[b]) ans[b] = 1;
        if(h[b] > h[a]) ans[a] = 1;
        if(h[b] == h[a]) ans[a] = ans[b] = 1;
    }

    ll res = 0;
    for(ll i = 1; i <= n; ++i) {
        if(!ans[i]) res++;
    }

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

Measured memory_bytes: 4476
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
typedef vector<int> ivec;
typedef vector<string> svec;

const int MOD=1000000007;

int a[100010];
int main(){
	int n,m;
	cin>>n>>m;
	if(n%2==1)
	{
		for(int i=1;i<=m;i++)
		{
			cout<<i<<" "<<n+1-i<<"\n";
		}
	}
	else
	{
		for(int i=1;i<=m;i++)
		{
			if(i>=n/4+1)cout<<i<<" "<<n-i<<"\n";
			else cout<<i<<" "<<n+1-i<<"\n";
		}
	}
	return 0;
}

Measured memory_bytes: 3636
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,Z,W;
  cin >> N >> Z >> W;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  if(N == 1){
    cout << abs(A[0]-W) << "\n";
    return 0;
  }
  cout << max(abs(A[N-1]-W),abs(A[N-2]-A[N-1])) << "\n";
  return 0;
}

Measured memory_bytes: 3576
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// std::ios::sync_with_stdio(false);

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 2e5+5;
int A[maxn],cnt[maxn],cover[maxn];

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    int N,M;
    while (cin >> N >> M) {
        memset(cnt,0,sizeof(cnt));
        memset(cover,0,sizeof(cover));
        FOR(i,1,N+1) {
            cin >> A[i]; cnt[A[i]]++;
        }
        FOR(i,1,N+1) FOR(x,i-cnt[i],i)
            cover[max(0,x)]++;
        int ans = 0;
        FOR(x,0,N) if (!cover[x])
            ans++;
        FOR(_,0,M) {
            int x,y; cin >> x >> y;
            const int i = max(0, A[x] - cnt[A[x]]);
            if (cover[i] == 1)
                ans++;
            cover[i]--; cnt[A[x]]--; cnt[y]++; A[x] = y;
            const int j = max(0, y - cnt[y]);
            if (cover[j] == 0)
                ans--;
            cover[j]++;
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3840
#include <iostream>
using namespace std;
int main()
{
	int mx=0,mn=999999999;
	int n=5;
	while(n--)
	{
		int a;
		cin>>a;
		mn=min(a,mn);
		mx=max(a,mx);
	}
	int k;
	cin>>k;
	if(mx-mn>k)
	{
		cout<<":("<<endl;
	}
	else
	{
		cout<<"Yay!"<<endl;
	}
}

Measured memory_bytes: 256
import bisect


def get_next_int():
    return int(float(input()))


def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_str():
    return input()


def get_next_strs(delim=" "):
    return tuple(input().split(delim))


def get_next_by_types(*value_types, delim=" "):
    return tuple([t(x) for t, x in zip(value_types, input().split(delim))])

def get_comb(num, sort_numbers):
    index = bisect.bisect(sort_numbers, int(num/2))
    left = sort_numbers[index-1]
    right = sort_numbers[index]
    choose_num = left if abs(num/2 - left) < abs(num/2 - right) or right == num else right
    return choose_num

def solve():
    N = get_next_int()
    numbers = get_next_ints()
    max_num, max_choose = 0, -1
    sort_numbers = sorted(numbers)
    for num in sort_numbers[int(len(sort_numbers)/2):][::-1]:
        choose = get_comb(num, sort_numbers)
        if choose > max_choose:
            max_num = num
            max_choose = choose
    print(max_num, max_choose)



solve()

Measured memory_bytes: 14348
'use strict';

function main(inputs) {
  let i = 0;
  let input = inputs.split('\n');
  let numbers = input[1].split(' ').map(num => parseInt(num, 10));
  console.log(count_up(numbers, i));
}

function count_up(numbers, i) {
  let results = [];
  for (let k = 0, len = numbers.length; k < len; k++) {
    if (numbers[k] % 2 === 0) {
      results.push(numbers[k] / 2);
    } else {
      return i;
    }
  }
  i++;
  return count_up(results, i);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7500
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s:String = read();
    let mut t:String = read();
    t.pop();
    if s == t {
        println!("Yes");
    } else {
        println!("No");
    }
}

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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0; i<n; i++)cin>>a.at(i);

  set<int> fl;
  int free=0;
  for(int i=0; i<n; i++){
    if(a.at(i)<400)fl.insert(0);
    else if(a.at(i)<800)fl.insert(1);
    else if(a.at(i)<1200)fl.insert(2);
    else if(a.at(i)<1600)fl.insert(3);
    else if(a.at(i)<2000)fl.insert(4);
    else if(a.at(i)<2400)fl.insert(5);
    else if(a.at(i)<2800)fl.insert(6);
    else if(a.at(i)<3200)fl.insert(7);
    else free++;
  }

  int x=fl.size();
  cout<<max(x, 1)<<" "<<x+free<<endl;
}

Measured memory_bytes: 256
import sys
import math
import collections
from collections import deque
x = int(input())
#n, s = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))

a = math.floor(x/500)
b = x % 500
c = math.floor(b/5)

print(1000*a + 5*c)




Measured memory_bytes: 3440
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		double[] d = new double[6];
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			for (int i = 0; i < d.length; i++) {
				d[i] = sc.nextDouble();
			}
			double dv = d[0] * d[4] - d[1] * d[3];
			if (Double.compare(dv, 0.0f) == 0) {
				continue;
			}
			double[][] m1 = { { d[4] / dv, -d[1] / dv },
					{ -d[3] / dv, d[0] / dv } };
			double[][] m2 = { { d[2] }, { d[5] } };
			double x = m1[0][0] * m2[0][0] + m1[0][1] * m2[1][0];
			double y = m1[1][0] * m2[0][0] + m1[1][1] * m2[1][0];
			System.out.println(String.format("%.3f %.3f", x, y));
		}
	}
}

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

struct RollingHash {
  int Mod, Base;
  vector<int> pow;
  vector<vector<int>> hash;
  // mod : 1e9 + 9,base : 1007
  RollingHash(const int len = 3000000,
              const int mod = (int)(1e9 + 7),
              const int base = 1009) {
    Mod = mod;
    Base = base;
    pow.assign(len + 1, 0);
    pow[0] = 1;
    for(int i = 1; i <= len; ++i)
      pow[i] = (long long)pow[i - 1] * Base % Mod;
  }
  void add(const string &s) {
    int id = hash.size();
    hash.push_back(vector<int>((int)s.size() + 1, 0));
    sethash(id, s);
  }
  void changestr(const int &id, const string &s) {
    assert(id < (int)hash.size());
    sethash(id, s);
  }
  void sethash(const int &id, const string &s) {
    int len = s.size();
    for(int i = 0; i < len; ++i) {
      hash[id][i + 1] = (long long)hash[id][i] * Base % Mod;
      hash[id][i + 1] += s[i];
      if(hash[id][i + 1] >= Mod) hash[id][i + 1] -= Mod;
    }
  }
  // [l,r),0-indexed
  long long calchash(const int &id, const int &l,
                     const int &r) const {
    assert(r >= l);
    long long res = hash[id][r];
    res -= (long long)hash[id][l] * pow[r - l] % Mod;
    if(res < 0) res += Mod;
    if(res >= Mod) res -= Mod;
    return res;
  }
  inline bool issame(const int &idl, const int &ll,
                     const int &lr, const int &idr,
                     const int &rl, const int &rr) const {
    return calchash(idl, ll, lr) == calchash(idr, rl, rr);
  }
};

long long n;
vector<long long> a, b;
RollingHash rh;

void solve();

int main() {
  cin >> n;
  a.resize(n);
  b.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(int i = 0; i < n; ++i) cin >> b[i];
  solve();
  return 0;
}

void solve() {
  for(int i = 0; i < 30; ++i) {
    string s, t, r;
    for(int j = 0; j < n; ++j) {
      s += '0' + (a[j] >> i & 1);
      t += '0' + 1 - (a[j] >> i & 1);
      r += '0' + (b[j] >> i & 1);
    }
    s += s;
    t += t;
    r += r;
    rh.add(s);
    rh.add(t);
    rh.add(r);
  }
  for(int i = 0; i < n; ++i) {
    bool ch = 1;
    for(int j = 0; j < 30; ++j)
      if(!rh.issame(j * 3, i, i + n, 2 + j * 3, 0, n) &&
         !rh.issame(1 + j * 3, i, i + n, 2 + j * 3, 0, n))
        ch = 0;
    if(ch) cout << i << " " << (a[i] ^ b[0]) << endl;
  }
}


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

int main() {
    int K, N;
    string S;
    cin >> N >> S >> K;
    
    char c = S[K - 1];
    for (char& cc: S) {
        if (cc != c) {
            cc = '*';
        }
    }

    cout << S << endl;

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int h, a, ans;
int main() {
	cin >> h >> a;
	while (h > 0) {
		ans++;
		h -= a;
	}
	cout << ans << endl;
	
	return 0;
}

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e9
#define MOD 1000000007

int main()
{

    ll n, m;;
    cin >> n >> m;
    vector<ll> v;
    for(ll i = 0; i < m; i++)
    {

        ll x;
        cin >> x;
        v.pb(x);
    }
    vector<ll> d;
    sort(v.begin(), v.end());
    //aise;
    for(ll i = 0; i  < v.size()-1; i++)
    {

        ll y = v[i+1]-v[i];
        d.pb(y);
    }
    //aise;
    sort(d.begin(), d.end());
    ll ans = v[m-1]-v[0];
    sort(d.begin(), d.end());
    reverse(d.begin(), d.end());
    for(ll i = 0; i < min(m-1, n-1); i++) ans-=d[i];
    cout << ans;
}


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

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

const long long INF = 1LL << 60;
long long dp[100010];
int n, k;
int h[100010];
int main()
{
	cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> h[i];
	for (auto &x : dp) x = INF;
	dp[0] = 0;
	for (int i = 1; i < n; i++){
		for (int j = 1; j <= k and i-j >= 0; j++){
			chmin(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
		}
	
	}
	cout << dp[n-1] << endl;
}



Measured memory_bytes: 1408
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

#[allow(unused_macros)]
macro_rules! chmin {
    ( $ x : expr , $ y : expr ) => { if $ x > $ y { $ x = $ y ; true } else { false } };
}

fn main() {
    input! {
        n: usize, k: usize,
        x: [i64; n]
    }

    let mut xm = x;
    xm.sort();
    let mut ret = 1i64 << 60;
    for i in 0..n-k+1 {
        let ln = xm[i+k-1]-xm[i];
        chmin!(ret, ln + xm[i+k-1].abs());
        chmin!(ret, ln + xm[i].abs());
    }
    println!("{}", ret);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i, x, n) for(int i = x; i < n; i++)
#define repr(i, x, n) for(int i = x; i > n; i--)
#define pii pair<int,int>
#define ll long long
const long long iinf = 1e18;
const int inf = 1e9;
const int MOD = (1e6+3);
int dir4[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};
int knight[8][2] = {{2,1},{2,-1},{-2,1},{-2,-1},{1,2},{-1,2},{1,-2},{-1,-2}};

using namespace std;

void solve()
{
    int x, n;
    int a[102] = {0};
    cin >> x >> n;
    for(int i = 1; i <= n; i++){
        int y; cin >> y;
        a[y] = 1;
    }
    int min1 , min2;
    for(int i = x; ;i++){
        if(a[i] == 0){
            min1 = i;
            break;
        }
    }
    for(int i = x; ; i--){
        if(a[i] == 0){
            min2 = i;
            break;
        }
    }
    if(abs(x-min2) < abs(x-min1)) cout << min2;
    else if(abs(x-min1) < abs(x-min2)) cout << min1;
    else cout << min2;
}
//new line is printed in the main

int main()
{
    int t = 1;
        // cin >> t; // comment out if no test case is required
    // int i = 1;
    while(t--){
        //cout << "Case " << i++ << ": ";
        solve();
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 3608