akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
static const int MAX = 10000;

int solve_coin_changing1(vector<int> coins, int target) {
  vector<vector<int>> com = {{0}};
  com.push_back(coins);
  bool data[50000] = {false};

  for (int n = 2; n <= 10000; n++) {
    vector<int> b;
    cout << n << endl;
    for (int i = 1; i <= n / 2; i++) {
      for (int j = 0; j < com[i].size(); j++) {
        for (int k = j; k < com[n - i].size(); k++) {
          int val = com[i][j] + com[n - i][k];
          if (val == target) {
            return n;
          }
          if (!data[val]) {
            b.push_back(val);
            data[val] = true;
          }
        }
      }
    }
    cout << b.size() << endl;
    com.push_back(b);
  }
  return -1;
}
int solve_coin_changing2(vector<int> coins, int target) {
  int need_ncoin[50001];
  sort(coins.begin(), coins.end());
  auto cp = coins.begin();

  for (int i = 1; i <= target; i++) {
    if (*cp == i) {
      need_ncoin[i] = 1;
      cp++;
      continue;
    }
    int minimum = 50000;
    for (int j = 1; j <= i / 2; j++) {
      int ncoin = need_ncoin[i - j] + need_ncoin[j];
      minimum = min(minimum, ncoin);
      if (ncoin == 2)
        break;
    }
    need_ncoin[i] = minimum;
  }
  return need_ncoin[target];
}

#define T_NMAX 50000
#define NCOIN_MAX 20
int solve_coin_changing(vector<int> coins, int target) {
  sort(coins.begin(), coins.end());
  int need_ncoin[T_NMAX + 1];

  for (int j = 0; j <= target; j++) {
    need_ncoin[j] = j;
  }
  for (int i = 1; i < coins.size(); i++) {
    for (int j = 1; j <= target; j++) {
      int not_use_i = need_ncoin[j];
      int use_i = (j-coins[i] >= 0) ? need_ncoin[j - coins[i]] + 1 : T_NMAX;
      need_ncoin[j] = min(use_i, not_use_i);
    }
  }
  return need_ncoin[target];
}

int main() {
  int ncoin, target;
  cin >> target >> ncoin;
  vector<int> coins;
  for (int i = 0; i < ncoin; i++) {
    int val;
    cin >> val;
    coins.push_back(val);
  }
  cout << solve_coin_changing(coins, target) << endl;
}

Measured memory_bytes: 3344
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return(a)


def make_divisors(n):
    divisors = []
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.append(n)
    return divisors


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)

    return a


A, B = map(int, input().split())

C = gcd(A, B)

d = prime_factorize(C)
d.append(1)

print(len(list(set(d))))


Measured memory_bytes: 3064
H, W = map(int,input().split())
S = []
for i in range(H):
    S.append(input())

di = [-1,0,1,0]
dj = [0,-1,0,1]

def BFS(i,j,que):
    count = 0
    for k in range(4):
        row = i + di[k]
        col = j + dj[k]
        if H > row >=0 and W >col >= 0 \
            and dist[row][col] == float('inf')\
                and S[row][col] != "#":
            
            que.append([row,col])
            dist[row][col] = dist[i][j] + 1
            count = dist[row][col]
    return count


path_max = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            continue
        que = []
        stt = [i,j]
        que.append(stt)
        dist = [[float('inf') for ii in range(W)] for jj in range(H)]
        dist[i][j] = 0
        while que:
            idx = que[0]
            que.pop(0)
            count  = BFS(idx[0],idx[1],que)
            path_max = max(path_max,count)

print(path_max)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
string s;
cin>>s;
int count=0;
for(int i=0;i<s.size()-1;i++){
    if(s[i]!=s[i+1]){
        count++;
    }
}
cout<<count+1<<endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

#define LSB(x) ((x)&-(x))
const int N = 5e5 + 5;
int n, m, l, r;
int a[N];
int ans[N];
vector<int> q[N];
int p[N];
int T[N];

void update(int i, int j) {
    while (i <= N) {
        T[i]+=j;
        i+=LSB(i);
    }
}

int query(int i) {
    int res = 0;
    while (i >= 1) {
        res += T[i];
        i -= LSB(i);
    }
    return res;
}

int main() {
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> l >> r;
        q[i] = {r, l, i};
    }
    sort(q, q + m);
    int start = 1;
    for (int i = 0; i < m; ++i) {
        l = q[i][1];
        r = q[i][0];
        int o = q[i][2];
        for (int j = start; j <= r; ++j) {
            int v = a[j];
            if (p[v]) {
                update(p[v], -1);
            }
            update(j, 1);
            p[v] = j;
        }
        start = r + 1;
        ans[o] = query(r) - query(l - 1);
    }
    for (int i = 0; i < m; ++i) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 38960
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <set>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

typedef long long ll;

using namespace std;

int main(void) {
  int N;
  cin >> N;
  vector<int> X(N);
  for (int i = 0; i < N; i++) { cin >> X[i]; }
  vector<int> A(X.begin(), X.end());
  sort(X.begin(), X.end());


  for (int i = 0; i < N; i++) {
    auto lb = lower_bound(X.begin(), X.end(), A[i]);
    int li = distance(X.begin(), lb);

    if (li < N / 2) {
      cout << X[N / 2] << endl;
    } else {
      cout << X[N / 2 - 1] << endl;
    }
  }
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

ll mod = 998244353;

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

  int n,a,b,c;
  cin >> n >> a >> b >> c;
  vector<string> q(n);
  vi AB,BC,AC;
  rep(i,n){
    cin >> q[i];
    if(q[i] == "AB")AB.push_back(i);
    if(q[i] == "BC")BC.push_back(i);
    if(q[i] == "AC")AC.push_back(i);
  }

  string ret = "Yes";
  string op = "";

  int pAB = 0,pBC = 0,pAC = 0;

  rep(i,n){
    if(q[i] == "AB"){
      if(a == 1 && b == 1){
        if((AC.size() >  pAC && AC[pAC] < BC[pBC]) || BC.size() == pBC){
          a++;b--;
          op += "A";
        }else{
          a--;b++;
          op += "B";
        }
      }else if(a == 0 && b == 0){
        ret = "No";
        break;
      }else if(a < b){
        a++;b--;
        op += "A";
      }else{
        a--;b++;
        op += "B";
      }
      pAB++;
    }else if(q[i] == "BC"){
      if(b == 1 && c == 1){
        if((AB.size() > pAB && AB[pAB] < AC[pAC]) || AC.size() == pAC){
          b++;c--;
          op += "B";
        }else{
          b--;c++;
          op += "C";
        }
      }else if(b == 0 && c == 0){
        ret = "No";
        break;
      }else if(b < c){
        b++;c--;
        op += "B";
      }else{
        b--;c++;
        op += "C";
      }
      pBC++;
    }else{
      if(a == 1 && c == 1){
        if((AB.size() > pAB && AB[pAB] < BC[pBC]) || BC.size() == pBC){
          a++;c--;
          op += "A";
        }else{
          a--;c++;
          op += "C";
        }
      }else if(a == 0 && c == 0){
        ret = "No";
        break;
      }else if(a < c){
        a++;c--;
        op += "A";
      }else{
        a--;c++;
        op += "C";
      }
      pAC++;
    }
  }

  cout << ret << endl;

  if(ret == "Yes")rep(i,n)cout << op[i] << endl;
}

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

int main()
{
  int64_t n, s = 0, q, a, b, c;
  cin >> n;
  vector<int64_t> C(100010, 0);
  for (int i = 0; i < n; i++)
  {
    cin >> a;
    C.at(a)++;
    s += a;
  }
  cin >> q;
  for (int i = 0; i < q; i++)
  {
    cin >> b >> c;
    s -= b * C.at(b);
    s += c * C.at(b);
    C.at(c) += C.at(b);
    C.at(b) = 0;
    cout << s << endl;
  }
}

Measured memory_bytes: 4024
from collections import deque as dq
N,M=map(int,input().split())
Graph=[[] for i in range(N)]
for i in range(M):
  a,b=map(int,input().split())
  Graph[a-1].append(b-1)
  Graph[b-1].append(a-1)
path=dq(["1",str(Graph[0][0]+1)])
p=[False]*N
ep1=0
ep2=Graph[0][0]
p[ep1],p[ep2]=True,True
flag=0

while len(path)<=N:
  for a in Graph[ep1]:
    if not p[a]:
      path.appendleft(str(a+1))
      p[a]=True
      ep1=a
      flag=1
      break
  for b in Graph[ep2]:
    if not p[b]:
      path.append(str(b+1))
      p[b]=True
      ep2=b
      flag=1
      break
  if flag==0:
    print(len(path))
    print(" ".join(path))
    exit()
  flag=0
    
      
  
    
      


Measured memory_bytes: 79136
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define mem(a,b) memset(a,b,sizeof a)
#define  For(i,a,b) for(int i=a,i##end=b;i<=i##end;++i)
#define rFor(i,a,b) for(int i=a,i##end=b;i>=i##end;--i)
using namespace std;
typedef long long LL;
const int N=100010;
const int M=200010;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T&a,const T&b){return b<a?a=b,1:0;}
template<typename T>inline bool chkmax(T&a,const T&b){return a<b?a=b,1:0;}
template<typename T>void read(T&x)
{
    x=0;int _f(0);char ch=getchar();
    while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
    while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
    x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}
int n,m,dis[N],deg[N];
struct edge
{
	int u,v,w;
	edge(){}
	edge(int u,int v,int w):u(u),v(v),w(w){}
}e[M];
int bgn[N],nxt[M],to[M],w[M],E;
inline void add_edge(int u,int v,int ew){nxt[++E]=bgn[u],bgn[u]=E,to[E]=v,w[E]=ew;}
int main()
{
	int x,y,z;
	file();
	mem(dis,inf);
	read(n),read(m);
	For(i,1,m)
	{
		read(x),read(y),read(z);
		e[i]=edge(x,y,z);
		add_edge(x,y,z);
		deg[y]++;
	}
	queue<int>q;
	For(i,1,n)
		if(!deg[i])q.push(i),dis[i]=1;
	while(!q.empty())
	{
		int u=q.front();q.pop();
		for(int v,i=bgn[u];i;i=nxt[i])
		{
			chkmin(dis[v=to[i]],dis[u]+w[i]);
			if(!--deg[v])q.push(v);
		}
	}
	For(i,1,m)
	if(dis[e[i].u]+e[i].w!=dis[e[i].v])
	{puts("No");exit(0);}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 6272
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<string,int> P;
const ll MOD=1e9+7;
multiset<int> st;
int a[100000];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	st.insert(a[0]);
	for(int i=1;i<n;i++)
	{
		if(a[i]<=(*st.begin()))
		{
			st.insert(a[i]);
		}else{
			auto p=st.lower_bound(a[i]);
			p--;
			st.erase(p);
			st.insert(a[i]);
		}
	}
	cout<<st.size()<<endl;
	return 0;
}

Measured memory_bytes: 5376
// ConsoleApplication9.cpp : アプリケーションのエントリ ポイントを定義します。
//


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
//#define int long long


using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[9] = {0, 0,0,1,1,1,-1,-1,-1 };
int dyy[9] = {0, 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(ll a, ll n) {//aのn乗を計算します。
	ll x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool arr[100000100];
vector<ll>sosuu;
void Eratosthenes() {
	ll N = 10000010;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (ll i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (ll j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (ll i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu.pb(i);
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}

ll stoL(string s) {
	ll n = s.length();
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		ans += pow2(10, n - i - 1)*(ll)(s[i] - '0');
	}
	return ans;
}

int main() {
	int N,A, B; cin >> N >> A >> B;
	cout << min(A, B) << " " << max(0, A + B - N) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector <char> vec;
int main()
{

    int x,y;
    cin>>x>>y;
    for(int i=y-x+1;i<=y;i++)
        cout<<i<<" ";
    for(int i=y+1;i<=x+y-1;i++)
        cout<<i<<" ";

}



Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;


int gcd(int a, int b) {//最大公約数
	if (b == 0)return a;
	return gcd(b, a%b);
}

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

	int N;
	cin >> N;
	VI A(N);
	REP(i, N) {
		cin >> A[i];
	}
	SORT(A);
	VI ret;
	int n = A[0];
	int ans=0;
	for (int i = 1; i*i <= n; ++i)
	{
		if (n%i == 0)
		{
			ret.push_back(i);
			if (i != 1 && i*i != n)
			{
				ret.push_back(n / i);
			}
		}
	}
	ret.push_back(A[0]);
	rSORT(ret);
	REP(i, ret.size()) {
		//cout << ret[i] << endl;
		int cnt = 0;
		REP(j, N) {
			if (A[j] % ret[i] == 0) {
				continue;
			}
			else {
				cnt++;
			}
			if (cnt == 2) {
				//cout << j << " " << i << " " << cnt << endl;
				break;
			}
			
		}
		if (cnt <= 1) {
			ans = max(ans,ret[i]);
		}
		//cout << ans << endl;
	}
	n = A[1];
	VI rret;
	for (int i = 1; i*i <= n; ++i)
	{
		if (n%i == 0)
		{
			rret.push_back(i);
			if (i != 1 && i*i != n)
			{
				rret.push_back(n / i);
			}
		}
	}
	rret.push_back(A[1]);
	rSORT(rret);
	REP(i, rret.size()) {
		//cout << rret[i] << endl;
		int cnt = 0;
		REP(j, N) {
			if (A[j] % rret[i] == 0) {
				continue;
			}
			else {
				cnt++;
			}
			if (cnt == 2) {
				//cout << j << " " << i << " " << cnt << endl;
				break;
			}

		}
		if (cnt <= 1) {
			ans = max(ans, rret[i]);
		}
		//cout << ans << endl;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1024
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;
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;
}
ll dp[110][110];
ll row[2] = {1,0};
ll column[2] = {0,1};

constexpr ll INF = 1145141919810;
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll h,w;
cin >> h >> w;
vector<string> grid(h);
rep(i,h)
cin >> grid[i];
rep(i,h){
    rep(j,w){
        dp[i][j] = INF;
    }
}
dp[0][0] = 0;

if(grid[0][0] == '#') {
    dp[0][0] = 1;
}
rep(i,h) {
    rep(j, w) {
        rep(k,2){
            if(i + row[k] >= h || j + column[k] >= w)
                continue;
            ll tmp = 0;
            if(grid[i + row[k]][j + column[k]] == '#' && grid[i][j] != '#')
                tmp = 1;
            chmin(dp[i + row[k]][j + column[k]],dp[i][j] + tmp);
        }
    }
}
cout << dp[h - 1][w - 1] << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);

const ll mod = 1'000'000'007;
const ll mod1= 998244353;
const int N = 5e5, M = N;
//=======================

vi g[N];
int a[N];
int f[1000000];


void solve() {
    int n;
    cin>>n;
    int l[1000];
    fo(i,n)
    {
        cin>>l[i];
    }
    sort(l,l+n);
    int cnt=0;
    Fo(i,0,n-2)
    {
        Fo(j,i+1,n-1)
        {
            Fo(k,j+1,n)
            {
                if(l[i]+l[j]>l[k] && l[i]!=l[j] && l[j]!=l[k] && l[k]!=l[i]) cnt++;
            }
        }
    }
    cout<<cnt<<endl;
}




int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
      solve();
    }
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}


void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}


Measured memory_bytes: 15380
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1001001001;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll memo[100000];
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/

int main(){
    ll N;
    cin >> N;
    cout << N * 800 - (N / 15) * 200 << endl;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long N){
    cout << (N * (N - 1) / 2) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
a, b, c, d = list(input())
O = ['+', '-']

for op1 in O:
    for op2 in O:
        for op3 in O:
            f = a + op1 + b + op2 + c + op3 + d
            if eval(f) == 7:
                ans = f + '=7'
                break

print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<31-1;
const int MOD = 1000000007;

void solve(void){
    ll N, M;
    cin >> N >> M;
    cout << abs(N-2)*abs(M-2) << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import sys
sys.setrecursionlimit(1000000)
input = sys.stdin.readline

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

if m%2==1:
  print(-1)
  exit()

graph = defaultdict(set)
grapht = defaultdict(set)
for i in range(m):
  a, b = list(map(int, input().split()))
  a -= 1
  b -= 1
  graph[a].add(b)
  graph[b].add(a)
  grapht[a].add(b)
  grapht[b].add(a)

graph2 = defaultdict(set)
visited = [0 for i in range(n)]
num = [1 for i in range(n)]

def dfs(x):
  visited[x] = 1

  for nx in graph[x]:
    if not visited[nx]:
      dfs(nx)

  t = set()
  if num[x]==1 and len(grapht[x])%2==0:
    for e in grapht[x]:
      graph2[x].add(e)
      t.add(e)
  elif num[x]==-1 and len(grapht[x])%2==0:
    for j, e in enumerate(grapht[x]):
      if j==len(grapht[x])-1:
        graph2[e].add(x)
        num[e] *= -1
      else:
        graph2[x].add(e)
      t.add(e)
  elif num[x]==1 and len(grapht[x])%2==1:
    for j, e in enumerate(grapht[x]):
      if j==len(grapht[x])-1:
        graph2[e].add(x)
        num[e] *= -1
      else:
        graph2[x].add(e)
      t.add(e)
  elif num[x]==-1 and len(grapht[x])%2==1:
    for e in grapht[x]:
      graph2[x].add(e)
      t.add(e)
  for e in t:
    grapht[x].remove(e)
    grapht[e].remove(x)

dfs(0)

for i in range(n):
  for e in graph2[i]:
    print(i+1, e+1)


Measured memory_bytes: 171152
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
#define YMAX 250001
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
bool arr[10001];
int Nmax=10001;
vint sosu;
void Eratosthenes(){
	for(int i = 0; i < Nmax; i++){
		arr[i] = true;
	}
	arr[0]=false; arr[1]=false;
	for(int i = 2; i < sqrt(Nmax); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < Nmax; j++){
				arr[i *(j + 2)] = false;
			}
		}
	}
	rep1(i,Nmax){
		if(arr[i]) sosu.push_back(i);
	}
}
ll gcd(ll x,ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x/gcd(x,y)*y;
}
int main(){
	Eratosthenes();
	int N;
	ll a[502][502];
	ll ichimatsu1[501][501],ichimatsu2[501][501];
	scan(N);
	int NMAX=500;
	int sosucount=0;
	for(int kyori=0;kyori<=NMAX*2-2;kyori+=2){
		for(int j=0;j<=NMAX-1;j++){
			int i=kyori-j;
			if(i<0||i>NMAX-1) continue;
			//printf("kyori:%d i:%d j:%d sosu:%d\n",kyori,i,j,sosu[sosucount]);
			ichimatsu1[i][j]=sosu[sosucount];
		}
		sosucount++;
	}
	for(int kyori=NMAX-1;kyori<=NMAX*2-2&&kyori>=0;kyori+=(kyori<=NMAX-1 ? 2*(NMAX-1-kyori)+2 : 2*(NMAX-1-kyori))){
		for(int j=NMAX-1;j>=0;j--){
			int i=j-kyori+NMAX-1;
			if(i<0||i>NMAX-1) continue;
			ichimatsu2[i][j]=sosu[sosucount];
		}
		sosucount++;
	}
	/*rep(i,N){
		rep(j,N){
			if((i+j)%2==0) printf("%lld ",ichimatsu1[i][j]);
			else printf("-- ");
		}
		kaigyo;
	}
	kaigyo;
	rep(i,N){
		rep(j,N){
			if((i+j)%2==0) printf("%lld ",ichimatsu2[i][j]);
			else printf("-- ");
		}
		kaigyo;
	}*/
	rep(i,NMAX){
		rep(j,NMAX){
			if((i+j)%2==0) a[i+1][j+1]=ichimatsu1[i][j]*ichimatsu2[i][j];
		}
	}
	rep(i,NMAX+2){
		a[i][0]=1;
		a[i][NMAX+1]=1;
	}
	rep(j,NMAX+2){
		a[0][j]=1;
		a[NMAX+1][j]=1;
	}
	rep(i,NMAX){
		rep(j,NMAX){
			if((i+j)%2==1) a[i+1][j+1]=lcm(lcm(a[i][j+1],a[i+2][j+1]),lcm(a[i+1][j],a[i+1][j+2]))+1;
		}
	}
	rep1(i,N){
		rep1(j,N){
			printf("%lld ",a[i][j]);
		}
		kaigyo;
	}
	return 0;
}


Measured memory_bytes: 9088
import sys
import math

input = sys.stdin.readline

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
time_list = [a, b, c, d, e]
round_sum = 0
round_list = []
for t in time_list:
    if t%10 > 0:
        round_sum += t + 10-(t%10)
        round_list.append(t + 10-(t%10))
    else:
        round_sum += t
        round_list.append(t)
cnt_list = []
for r, t in zip(round_list, time_list):
    cnt_list.append(round_sum - r + t)
print(min(cnt_list))


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

int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i<N;i++)cin >> A[i],A[i]*=2;
    
    //x0 = 0のとき
    long long offset = 0;
    for(int i = 0; i < N ; i++)offset = A[i]-offset;
    long long x = offset /2;
    
    //復元
    long long cur = x;
    for(int i = 0; i < N;i++){
        cout << cur << " ";
        cur = A[i]-cur;
        
        
        
    }
    
    cout << endl;
    
    
    
    
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    ll na = 1, nb = 1;
    REP(i,n) {
        ll a, b;
        cin >> a >> b;
        ll da = (na+a-1) / a;
        ll db = (nb+b-1) / b;
        ll m = max(da,db);
        na = a * m;
        nb = b * m;
        //cerr << na << " " << nb << endl;
    }

    OUT(na+nb)

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const int limit = 50;
int n,m;
int a[limit], b[limit];
bool graph[limit][limit];
bool visited[limit];

void dfs(int v){
    visited[v] = true;
    for(int v2=0; v2<n; v2++) {
        if(graph[v][v2] == false) continue;
        if(visited[v2] == true) continue;
        dfs(v2);
    }
}

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

    for(int i=0; i<m; i++) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    int ans = 0;

    for(int i=0; i<m; i++) {
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

        for(int j=0; j<n; j++) visited[j] = false;

        dfs(0);

        bool bridge = false;
        for(int j=0; j<n; j++) {
            if(visited[j] == false) {
                bridge = true;
                break;
            }
        }
        if(bridge == true) ans++;
        
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int h, w;
    cin >> h >> w;
    vector<string> ss(h);
    REP(i,h) cin >> ss[i];
    vector<string> tt(h,string(w,'.'));
    tt[0][0] = '#';
    int y = 0, x = 0;
    while(y != h-1 || x != w-1) {
        if (y < h-1 && ss[y+1][x] == '#') {
            y++;
            tt[y][x] = '#';
        } else if (x < w-1 && ss[y][x+1] == '#') {
            x++;
            tt[y][x] = '#';
        } else break;
    }

    bool ans = (y == h-1 && x == w-1);
    if (ans) {
        REP(i,h) {
            if (ss[i] != tt[i]) ans = false;
        }
    }

    if (ans) OUT("Possible")
    else OUT("Impossible")


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(long long i=0; i<(int)n; i++)
#define rep2(i,a,n) for(long long i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}

int N, M, K, H, W, L, R, X;
//string S, T;

signed main(){
  cin >> N;
  cout << N*800 - (N/15)*200 << endl;    
  return 0;
}

Measured memory_bytes: 3644
#include<iostream>
using namespace std;
 
int main(){
  int N,Y;
  cin >> N >> Y;
  int res10000 = -1,res5000 = -1,res1000 = -1;
  for(int a=0;a<=N;a++){
    for(int b=0;b+a<=N;b++){
      int c = N-a-b;
      int total = 10000*a+5000*b+1000*c;
      if(total == Y){
        res10000 = a;
        res5000  = b;
        res1000  = c;
      }
    }
  }
  
  cout << res10000 << " " << res5000 << " " << res1000 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i, a, b)  for(int i = a; i <= b; ++i)
#define Ford(i, a, b) for(int i = a; i >= b; --i)
#define ll            long long
#define pb            push_back

const int N = 1e3 + 7;
const ll oo = 1e18 + 7;

using namespace std;

int n, m;
ll dp[N][N], a[N], c[N][N];

void Init()
{
    cin >> n;
    For(i, 1, n)
    {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    For(i, 1, n)
    For(j, i, n)
    c[i][j] = a[j] - a[i - 1];
}

ll DP(int l, int r)
{
    if(dp[l][r] != -1) return dp[l][r];
    if(r - l == 1) return dp[l][r] = c[l][r];
    dp[l][r] = oo;
    For(k, l + 1, r) dp[l][r] = min(dp[l][r], DP(l, k - 1) + DP(k, r) + c[l][r]);
    return dp[l][r];
}

void Solve()
{
     memset(&dp, -1, sizeof dp);
     For(i, 1, n) dp[i][i] = 0;
     cout << DP(1, n);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //READ; WRITE;
    Init();
    Solve();
}


Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define INF 1e15
#define MOD 1000000007
int n;
int dp[111][4][4][4];
signed main() {
	cin >> n;
	dp[0][3][3][3] = 1;
	for (int i = 1; i <= n; i++) {
		rep(j, 4) {
			rep(k, 4) {
				rep(l, 4) {
					if (j == 0 && k == 2 && l == 1)continue;
					if (j == 2 && k == 0 && l == 1)continue;
					if (j == 0 && k == 1 && l == 2)continue;
					rep(m, 4) {
						if (k == 0 && l == 2 && m == 1)continue;
						if (k == 2 && l == 0 && m == 1)continue;
						if (k == 0 && l == 1 && m == 2)continue;
						if (j == 0 && k == 2 && m == 1)continue;
						if (j == 0 && l == 2 && m == 1)continue;

						dp[i][k][l][m] += dp[i - 1][j][k][l];
						dp[i][k][l][m] %= MOD;
					}
				}	
			}
		}
	}
	int ans = 0;
	rep(i, 4) {
		rep(j, 4) {
			rep(k, 4) {
				if (i == 0 && j == 2 && k == 1)continue;
				if (i == 2 && j == 0 && k == 1)continue;
				if (i == 0 && j == 1 && k == 2)continue;
				ans += dp[n][i][j][k];
				ans %= MOD;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  if (a < b) {
    return b - a;
  } else {
    return a - b;
  }
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a) {
    a = b;
  }
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b) {
    a = b;
  }
}
template <class F> class fix_point : private F {
public:
  explicit constexpr fix_point(F &&f) : F(std::forward<F>(f)) {}

  template <class... Args>
  constexpr decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};
template <class F> constexpr decltype(auto) make_fix(F &&f) {
  return fix_point<F>(std::forward<F>(f));
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const usize n = scan<usize>();
  const std::string s = scan<std::string>();
  const std::string t = scan<std::string>();
  for (const usize i : rep(0, n)) {
    std::cout << s[i] << t[i];
  }
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


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

#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ffor(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(i, n) ffor(i, 0, n)
#define All(obj) (obj).begin(), (obj).end()
#define INF ((ll)1e9 + 7)
#define c(a) cout << a << "\n";
using namespace std;
const int N = 100005;

int main()
{
    speed;
    cout << fixed << setprecision(6);
    /*start*/
    int n, m;
    set<string> all;
    cin >> n;
    vector<string> s(n);
    rep(i, n)
    {
        cin >> s[i];
        all.insert(s[i]);
    }
    cin >> m;
    vector<string> t(m);
    rep(i, m)
    {
        cin >> t[i];
        all.insert(t[i]);
    }
    int counting = 0;
    for (auto strset : all)
    {
        int x = 0;
        x += count(All(s), strset);
        x -= count(All(t), strset);
        if (x > counting)
        {
            counting = x;
        }
    }
    c(counting);


    return 0;
}

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

int main() {
  int64_t X;
  cin >> X;
  int64_t h_500 = X/500;
  int64_t h_5 = (X-500*(X/500))/5;
  cout << h_500*1000 + h_5*5 << endl;
  
}


// int型の2次元配列(3×4要素の)の宣言
  //vector<vector<int>> data(3, vector<int>(4));
 
  // 入力 (2重ループを用いる)
  //for (int i = 0; i < 3; i++) {
    //for (int j = 0; j < 4; j++) {
      //cin >> data.at(i).at(j);
   // }
  //}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> vec(n);
    for(auto &e:vec)
        cin>>e;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(vec[i]==vec[j]||vec[i]==vec[k]||vec[j]==vec[k])
                    continue;
                if(vec[i]+vec[j]>vec[k]&&vec[i]+vec[k]>vec[j]&&vec[j]+vec[k]>vec[i])
                    ans++;
            }
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long int64;
int MOD = 1e9 + 7;

int64 inv(int64 a, int64 mod) {
  a %= mod;
  int64 v[] = { 0, 1, mod };
  int64 u[] = { 1, 0, a };
  while (v[2] != 1) {
    if (v[2] < u[2]) {
      int64 tmp[] = { v[0], v[1], v[2] };
      v[0] = u[0]; v[1] = u[1]; v[2] = u[2];
      u[0] = tmp[0]; u[1] = tmp[1]; u[2] = tmp[2];
      continue;
    }
    int64 coe = v[2] / u[2];
    for (int i = 0; i < 3; ++i) v[i] = v[i] - u[i] * coe;
  }
  return v[0] < 0 ? v[0] + mod : v[0];
}

int64 pow(int64 a, int64 p, int64 mod) {
  a %= mod;
  int64 ret = a;
  while (p > 1) {
    if (p % 2) {
      ret = (ret * ret) % mod;
      ret = (ret * a) % mod;
    } else {
      ret = (ret * ret) % mod;
    }
    p /= 2;
  }
  return ret;
}

int main() {
  //cout << fixed << setprecision(15);
  int N, M;
  cin >> N >> M;
  cout << (N-1)*(M-1) << "\n";
  return 0;
}


Measured memory_bytes: 256
import bisect

n = int(input())
s = list(input())
q = int(input())

alpha_map = {chr(i):[] for i in range(97,123)}
for i,c in enumerate(s):
    bisect.insort(alpha_map[c],i+1)
    
for _ in range(q):
    x,y,z = map(str,input().split())
    if int(x) == 1:
        y = int(y)
        bef = s[y-1]
        if bef == z:
            continue
        alpha_map[bef].pop(bisect.bisect_left(alpha_map[bef],y))
        bisect.insort(alpha_map[z],y)
        s[y-1] = z
    else:
        count = 0
        for i,j in alpha_map.items():
            idx = bisect.bisect_left(j,int(y))
            if idx < len(j) and j[idx] <= int(z):
                    count += 1
        print(count)

Measured memory_bytes: 29960
#include<iostream>
#include<string>


using namespace std;

int main(){
  string S; cin >> S; int s = S.size(); int ans = 0;
  for(int i = 0; i < s; i++){
     bool flag = true; int X = 0; int j = 0; //X、ループ変数j共に毎回初期化
    while( i + j < s && flag == true){//ループ変数の範囲はflagが破られずかつ範囲内の時
         if(S[i+j] == 'A' || S[i+j] == 'C' || S[i+j] == 'G'||S[i+j] == 'T'){
           X++; j++;} //iは先頭ポインタ、ACGT部分列の条件を満たす限りループ変数jを増やす。
         else{ flag = false;}}//flagが破られた
    ans = max ( ans, X);}//flagが破られるか、範囲外となり次第値を更新
  
  cout << ans << endl;//出力
  
  
  return 0;
}
           

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

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

using namespace std;

int m;
int idx;
string s;

string expr();

int number(){
	int a=0;
	for(;s[idx]!='(';idx++){
		a=10*a+(s[idx]-'0');
		a=min(a,m);
	}
	return a;
}

string expr2(){
	if(isdigit(s[idx])){
		int num=number();
		idx++;
		string a=expr();
		idx++;

		string res;
		if(a.length()<m){
			rep(i,num){
				if(res.length()>=m) break;
				res+=a;
			}
		}
		else{
			res=a;
			num--;
			if(num>0){
				res+=a.substr(0,m);
				res+='@';
				res+=a.substr(a.length()-m,m);
			}
		}
		return res;
	}
	else return string(1,s[idx++]);
}

string expr(){
	string res;
	while(idx<s.length() && (isdigit(s[idx]) || islower(s[idx]))) res+=expr2();
	return res;
}

void regularize(string &s){
	::s=s;
	idx=0;
	s=expr();
}

class suffix_array{
	const static int N_MAX=200000;
	char s[N_MAX+1];
	int n,sa[N_MAX+1];

	int f[N_MAX+1];
	bool inc[N_MAX+1];

	struct cmp0{
		char *s;
		cmp0(char *s):s(s){}
		bool operator()(int i,int j){ return s[i]<s[j]; }
	};
	struct cmp1{
		int h,*f;
		cmp1(int h,int *f):h(h),f(f){}
		bool operator()(int i,int j){ return i==j||f[i]!=f[j]?f[i]<f[j]:f[i+h]<f[j+h]; }
	};

public:
	void build(const char *ss){
		n=strlen(ss);
		rep(i,n+1){
			s[i]=ss[i];
			sa[i]=i;
		}

		cmp0 c0(s);
		sort(sa,sa+n+1,c0);
		f[sa[0]]=0;
		rep(i,n) f[sa[i+1]]=f[sa[i]]+(c0(sa[i],sa[i+1])?1:0);

		for(int h=1;f[sa[n]]<n;h<<=1){
			cmp1 c1(h,f);
			sort(sa,sa+n+1,c1);
			rep(i,n) inc[i+1]=c1(sa[i],sa[i+1]);
			rep(i,n) f[sa[i+1]]=f[sa[i]]+(inc[i+1]?1:0);
		}
	}

	int calc_lcp(char *a,char *b){
		int i;
		for(i=0;a[i]&&b[i]&&a[i]==b[i];i++);
		return i;
	}

	int solve(char *t){
		int res=0,len;
		for(len=::m;len;len--,t++){
			int lo=0,hi=n;
			while(lo<hi){
				int mi=(lo+hi)/2;
				if(strcmp(t,s+sa[mi])<0) hi=mi; else lo=mi+1;
			}

			int tmp=calc_lcp(t,s+sa[lo]);
			if(lo>0) tmp=max(tmp,calc_lcp(t,s+sa[lo-1]));
			if(lo<n) tmp=max(tmp,calc_lcp(t,s+sa[lo+1]));
			res+=tmp;
		}
		return res;
	}
};

int main(){
	int n,k;
	string s; cin>>n>>m>>k>>s;

	regularize(s);

	static suffix_array SA;
	SA.build(s.c_str());

	int ans=-1,i_ans=-1;
	rep(i,k){
		char t[401]; cin>>t;
		int tmp=SA.solve(t);
		if(ans<tmp) ans=tmp, i_ans=i;
	}
	printf("%d %d\n",i_ans+1,ans);

	return 0;
}

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

int main(){
    int N,Y;
    int man,gosen,sen,maisu;
    cin >> N >> Y;

    int res10000 = -1 , res5000 = -1 , res1000 = -1;

    for(man = 0 ; man <= N ; man++){
        for(gosen = 0; gosen + man <= N; gosen++){
            sen = N - man -gosen;
            int total = 10000*man+5000*gosen+1000*sen;  
            if(total == Y){
               res10000 = man;
               res5000 = gosen;
               res1000 = sen;  
            }
        }
    }
    cout << res10000 << " " << res5000 << " " << res1000 <<" ";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unsigned long long int ull;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e9;

struct UnionFindTree{
    vector<int> par,rank;
    UnionFindTree(int n):par(n),rank(n,0){
        for(int i=0;i<n;i++) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[rx]<rank[ry]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

ll power(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1) res*=a;
        a*=a;
        x>>=1;
    }
    return res;
}

int popcount(int x){
    int res=0;
    while(x>0){
        if(x&1) res++;
        x>>=1;
    }
    return res;
}

ll f(ll x){
    ll res=0;
    while(x>0){
        res+=x%10;
        x/=10;
    }
    return res;
}

int main(){
    int n;cin>>n;
    vector<int> C(n);
    for(int i=0;i<n;i++) cin>>C[i];
    vector<ll> DP(n+1,0),L(200001,-1);
    DP[0]=1;
    for(int i=0;i<n;i++){
        DP[i+1]=DP[i];
        int c=C[i];
        if(L[c]>=0&&L[c]<i-1){
          DP[i+1]=(DP[i+1]+DP[L[c]+1])%MOD;
        }
        L[c]=i;
    }
    cout<<DP[n]<<endl;
    return 0;
}

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

int main(){
  int n,k; cin >> n >> k;
  int d[n+1]; for (int i = 0; i < n; i++) cin >> d[i];
  int num[n] = {0}; for (int i = 0; i < n; i++) num[d[i]-1]++;
  int count1 = 0;
  for (int i = 0; i < n; i++) if(num[i]) count1++;
  
  if (count1 <= k) cout << 0 << endl;
  else{
    sort(num, num + n);
    int count2 = 0;
    for (int i = 0; i < n-k; i++) count2 += num[i];
    cout << count2 << endl;
  }
}
    
      

Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,a,i;
	double x=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		x+=(double)1/a;
	}
	printf("%lf\n",1/x);
	return 0;
}


Measured memory_bytes: 1728
#define watch5(a,b,c,d,e) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d << " | "<<#e<<": "<<e<<endl;
#define watch4(a,b,c,d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define watch3(a,b,c) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<endl;
#define printclock cerr<<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define sharingan cerr << "\n-------------------------------------------\n\n";
#define watch2(a,b) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<< endl;
#define Yup ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(a) cerr <<#a<<": "<<a<<endl;
#define __gcd(a, b) __algo_gcd(a, b)
#define PI 3.14159265358979323846

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

#define endl "\n"
#define int long long

int32_t main() {
    int a, b;
    cin >> a >> b;
    cout << a*b;
}


Measured memory_bytes: 3624