akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define ji -
using namespace std;
int n,m;
long long te,ans,w[150],v[150],a[4][120],at[4],s[4][120]; 
bool cmp(int a,int b){
	return a>b;
}
int main(){
	scanf("%d%d",&n,&m);
	fo(i,1,n) scanf("%lld%lld",&w[i],&v[i]);
	fo(i,1,n) a[w[i] ji w[1]][++at[w[i] ji w[1]]]=v[i];
	fo(i,0,3) sort(a[i]+1,a[i]+at[i]+1,cmp);
	//fo(i,0,3)
	//	fo(j,1,at[i])
	//		printf("%d %d:%d\n",i,j,a[i][j]); 
	fo(i,0,3)
		fo(j,1,at[i])//2..at[i]
			s[i][j]=s[i][j ji 1]+a[i][j];
	fo(i,0,at[0])
		fo(j,0,at[1])
			fo(k,0,at[2])
				fo(l,0,at[3]){
					te=i*w[1]+j*w[1]+j+k*w[1]+k+k+l*w[1]+l+l+l;
					if (te>m) break;
					te=s[0][i]+s[1][j]+s[2][k]+s[3][l];
					if (te>ans) ans=te;
				}
	printf("%lld\n",ans); 
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main()
{
	char a[10];
	const char *check = "1";
	cin >> a;
	int ans = 0;
	for (int i = 0; i < 10; i++) {
		if (a[i] == *check) {
			ans++;
		}
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int p[100][100], q[100][100], H, W, K;
int chain(){
    int score = 0, cnt = 0;
    while (true)
    {
        int r = 0;
        for (int i = 0; i < H; i++)
        {
            int L = 0;
            for (int j = 0; j <= W; j++)
            {
                if(q[i][j] != q[i][L] || q[i][j] == 11){
                    if(j - L >= K){
                        for(int k = L; k < j; k++){r += q[i][k]; q[i][k] = 11;}
                    }
                    L = j;
                }
            }
        }
        for(int i = 0; i < W; i++){
            vector<int> W;
            for(int j = H - 1; j >= 0; j--){
                if(q[j][i] <= 9) W.push_back(q[j][i]);
            }
            for(int j = H - 1; j >= 0; j--){q[j][i] = 11;}
            for(int j = 0; j < W.size(); j++){q[H - 1 - j][i] = W[j];}
        }
        if(r == 0) return score;
        score += r * (1 << cnt); cnt++;
    }
}
int main() {
    cin >> H >> W >> K;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            char c; cin >> c;
            if(c == '.')p[i][j] = 11;
            else {p[i][j] = c - '0';}
        }
    }
    int maxn = 0;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if(p[i][j] == 11) continue;
            for (int k = 0; k < H; k++)
            {
                for (int l = 0; l < W; l++)
                {
                    q[k][l] = p[k][l];
                }
            }
            q[i][j] = 11; vector<int> V;
            for(int k = H - 1; k >= 0; k--){if(q[k][j] <= 9) V.push_back(q[k][j]);}
            for(int k = H - 1; k >= 0; k--){ q[k][j] = 11;}
            for(int k = 0; k < V.size(); k++) { q[H-1-k][j] = V[k];}
            maxn = max(maxn, chain());
        }
    }
    cout << maxn << endl;
}

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

using namespace std;
using ll = long long;

int main(){
cin.tie(0);
int a,b;
  
cin >>a>>b;
if(b%2==0&&b>=a*2&&b<=a*4)cout <<"Yes";
  else cout <<"No";

return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define input freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
ll mat[55][55];
ll temp[55][55];
ll n;
auto addmod(ll a,ll b)
{
	ll res=(a%mod+b%mod)%mod;
	if(res<0)
		res+=mod;
	return res%mod;
}
auto mulmod(ll a,ll b)
{
	ll res=(a%mod * b%mod)%mod;
	if(res<0)
		res+=mod;
	return res%mod;
}
void multiply(ll A[55][55],ll B[55][55])
{
	ll c[55][55];
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<n;j++)
		{
			c[i][j]=0;
			for(ll k=0;k<n;k++)
			{
				c[i][j]=addmod(c[i][j],mulmod(A[i][k],B[k][j]));
			}
		}
	}
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<n;j++)
			A[i][j]=c[i][j];
	}
}

int main(){
	fast;
	// input;
	ll k;
	cin>>n>>k;
	for(ll i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{

			cin>>mat[i][j];
			// mat[i][j];
			if(i==j)
				temp[i][j]=1;
			else
				temp[i][j]=0;
		}
	}
	
	while(k)
	{
		if(k&1)
		{
			multiply(temp,mat);
		}
		k>>=1;
		multiply(mat,mat);
	}
	ll res=0;

	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<n;j++)
		{
			res=addmod(res,temp[i][j]);
		}
	}
	cout<<res%mod<<endl;
}

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

int main(){
  int64_t n;
  cin >> n;
  //n=mk+k n=(m+1)k i = k+1
  queue<int64_t> que;
  for(int i=1;i<=sqrt(n);i++){
    if(n%i==0){
      if(i*i!=n){
        que.push(i);
        que.push(n/i);
      }else{
        que.push(i);
      }
    }
  }
  int64_t sum = 0;
  while(!que.empty()){
    int64_t a = que.front();
    que.pop();
    if((n/a)-1>a){
      sum += (n/a)-1;
      //cout << n/a-1 << ",";
    }
  }
        
        
  cout << sum << endl;
  
        
        
      
}


Measured memory_bytes: 256
#include <stdio.h>
int s(int x) {
    int sum = x % 10;
    while (x != 0) {
        x /= 10;
        sum += x % 10;
    }
    return sum;
}
int main() {
    int n;
    scanf("%d", &n);
    printf("%s\n", n % s(n) == 0 ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){ T x; cin >> x; return (x); }
template<typename T=int,typename C=vector<T>>
C vecin(int N){ C x(N);REP(i,N){ x[i]=in<T>(); }return move(x); }

void vout(){ cout << endl; }
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){ cout << ' ' << h;vout(forward<Tail>(t)...); }
void out(){ cout << endl; }
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){ cout << h;vout(forward<Tail>(t)...); }

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

	int A=in(),B=in(),M=in();
	auto C=vecin(A);
	auto D=vecin(B);
	int minP = *min_element(ALL(C)) + *min_element(ALL(D));

	REP(i,M){
		int x=in()-1,y=in()-1,z=in();
		minP = min(minP,C[x]+D[y]-z);
	}
	out(minP);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 998244353;
const int RT = 3;

int power(int x, int t)
{
	int ret = 1;
	while(t > 0) {
		if(t & 1) ret = 1LL * ret * x % MOD;
		x = 1LL * x * x % MOD;
		t >>= 1;
	}
	return ret;
}

void fft(int from[], int to[], int tp)
{
	int cur = 0;
	rep(i, 16384) {
		to[i] = from[cur];
		for(int j = 13; j >= 0; j --) {
			cur ^= 1 << j;
			if(cur >> j & 1) break;
		}
	}
	
	for(int d = 2; d <= 16384; d <<= 1) {
		int rt = power(RT, MOD - 1 + (MOD - 1) / d * tp);
		for(int i = 0; i < 16384; i += d) {
			int cr = 1;
			for(int j = i; j < i + (d >> 1); j ++) {
				int ev = to[j], od = 1LL * to[j + (d >> 1)] * cr % MOD;
				to[j] = (ev + od) % MOD;
				to[j + (d >> 1)] = (ev - od + MOD) % MOD;
				cr = 1LL * cr * rt % MOD;
			}
		}
	}
	
	if(tp == -1) {
		int invn = power(16384, MOD - 2);
		rep(i, 16384) to[i] = 1LL * to[i] * invn % MOD;
	}
}

void prod(int u[], int v[], int w[])
{
	fft(u, w, 1);
	fft(v, u, 1);
	rep(i, 16384) v[i] = 1LL * u[i] * w[i] % MOD;
	fft(v, w, -1);
}

int n, m;
int fac[8005], ifac[8005];
int dp[8005];

int cu[16384], cv[16384], cw[16384];
void trans_dp()
{
	memset(cu, 0, sizeof(cu));
	memset(cv, 0, sizeof(cv));
	for(int i = 0; i <= n; i ++) cu[i] = 1LL * dp[i] * ifac[i] % MOD;
	for(int i = 0; i <= n; i ++) cv[i] = ifac[i + 2];
	prod(cu, cv, cw);
	for(int i = 0; i <= n; i ++) cw[i] = 1LL * cw[i] * fac[i + 2] % MOD;
	for(int i = 0; i <= n; i ++) dp[i] = (cw[i] - 1LL * dp[i] * i % MOD + MOD) % MOD;
}

int main()
{
	fac[0] = 1;
	rep1(i, 8002) fac[i] = 1LL * fac[i - 1] * i % MOD;
	ifac[8002] = power(fac[8002], MOD - 2);
	for(int i = 8002; i >= 1; i --) ifac[i - 1] = 1LL * ifac[i] * i % MOD;
	
	scanf("%d%d", &n, &m);
	dp[0] = 1;
	
	rep(i, m) trans_dp();
	
	int ans = 0;
	for(int i = 0; i <= n; i ++) ans = (ans + 1LL * ifac[i] * ifac[n - i] % MOD * dp[i]) % MOD;
	ans = 1LL * ans * fac[n] % MOD;
	printf("%d\n", ans);
	return 0;
}

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

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

    if( A.size()>B.size() ){
        cout << "GREATER" << endl;
        return 0;
    }else if( A.size()<B.size() ){
        cout << "LESS" << endl;
        return 0;        
    }

    for(int i=0; i<A.size(); i++ ){
        int a,b;
        a= (int) A[i]-'0';
        b= (int) B[i]-'0';
        if( a>b ){
            cout << "GREATER" << endl;
            return 0;
        }else if(a<b){
            cout << "LESS" << endl;
            return 0;
        }
    }

    cout << "EQUAL" << endl;

    return 0;
}

Measured memory_bytes: 256
def solve():
    l,r = map(int, input().split())
    if r-l<2019:
        arr = []
        for i in range(l,r):
            for j in range(i+1,r+1):
                if i*j%2019 == 0:
                    return 0
                arr.append(i*j%2019)
        return min(arr)
    else:
        return 0


if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 6808
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 1> { using type = vector<T>; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N;
  while (cin >> N) {
    int M = 1 << N;
    vector<int> A(M);
    for (int i = 0; i < M; i++) cin >> A[i];
    vec<int, 2> dp(M);
    dp[0] = {0};
    for (int i = 1; i < M; i++) {
      vector<int> cand = {i};
      for (int j = 0; j < N; j++) {
        if ((i >> j) & 1) {
          for (int x : dp[i ^ (1 << j)]) {
            cand.push_back(x);
          }
        }
      }
      sort(cand.begin(), cand.end());
      cand.erase(unique(cand.begin(), cand.end()), cand.end());
      sort(cand.begin(), cand.end(), [&](int a, int b) { return A[a] > A[b]; });
      if (cand.size() > 2) cand.resize(2);
      dp[i] = cand;
    }
    int mx = 0;
    for (int i = 1; i < M; i++) {
      mx = max(mx, A[dp[i][0]] + A[dp[i][1]]);
      cout << mx << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 18688
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

const int64_t MOD = 1000000007;

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

  int n, m;
  cin >> n >> m;
  std::unordered_set<int> broken;
  for (int i = 0; i < m; i++) {
    int m1;
    cin >> m1;
    broken.insert(m1);
  }

  int64_t dp[100001] = {};
  dp[0]              = 1;
  for (int step = 1; step <= n; step++) {
    if (broken.find(step) != broken.end()) {
      dp[step] = 0;
    } else {
      if (step == 1) {
        dp[step] = dp[step - 1];
      } else {
        dp[step] = dp[step - 1] + dp[step - 2];
      }

      // cerr << dp[step] << endl;
      dp[step] %= MOD;
    }

    // cerr << "\033[93m" << step << " " << dp[step] << "\033[m" << endl;
  }

  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 5024
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main{

	private static final int mod =(int)1e9+7;
	public static void main(String[] args) throws Exception  {
		Scanner  sc=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
	char a[]= {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	int n=sc.nextInt();
	String s[]=new String[n];
	for(int i=0;i<n;i++) {
		s[i]=sc.next();
	}
	String ans="";
	for(char alp:a) {
	
		int ans1=100;
		for(int i=0;i<n;i++) {
			int count=0;
			for(char x:s[i].toCharArray()) {
				if(x==alp) {
					count++;
				}
			}
			ans1=Math.min(ans1,count);
		}
		for(int i=0;i<ans1;i++) {
			ans+=alp;
		}
	}
	out.println(ans);
	out.flush();
	
}
}

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

using namespace std;
static const int MAX = 200000;

int main(){
		int R[MAX],n;
		
		cin>>n;
		for(int i=0;i<n;i++){cin>>R[i];}

		int maxv=-2000000000;	//???????°?????????°?????£??\
		int minv=R[0];

		for(int i=1;i<n;i++){
				maxv=max(maxv,R[i]-minv);
				minv=min(minv,R[i]);
				}

		cout<<maxv<<endl;

return 0;
		}

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

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

    int N, A, B;
    cin >> N;

    if (N == 1) {
        cout << "Hello World" << '\n';
    } else {
        cin >> A >> B;
        cout << A + B << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int r,g,b,a;
  cin>>r>>g>>b;
  a=(100*r)+(10*g)+b;
  if(a%4==0){
    cout<<"YES"<<"\n";
  }
  else{
    cout<<"NO"<<"\n";
  }
  
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
#define ALL(x) x.begin(),x.end()
#define P pair<int,int>
#define mod 1000000007

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  char board[h][w];
  rep(i, h) {
    rep(j, w) {
      cin >> board[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < 1<<h; i++) {
    for (int j = 0; j < 1<<w; j++) {
      int redcount = 0;
      for (int k = 0; k < h; k++) {
        if (i>>k & 1) continue;
        for (int l = 0; l < w; l++) {
          if (j>>l & 1) continue;
          if (board[k][l] == '#') redcount++;
        }
      }
      if (redcount == k) ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;

long long mpow(long long a, long long n)
{
	long long ret = 1;
	while (n) {
		if (n&1) ret = ret*a % MOD;
		a = a*a % MOD;
		n >>= 1;
	}
	return ret;
}

const int MAXN = 5e5 + 2;

long long int fac[MAXN], invf[MAXN];

long long int C(int n, int r)
{
	if (n < 0 or r < 0 or n < r) return 0;
	long long ret = fac[n]*invf[r] % MOD;
	return (ret*invf[n-r])%MOD;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

	fac[0] = 1;
	for (int i = 1; i < MAXN; ++i)
		fac[i] = 1LL*i*fac[i-1]%MOD;
	invf[MAXN-1] = mpow(fac[MAXN-1], MOD-2);
	for (int i = MAXN-2; i >= 0; --i)
		invf[i] = 1LL*(i+1)*invf[i+1]%MOD;

	int n, m; cin >> n >> m;
	long long int ans = 0;
	for (int k = 0; k <= n; ++k) {
		// k mismatches: how many ways?
		long long bad = C(n, k) * C(m, k) % MOD; // Choose k positions, values for those positions
		bad = (bad * fac[k]) % MOD; // All permutations
		long long other = C(m-k, n-k) * C(m-k, n-k) % MOD; // Other positions
		other = (other * fac[n-k]) % MOD;
		other = (other * fac[n-k]) % MOD;
		if (k%2 == 1) ans -= other*bad;
		else ans += other*bad;
		ans %= MOD;
		if (ans < 0) ans += MOD;
	}
	cout << ans << '\n';
}

Measured memory_bytes: 11456
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i,N) cin >> A[i];
    vector<int> idx(N);
    iota(idx.begin(),idx.end(),0);
    sort(idx.begin(), idx.end(),[&](int x, int y){return A[x] < A[y];});
    REP(i,N){
        cout << idx[i] + 1 << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
const long long int sMod = 998244353;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n,k;
    cin >> n >> k;
    if(k>(n-1)*(n-2)/2){
        print(-1);
        return;
    }
    print(n-1+(n-1)*(n-2)/2-k);
    repi(i,2,n+1){
        cout << 1 << " " << i << endl;
    }
    ll ctr=(n-1)*(n-2)/2;
    bool ok=false;
    repi(i,2,n){
        repi(j,i+1,n+1){
            if(ctr==k) {
                ok=true;
                break;
            }
            cout << i << " " << j << endl;
            ctr--;
        }
        if(ok) break;
    }

    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
class c
{
    static void Main()
    {
        var list = new List<int>();
        for (int i = 0; i < 5; i++) list.Add(int.Parse(Console.ReadLine()));
        var p = 10;
        for (int i = 0; i < 5; i++)
        {
            if (list[i] % 10 == 0) continue;
            else p = Math.Min(p, list[i] % 10);
        }
        var ans = 0;
        for (int i = 0; i < 5; i++)
        {
            ans += (list[i] - 1) / 10 * 10;
        }
        Console.WriteLine(ans+p+40);
    }
}



Measured memory_bytes: 13140
import sys
from collections import defaultdict as ddict

sys.setrecursionlimit(10**7)
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
printn = lambda x: print('\n'.join(x))

n = ni()
a = nl()
d = ddict(int)
ans = 0
for i in range(n):
    ans += d[a[i] - i]
    d[- a[i] - i] += 1
print(ans)


Measured memory_bytes: 61588
#include <iostream>
#include <iomanip>
/*cout<<setprecision(11)<<ret<<endl;で、数字部分を計11桁表示かつゼロ埋め無*/
/*cout<<fixed<<setprecision(11)<<ret<<endlで、小数部のみ11桁表示かつゼロ埋め有*/
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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; }

//Shift+Command+bでデバッグ
//その後ターミナルで./a.outを実行
//入力を貼り付ける

//////////////////
//  A
int main(void){
    int x;cin>>x;
    int a=-1;
    rep(i,4){
        int tmp=x%10;
        if(a==tmp){
            cout<<"Bad"<<endl;
            return 0;
        }else{
            a=tmp;
            x/=10;
        }
    }
    cout<<"Good"<<endl;

    return 0;
}
//////////////////
//  B
/*int main(void){
    int n,x;cin>>n>>x;
    int sum=0,cnt=1;

    rep(i,n){
        int l;cin>>l;
        sum+=l;
        if(sum>x){
            break;
        }else{
            cnt++;
        }
    }

    cout<<cnt<<endl;

    return 0;
}*/
//////////////////
//  C
/*int main(void){
    double w,h,x,y;cin>>w>>h>>x>>y;
    bool ret=(2*x==w)&&(2*y==h);
    cout<<(double)((w*h)/2.0)<<" "<<ret<<endl;
    return 0;
}*/
//////////////////
//  D　いけそう感がある。しゃくとり法
/*int main(void){

    return 0;
}*/
//////////////////
//  E
/*int main(void){

    return 0;
}*/
//////////////////
//  F
/*int main(void){

    return 0;
}*/


Measured memory_bytes: 3604
using System;

class Problem
{
  public static void Main()
  {
    var inputs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    var A = inputs[0];
    var B = inputs[1];
    var plus = A + B;
    var minus = A - B;
    var multi = A * B;
    Console.WriteLine($"{Math.Max(plus, Math.Max(minus, multi))}");
  }
}


Measured memory_bytes: 13268
from itertools import product

n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))

A = [0]*(2**n)
c = 0
for x in product([0,1], repeat=n):
    summ = 0
    for j in range(n):
        if x[j] == 1:
            summ += a[j]
    A[c] = summ
    c+=1

for i in range(q):
    if m[i] in A:
        print('yes')
    else:
        print('no')


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, y, r, p;
string s, t;
// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a*b < c*d) cout<<c*d;
	else cout<<a*b;
}

int main() {
	fastio; randomINT;
	//cin>>t;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 237956
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define ld long double
#define tc() ll t;cin>>t;while(t--)
#define inp(n) ll n;cin>>(n)
#define inp2(n,m) ll n,m;cin>>(n);cin>>(m)
#define inp3(n,m,g) ll n,m,g;cin>>(n);cin>>(m);cin>>(g)
#define inps(s) string s;cin>>(s)
#define fr(i,n) for(ll i=0;i<n;i++)
#define rf(n,i) for(ll i=n-1;i>=0;i--)
#define vi vector<int >
#define vl vector<ll>
#define vd vector<ld>
#define vs vector<string >
#define pii pair<int,int>
#define pci pair<char ,int>
#define pic pair<int ,char>
#define psi pair<string ,int>
#define mii map<int ,int >
#define mci map<char ,int>
#define msi map<string ,int>
#define si set<int >
#define ss set<string>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007

int main() {
    fast
    int n;
    cin>>n;
    
    int x,y;
    int ant = 0;
    int ans = 0;
    while(n--){
        cin>>x>>y;
        if(x==y){
            ans++;
        }
        else{
            ans=0;
        }
        if(ans==3){
            ant = 1;
        }
    }
    
    if(ant){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
	return 0;
}


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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int r,g,b;
  cin >> r >> g >> b;
  if((10*g+b)%4==0){
    cout << "YES" << endl;
  }
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
c,A,s = [],[],0
for i in range(10):
    c.append(list(map(int,input().split())))
for i in range(H):
    A.append(list(map(int,input().split())))
for i in range(10):
    for j in range(10):
        for k in range(10):
            c[j][k] = min(c[j][k], c[j][i]+c[i][k])
for i in range(10):
    for j in range(H):
        s += A[j].count(i) * c[i][1]
print(s)

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#define INF 1000000009
#define LINF 1000000000000000009
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
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; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

int main() {
	int a, b;
	cin >> a >> b;
	for (int i = 0; i < max(a, b); i++) cout << min(a, b);
}

Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  double a, b;
  cin >> a >> b;
  cout << PREC(20) << a / b << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
while True:
    N = int(raw_input())
    if N == 0: break
    total = None
    result = []
    for i in range(N):
        lis = list(map(int, raw_input().split(' ')))
        lis.append(sum(lis))
        result.append(lis)
        if total == None:
            total = lis[:]
        else:
            for i in range(len(total)):
                total[i] = total[i]+lis[i]
    else:
        result.append(total)
        for line in result:
            ans = []
            for v in line:
                ans.append('%05s' % v)
            else:
                print ''.join(ans)

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

int main() {
	long long int N, ans,bef;
	cin >> N;
	if (N == 1) {
		ans = 1;
	}
	else {
		ans = 1;
		bef = 2;
		for (int i = 0; i < N-1; i++) {
			long long int tmp = ans;
			ans += bef; //最初:2
			bef = tmp;
		}
	}
	cout << ans << endl;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<ll> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    map<ll, ll> m1, m2, m3;
    for(int i = 0; i < n; i++){
        m1[v[i]]++;
        m2[v[i] + 1]++;
        m3[v[i] - 1]++;
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ll sum = m1[v[i]] + m2[v[i]] + m3[v[i]];
        ans = max(ans, sum);
    }
    cout << ans << endl;
}


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

int main() {
    int N, X;
    cin >> N >> X;
    int m, min=10000;
    while ( cin >> m ) {
        X -= m;
        if ( min > m ) min = m;
    }
    int ans = N + X / min;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = 4*atan(1);
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
// ll gcd(ll a, ll b) { 
//     if (a == 0) return b; 
//     return gcd(b % a, a); 
// }
// ll f(ll x) {
// 	x%=MOD;
// 	if(x<0)x+=MOD;
// 	return x;
// }
// ll power(int base, int power) {
// 	ll prod = 1;
// 	ll b = base;
// 	while(power) {
// 		if (power & 1) {
// 			prod = f(prod*b);
// 		}
// 		b = f(b*b);
// 		power/=2;
// 	}
// 	return prod;
// }
// struct line {
//     int m, c;
//     ll eval(int x) { return 1LL * m * x + c; }
//     double intersectX(line l) { return (double) (c - l.c) / (l.m - m); }
// };

int n, k;
bool has[101];
void solve() {
	cin >> n >> k;
	for (int i = 0,d; i < k; i++) {
		cin >> d;
		for (int j = 0,a; j < d; j++) {
			cin >> a;
			has[a] = true;
		}
	}
	int cnt = 0;
	for (int i = 1; i <= n; i++) if (!has[i])cnt++;
	cout << cnt << endl;
}
int main() {

	// int t;
	// cin >> t;
	// for (int i = 1; i <= t; i++) { 
		// cout << "Case #" << i << ": ";
		solve();
	// }
}

Measured memory_bytes: 3584
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

double mdistance(vector<int> x, vector<int> y, size_t p) {
    /* Minkowski distance */
    double d=0;
    size_t n=x.size();

    if (p == 1) {
        // Manhattan distance
        for (size_t i=0; i<n; ++i)
            d += abs(x[i]-y[i]);

        return d;
    } else if (p == 2) {
        // Euclidean distance
        for (size_t i=0; i<n; ++i)
            d += (x[i]-y[i])*(x[i]-y[i]);

        return sqrt(d);
    } else if (p == 3) {
        for (size_t i=0; i<n; ++i) {
            int z=abs(x[i]-y[i]);
            d += z*z*z;
        }
        return cbrt(d);
    } else if (!~p) {
        // Chebyshev distance
        for (size_t i=0; i<n; ++i)
            d = max(d, 1.0*abs(x[i]-y[i]));

        return d;
    }

    return 0;
}

int main() {
    size_t n;
    scanf("%zu", &n);

    vector<int> x(n), y(n);

    for (size_t i=0; i<n; ++i)
        scanf("%d", &x[i]);

    for (size_t i=0; i<n; ++i)
        scanf("%d", &y[i]);

    for (size_t i=1; i<=3; ++i)
        printf("%.12f\n", mdistance(x, y, i));

    printf("%.12f\n", mdistance(x, y, -1));
    return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}
// //
// //累積和2d
// //(Y, X)
// template <int H, int W> struct Sum2D {
//     int sum[H][W];
//     void set(int y, int x, int c) { sum[y][x] += c; }
//     void build() {
//         for (int y = 0; y < H; ++y) {
//             for (int x = 0; x < W; ++x) {
//                 if (0 < y) sum[y][x] += sum[y-1][x];
//                 if (0 < x) sum[y][x] += sum[y][x-1];
//                 if (0 < y and 0 < x) sum[y][x] -= sum[y-1][x-1];
//             }
//         }
//     }
//     int get(int sy, int sx, int ty, int tx) {
//         assert(sx <= tx and sy <= ty);
//         int tmp = sum[ty][tx];
//         if (0 < sx) tmp -= sum[ty][sx-1];
//         if (0 < sy) tmp -= sum[sy-1][tx];
//         if (0 < sx and 0 < sy) tmp += sum[sy-1][sx-1];
//         return tmp;
//     }
//     void print(int K) {
//         for (int y = 0; y < K; ++y) {
//             for (int x = 0; x < K; ++x) {
//                 cerr << sum[y][x] << " ";
//             }
//             cerr << endl;
//         }
//     }
// };
//
// Sum2D<4010, 4010> sum;

int sum[4010][4010];
int b[2002][2002];
int N, K;

int get(int y, int x) {
    return sum[y+K-1][x+K-1] - sum[y+K-1][x-1] - sum[y-1][x+K-1] + sum[y-1][x-1];
}

int main() {
    cin >> N >> K;
    rep(i, N) {
        int x, y;
        char color;
        cin >> x >> y >> color;
        if (color == 'W') y += K;
        ++b[y%(2*K)+1][x%(2*K)+1];
    }
    for (int x=1; x<=4*K; ++x) {
        for (int y=1; y<=4*K; ++y) {
            sum[y][x] = sum[y-1][x] + b[(y-1)%(2*K)+1][(x-1)%(2*K)+1];
        }
    }
    for (int y=1; y<=4*K; ++y) {
        for (int x=1; x<=4*K; ++x) {
            sum[y][x] += sum[y][x-1];
        }
    }
    int KK = K*2, ans = 0;
    for (int i=1; i<=KK; ++i) {
        for (int j=1; j<=KK; ++j) {
            ans = max(ans, get(i, j) + get(i+K, j+K));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 78592
line = []
while True:
    b = list(map(int, input().split()))
    if b[0] == 0 and b[1] == 0:
        break
    else:
        line.append(b)
for i in line:
    for j in range(i[0]):
        for k in range(i[1]):
            print("#", end ="")
        print()
    print()


Measured memory_bytes: 7008
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define int long long
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define MAXN 200100
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef pair<ll,ll> pll;
typedef vector<string> vs;
typedef vector<pll> vpl;
typedef vector<int> vi;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);

}

int32_t main(){
	fastio;
	string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes"<<endl;
    }else cout<<"No"<<endl;
	// Math -> gcd it all
	//did you check N=1? Did you mix up N,M?
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int m, f, r;

  while(1){
    scanf("%d %d %d", &m, &f, &r);
    if(m == -1 && f == -1 && r == -1){break;}

    if(m == -1 || f == -1){
      printf("F\n");
      continue;
    }

    if((m + f) >= 80){
      printf("A\n");
      continue;
    }

    if(65 <= (m + f) && (m + f) < 80){
      printf("B\n");
      continue;
    }

    if(50 <= (m + f) && (m + f) < 65){
      printf("C\n");
      continue;
    }

    if(30 <= (m + f) && (m + f) < 50 && r >= 50){
      printf("C\n");
    }else if(30 <= (m + f) && (m + f) < 50){
      printf("D\n");
      continue;
    }

    if((m + f) < 30){
      printf("F\n");
      continue;
    }

  }
  return 0;
}



Measured memory_bytes: 2044
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static final int NMAX = 100000;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		long K = sc.nextLong();
		long ary[] = new long[NMAX+1];

		for(int i=0; i<N; i++){
			int a = sc.nextInt();
			int b = sc.nextInt();

			ary[a] += b;
		}

		for(int i=0; i<=NMAX; i++){
			if((K -=ary[i]) <=0){
				System.out.println(i);
				break;
			}
		}
	}

}

class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 21956
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
using namespace std;
using ll=long long;
using ld=long double;
ll mod = ll(1e9)+7;
ll inf = ll(1e18);
template<typename T1, typename T2> ll ceill(T1 a, T2 b){ return (a+b-1)/b; }
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(a>b){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

#include <iostream>
#include <vector>
#include <map>
using namespace std;

namespace dbg {
    using ll = long long;

    class Debug {
    public:
        Debug(){}
        template<typename T>
        void vd(vector<T> vec);
        template<typename T>
        void vd2(vector<vector<T>> vec);
        template<typename T>
        void ad(T *arr, ll n);
        template<typename T, size_t N>
        void ad2(T (&arr)[N], ll n);
        template<typename T>
        void md(T mp);
    };

    template<typename T>
    void Debug::vd(vector<T> vec) {
        for (auto vv : vec) cout << vv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::vd2(vector<vector<T>> vec) {
        for (auto vv : vec) for (auto vvv : vv) cout << vvv << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::ad(T *arr, ll n) {
        for (int i = 0; i <= n; i++) cout << arr[i] << " ";
        cout << endl;
    }

    template<typename T, size_t N>
    void Debug::ad2(T (&arr)[N], ll n) {
        for (int i = 0; i <= N; i++) for (int j = 0; j <= n; j++) cout << arr[i][j] << " ";
        cout << endl;
    }

    template<typename T>
    void Debug::md(T mp) {
        cout << "key : value" << endl;
        for (auto const &m : mp) cout << m.first << " : " << m.second << endl;
        cout << endl;
    }

}

#endif //INCLUDE_DEBUG_HPP

using dbg::Debug;
Debug debug;

class BGoldenCoins {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll x;
	    in >> x;

	    ll res = 0;
	    res += x/500 * 1000;
	    ll rest = x%500;
	    res += rest/5*5;
	    out << res << endl;
	}
};


int main() {
	BGoldenCoins solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t;
    cin>>t;
    int mx=0,mi=1000000000;
    while(t--){
    	int a;
    	cin>>a;
    	if(a>mx) mx=a;
    	if(a<mi) mi=a;
    }
   	cout<<mx-mi;
   return 0;
}

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

int main(){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  string S;
  int dx = tx - sx;
  int dy = ty - sy;
  for(int i=0; i<dx; i++) S+='R';
  for(int i=0; i<dy; i++) S+='U';
  for(int i=0; i<dx; i++) S+='L';
  for(int i=0; i<dy; i++) S+='D';
  S+='D';
  for(int i=0; i<dx+1; i++) S+='R';
  for(int i=0; i<dy+1; i++) S+='U';
  S+='L';
  S+='U';
  for(int i=0; i<dx+1; i++) S+='L';
  for(int i=0; i<dy+1; i++) S+='D';
  S+='R';
  cout << S << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1010;
const int INF=1e9;
int n,sum[maxn],b[maxn];
vector<int> m[maxn];
bool dfs(int u)
{
	vector<int> f(sum[u]+1,INF); f[0]=0;
	for(int j=0;j<m[u].size();j++)
	{
		int v=m[u][j]; if(!dfs(v))return 0;	vector<int> g(sum[u]+1,INF);
		for(int i=0;i+sum[v]<=sum[u];i++)g[i+sum[v]]=min(g[i+sum[v]],f[i]+b[v]);
		for(int i=0;i+b[v]<=sum[u];i++)g[i+b[v]]=min(g[i+b[v]],f[i]+sum[v]); f=g;
	}
	b[u]=*min_element(f.begin(),f.end()); return b[u]<INF;
}
int main()
{
	cin>>n;	for(int i=2;i<=n;i++){int x; cin>>x; m[x].push_back(i);}
	for(int i=1;i<=n;i++)cin>>sum[i]; if(!dfs(1))cout<<"IM"; cout<<"POSSIBLE\n"; return 0;
}

Measured memory_bytes: 5756
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define C 0.5772156649
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define pil pair<int,ll>
#define pii pair<int,int>
#define ull unsigned long long
#define base 1000000000000000000
#define fio ios::sync_with_stdio(false);cin.tie(0)

using namespace std;

const double g=10.0,eps=1e-12;
const int N=100000+10,maxn=2000+10,inf=0x3f3f3f3f,INF=0x3f3f3f3f3f3f3f3f;

vector<pii>v[N];
ll dis[N];
void dfs(int u)
{
//    printf("%d\n",u);
    for(int i=0;i<v[u].size();i++)
    {
        pii te=v[u][i];
        if(dis[te.fi]==-1e18)
        {
            dis[te.fi]=dis[u]+te.se;
            dfs(te.fi);
        }
        else if(dis[te.fi]!=dis[u]+te.se)
        {
            puts("No");
            exit(0);
        }
    }
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;++i)
    {
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        v[a].pb(mp(b,c));
        v[b].pb(mp(a,-c));
    }
    for(int i=1;i<=n;++i)dis[i]=-1e18;
    for(int i=1;i<=n;++i)
    {
        if(dis[i]==-1e18)
        {
            dis[i]=0;
            dfs(i);
        }
    }
    puts("Yes");
    return 0;
}
/********************

********************/


Measured memory_bytes: 13312
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx")

int main() {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H.at(i);

  vector<int> DP(N, 1e9);
  DP.at(0) = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j <= i + K; j++) {
      if (j >= N) break;
      DP.at(j) = min(DP.at(j), DP.at(i) + abs(H.at(i) - H.at(j)));
    }
  }

  cout << DP.at(N - 1) << "\n";
}

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

int main(){
  char str[1002];
  int len;
  
  scanf("%s",str);
  
  len = strlen(str);
  
  if(str[len-1] == 's'){
    strcat(str,"es");  
  }else{
    strcat(str,"s");
  }
  
  printf("%s",str);
  
}

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

int main(void) {
    int i, n, l, x, sum=0, min=300, check;
    cin >> n >> l;
    vector<int> apples(n);
    for(i=0; i<n; i++) {
        apples[i]=l+i;
        check=apples[i];
        sum+=apples[i];
        if(check<0)
            check*=-1;
        if(check<min) {
            min=check;
            x=i;
        }
    }
    cout << sum-apples[x] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  vector<string> row(H);
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    cin >> row.at(i);
  }
  for (int j = 0; j < W + 2; j++) {
    cout << "#";
  }
  cout << endl;
  for (int k = 0; k < H; k++) {
    cout << "#" << row.at(k) << "#" << endl;
  }
  for (int l = 0; l < W + 2; l++) {
    cout << "#";
  }
  cout << endl;
}

Measured memory_bytes: 33024