akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;

const long long MOD = 2;

void solve(long long N, std::vector<long long> a){
  vl x(N,-1);
  RREP(i,N,1){
    // iの倍数
    int idx = -1; // まだ
    ll cnt = 0;
    for(ll t = i; t <= N; t += i){
      if(x[t-1]==-1) idx = t-1;
      else (cnt += x[t-1])%=2;
    }
    if(cnt!=a[i-1]){
      if(idx==-1){
        cout << "-1" << endl; return;
      }
      x[idx] = 1;
    }else{
      if(idx!=-1) x[idx] = 0;
    }
  }
  vl ans;
  rep(i,N) if(x[i]==1) ans.pb(i);
  cout << ans.size() << endl;
  for(auto xx:ans) cout << xx+1 << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  long long N;
  scanf("%lld",&N);
  std::vector<long long> a(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&a[i]);
  }
  solve(N, std::move(a));
  return 0;
}


Measured memory_bytes: 4980
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#define ll long long
#define space putchar(' ')
#define endl putchar('\n')
#define debug puts("------------------------")
using namespace std;
inline void read(int &a) {a=0;int c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();a*=b; }
inline int  Rem() {int a=0,c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();return a*=b; }
inline void write(int x) {if(x>9)write(x/10);putchar('0'+x%10);}
inline void W(int x) {if(x<0){putchar('-'),x=-x;}write(x);}
/**/
/*I love Korosensei forever.*/
/**/
int main()
{
    // freopen("test.in","r",stdin);
    // freopen("test.out","w",stdout);
    int a,b,c;
    read(a);read(b);read(c);
    if(a==b&&b==c) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
// All Heil Fire Lord Zuko

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

#define sz(x) (int)x.size()
#define F first
#define S second
#define PB push_back

#define debug(x) cerr << #x << " = " << x << "\n"

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

const ll N = 100 * 1000 + 19;
const ll Mod = 998244353;
const ll inf = 1e18 + 19;

ll n, A[N], cnt[N], mx = -inf;
ll ans = 1;

ll pw(ll a, ll b);

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i ++) {
        cin >> A[i];
        mx = max(mx, A[i]);
    }
    if (A[0] != 0)
        return cout << 0, 0;
    for (int i = 1; i < n; i ++) {
        if (A[i] == 0)
            return cout << 0, 0;
        cnt[A[i]] ++;
    }
    for (int i = 2; i <= mx; i ++)
        ans = (ans * pw(cnt[i - 1], cnt[i]) % Mod);
    cout << ans;
    return 0;
}

ll pw(ll a, ll b) {
    if (b == 0)
        return 1;
    ll t = pw(a, b / 2);
    return ((b % 2) ? (a * ((t * t) % Mod) % Mod) : ((t * t) % Mod));
}

/* THINGS TO CHECK */

// Runtime ->
// Overflow ->
// Time ->
// Memory ->

/* READ PROBLEM STATEMENT CAREFULLY */


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

int main(void)
{
    int n, a, i;
    int *ans;
    
    scanf("%d", &n);
    
    ans = (int *)malloc(sizeof(int) * n);
    if(ans == NULL) {
        puts("Out of memory.");
        exit(EXIT_FAILURE);
    }
    
    for(i = 0; i < n - 1; i++) {
        scanf("%d", &a);
        ans[a - 1]++;
    }
    
    for(i = 0; i < n; i++)
        printf("%d\n", ans[i]);
    
    free(ans);
    
    return 0;
}

Measured memory_bytes: 2184
#include <bits/stdc++.h>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    int ans=0;
    
    if(n==1) {
        cout<<1<<endl;
        return 0;
    }
    
    for(int i=2;i<=n;i*=2){
        ans=i;
    }
    
    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
int main() {
  int n, k, d, a;
  cin >> n >> k;
  map<int, int> mp;
  rep(i,k)
  {
    cin >> d;
    rep(i,d)
    {
      cin >> a;
      mp[a]++;
    }
  }
  cout << n - mp.size();
  return 0;
}


Measured memory_bytes: 3600
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define x first
#define y second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

int gcd(int x,int y)
{
	while (y)
	{
		int r=x%y;x=y;y=r;
	}
	return x;
}

int main()
{
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("output.txt","w",stdout);
	#endif
	int n,k,x;scanf("%d%d%d",&n,&k,&x);
	int ma=x;
	for (int i=1;i<n;i++)
	{
		int y;scanf("%d",&y);
		x=gcd(x,y);ma=max(ma,y);
	}
	if (k%x==0&&k<=ma) puts("POSSIBLE"); else puts("IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, T t){return v2<T>(r, vector<T>(c, t));}

void solve(){
    int x; cin >> x;
    cout << 360 / __gcd(x, 360) << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 3608
#include <cstdio>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <tuple>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long int ll;
using namespace std;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;



int main()
{

    int ans = 0;
    string s;
    cin >> s;

    bool color = (s[0] == 'B');

    for(int i = 0 ; i < s.length() ; i++)
    {
        if(( s[i] == 'B' ) != color )
        {
            ans++;
        }
        color = ( s[i] == 'B' );
    }

    cout << ans << endl;

   return 0 ;

}


Measured memory_bytes: 512
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#include<tuple>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
#define REP(i,n) for (int i = 1; i <= (int)n; i++)//i=1からi=nまで
#define RREP(i,n)for(int i=n;i>=1;i--) 
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const double pi = 3.14159265358979323846;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	int h1, h2, m1, m2,k; cin >> h1 >> m1 >>h2  >> m2>>k;
	int ans;
    ans = (h2 - h1) * 60 + m2 - m1 - k;
	if (ans < 0) {
		cout << 0 << endl;
	}
	else {
		cout << ans << endl;
	}
}


Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  int A[4];
  for (int i = 3; i >= 0; i--) {
    A[i] = n % 10;
    n /= 10;
  }
  for (int bit = 0; bit < (1 << 3); bit++) {
    int ans = A[0];
    (bit & (1 << 2)) ? ans += A[1] : ans -= A[1];
    (bit & (1 << 1)) ? ans += A[2] : ans -= A[2];
    (bit & (1 << 0)) ? ans += A[3] : ans -= A[3];
    if (ans == 7) {
      cout << A[0];
      (bit & (1 << 2)) ? cout << '+' : cout << '-';
      cout << A[1];
      (bit & (1 << 1)) ? cout << '+' : cout << '-';
      cout << A[2];
      (bit & (1 << 0)) ? cout << '+' : cout << '-';
      cout << A[3] << '=' << 7 << endl;
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
bool ispal(string a)
{
    long long int n=a.length();
    if(n==1)
        return true;
    else{
    int i=0,j;
    j=n-1;
    while(1)
    {
        if(a[i]!=a[j])
        {
            cout<<i<<" "<<j;
           return false;
        }
        i++,j--;
        if(i==j)
         {
        //     cout<<i<<" ";
             break;
        }
    }
    return true;
}}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  double s,d,t;
  cin>>d>>t>>s;
  double ti= d/s;
  if(ti<=t)
  {
      cout<<"Yes";
  }
  else
  {
      cout<<"No";
  }

 }


Measured memory_bytes: 3756
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

int main() {
    int A, B ,C;
    cin >> A >> B >> C;
    int x = B / A;
    if(x>C){
        x  = C;
    }

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
double M,a[20][3];
double dfs(int depth,int m,int n,int c,int *v){
	if(m==0){
		int i=0,j;
		double f0=0;
		for(;i<depth-1;i++)for(j=i+1;j<depth;j++){
			f0+=(a[v[i]][0]-a[v[j]][0])*(a[v[i]][0]-a[v[j]][0])+(a[v[i]][1]-a[v[j]][1])*(a[v[i]][1]-a[v[j]][1])+(a[v[i]][2]-a[v[j]][2])*(a[v[i]][2]-a[v[j]][2]);
		}
		if(M<f0)M=f0;
	}else{
		int i=c;
		for(;i<=n-m;i++){
			v[depth]=i;
			dfs(depth+1,m-1,n,i+1,v);
		}
	}
	return 0;
}

v[20];
main(n,m,i,j){
	scanf("%d%d",&n,&m);
	if(m<2)puts("0"),exit(0);
	for(i=0;i<n;i++)
		for(j=0;j<3;j++)scanf("%lf",a[i]+j);
	M=0;
	dfs(0,m,n,0,v);
	printf("%f\n",M);
exit(0);
}

Measured memory_bytes: 664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vector<vector<P>> g(n);
  rep(i, n - 1) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    g[a].push_back({b, c});
    g[b].push_back({a, c});
  }
  ll m, k;
  cin >> m >> k;
  k--;
  vl d(n, -1);
  d[k] = 0;
  queue<int> q;
  q.push(k);
  while(!q.empty()) {
    int i = q.front();
    q.pop();
    for(auto v : g[i]) {
      ll ni = v.first;
      if(d[ni] != -1) continue;
      ll c = v.second;
      d[ni] = d[i] + c;
      q.push(ni);
    }
  }
  rep(_, m) {
    ll x, y;
    cin >> x >> y;
    x--;
    y--;
    cout << d[x] + d[y] << endl;
  }
}

Measured memory_bytes: 11604
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
using namespace std;


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

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

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

	char c;
	cin >> c;

	bool ans = 0;

	ans |= (c == 'a');
	ans |= (c == 'e');
	ans |= (c == 'i');
	ans |= (c == 'o');
	ans |= (c == 'u');

	cout << (ans ? "vowel" : "consonant") << endl;

	return 0;
}


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

unsigned long long exist_num(unsigned long long start, unsigned long long end, unsigned long long exist) {
	return end/exist - (start-1)/exist;
}

unsigned long long gcd(unsigned long long a, unsigned long long b) {
	if (a%b) {
		return gcd(b, a%b);
	}
	return b;
}

int main() {
	unsigned long long A, B, C, D;
	cin >> A >> B >> C >> D;
	unsigned long long result = exist_num(A, B, C);
	result += exist_num(A, B, D);
	result -= exist_num(A, B, C*D/gcd(D, C));
	cout << (B-A+1)-result << endl;
}


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

const int INF = 1e9;

signed main(){
	int n,m,a[3];
	vector<int> G[55];
	cin >> n >> m;
	for(int i = 0;i < 3;i++) cin >> a[i];
	bool canReach[55][110][55] = {};
	for(int i = 0;i < m;i++){
		int u,v;
		cin >> u >> v; u--;v--;
		G[u].push_back(v);
		canReach[u][1][v] = true;
	}
	for(int i = 2;i <= 100;i++){
		for(int j = 0;j < n;j++){
			for(int to : G[j]){
				for(int k = 0;k < n;k++) canReach[j][i][k] |= canReach[to][i - 1][k];
			}
		}
	}
	int dist[55];
	for(int i = 0;i < n;i++) dist[i] = INF;
	dist[n - 1] = 0;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			int ds[3] = {INF,INF,INF};
			for(int k = 0;k < 3;k++){
				for(int l = 0;l < n;l++){
					if(canReach[j][a[k]][l]) ds[k] = min(ds[k],dist[l] + 1);
				}
			}
			dist[j] = min(dist[j],max({ds[0],ds[1],ds[2]}));
		}
	}
	if(dist[0] == INF) cout << "IMPOSSIBLE" << endl;
	else cout << dist[0] << endl;
}


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

using namespace std;

int check(double cx1, double cy1, double r1,
          double cx2, double cy2, double r2){

  double distance = sqrt((cx2 - cx1)*(cx2 - cx1) + (cy2 - cy1)*(cy2 - cy1));

  if(distance == r1 + r2) return 3;
  if(distance == abs(r1 - r2)) return 1;
  if(abs(r1 - r2) < distance && distance < r1 + r2) return 2;
  if(distance > r1 + r2) return 4;
  if(distance < abs(r1 - r2)) return 0;
}

int main(){
  double cx1 = 0, cy1 = 0, r1 = 0;
  double cx2 = 0, cy2 = 0, r2 = 0;
  cin >> cx1;
  cin >> cy1;
  cin >> r1;

  cin >> cx2;
  cin >> cy2;
  cin >> r2;

  // cout << cx1 << " " << cy1 << " " << r1 << endl;
  // cout << cx2 << " " << cy2 << " " << r2 << endl;

  cout << check(cx1, cy1, r1, cx2, cy2, r2) << endl;

  return 0;
}



Measured memory_bytes: 3228
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);


int main()
{
    IOS();
    ll n,k;
    cin>>n>>k;
    ll tt=0;
    for(int i=k+1;i<=n;i++)
    {
      tt+=((n-n%i)/i)*(i-k);
      tt+=max(0LL,n%i-(k-1));
      if(k==0)tt--;
      //debug(tt);
    }
    cout<<tt<<endl;

}


Measured memory_bytes: 256
object Main extends App{
  val sc = new java.util.Scanner(System.in)
  val N= sc.nextInt
  val s = sc.next
  val Rcount = s.filter(_=='R').length
  val Bcount = s.filter(_=='B').length
  val ans = if(Rcount > Bcount){"Yes"}else{"No"}
  println(ans)
}


Measured memory_bytes: 25652
def main():
    N = int( input())
    for x in range(1,3501):
        if 4*x - N < 0:
            continue
        for y in range(1, 3501):
            if 4*x*y <= N*(x+y):
                continue
            if N*x*y%(4*x*y-N*(x+y)) == 0:
                print(x, y, N*x*y//(4*x*y-N*(x+y)))
                return
if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	int k;
	scanf("%d%d%d",&a,&b,&c);
	scanf("%d",&k);
	int cnt=0;
	while(b<=a) b*=2,cnt++;
	while(c<=b) c*=2,cnt++;
	if(cnt<=k) printf("Yes");
	else printf("No");
	return 0;
 } 

Measured memory_bytes: 3748
A, B, C, D = map(int,input().split())

def shohai(A, B, C, D):
    while A > 0 and C > 0:
        C -= B
        A -= D
        if C <= 0:
            return('Yes')
            break
        if A <= 0:
            return('No')
            break
      

ans = shohai(A,B,C,D)
print(ans)

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

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

    vector<int> ans;

    for(int i=0; i<n; i++) {
        int a,b;
        cin >> a >> b;
        if(b <= t) {
            ans.push_back(a);
        }
    }
    sort(ans.begin(), ans.end());

    if(ans.size() == 0) cout << "TLE" << endl;
    else cout << ans[0] << endl;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

void solve()
{
    LL X;
    cin >> X;

    LL ans = (X / 500) * 1000;
    X %= 500;
    ans += (X / 5) * 5;
    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

void work() {
    int n; cin>>n;
    vector<int> v(n); for (int i = 0; i < n; ++i) cin>>v[i];
    int ans = iinf;
    for (int i = 1; i <= 100; ++i) {
        int cur = 0;
        for (int j = 0; j < n; ++j) {
            cur += (v[j] - i) * (v[j] - i);
        }
        ans = min(ans, cur);
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    work();

    return 0;
}


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

#define INF (1e9)
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> H(N);

    int highest = -INF;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
        highest = max(highest, H[i]);
        if (H[i] >= highest)
        {
            ans += 1;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)


typedef long long ll;
typedef unsigned long long int llt;

const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

string ans ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ans += to_string(x);
     return;
}

llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}



int main()
{
  int n;
  cin>>n;
  int arr[n];
  for(int i=0; i<n;i++)
    cin>>arr[i];
  int ans = 0;
  for(int i=0; i<n;i++)
    for(int j=i+1; j<n;j++)
      ans += (arr[i]*arr[j]);
  cout<<ans<<endl;
  return 0;
}


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



int main(){
    int n;
    cin>>n;
    int a,b;
    if(n==1){
        cout<<"Hello World"<<endl;
    }else{
        cin>>a>>b;
        cout<<a+b<<endl;     }
    return 0;
}



Measured memory_bytes: 256
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll INF = 1e18;
V dp;
VV vec;
ll dfs(int x){
    if(dp[x]!=-1)
        return dp[x];
    if(vec[x].empty()){
        dp[x] = 0;
        return 0;
    }
    ll Max = 0;
    rep(i,vec[x].size()){
        chmax(Max, dfs(vec[x][i]) + 1);
    }
    dp[x] = Max;
    return Max;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    dp.resize(n,-1);
    vec.resize(n);
    rep(i,m){
        ll x,y;
        cin >> x >> y;
        x--;
        y--;
        vec[x].push_back(y);
    }
    ll Max = 0;
   // rep(i,n)cout<<dfs(i)<<" ";
    //cout<<endl;
    rep(i, n) chmax(Max, dfs(i));
    cout << Max << endl;
}


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

int main()
{
    int a[5]={},sum=0,m=0;
    for(int i=0;i<5;i++)
        {
            cin>>a[i];
            sum+=((a[i]+9)/10 * 10);
            m = max(m,(((a[i]+9)/10 * 10)-a[i]));
        }
    cout<<sum-m;
    return 0;
}



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

using namespace std;
using ll = long long;

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

int main() {
  int n;
  cin >> n;
  int x[n], y[n];
  rep(i, n) { cin >> x[i] >> y[i]; }

  auto f = [](int n) {
    int res = 1;
    rep(i, n) res *= i + 1;
    return res;
  };

  double ans = 0;
  rep(i, n) rep(j, n) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    double d = sqrt((dx * dx) + (dy * dy));
    ans += d;
  }

  ans *= f(n - 1);
  ans /= f(n);

  printf("%.10f\n", ans);

  return 0;
}


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

int v[1100]={0}, w[1100]={0}, dp[1100][11000]={{0}};

int main(){
  int n,W;
  cin >> n >> W;
  for(int i = 0;i < n;i++) cin >> v[i] >> w[i];
 
  for(int i = 0; i < n; i++)
    for(int j = 0; j <= W; j++)
        dp[i+1][j] = (j-w[i]>=0) ? max(dp[i][j], dp[i+1][j-w[i]]+v[i]) : dp[i][j];
    
  
  cout << dp[n][W] << endl;
  
  return 0;
}


Measured memory_bytes: 7376
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int P, Q, R; cin >> P >> Q >> R;
  cout << min({P+Q, Q+R, R+P}) << endl;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
a=['']*h
for i in range(h):
    a[i]=input()

row=[False]*h
col=[False]*w
for i in range(h):
    for j in range(w):
        if a[i][j]=='#':
            row[i]=True
            col[j]=True

for i in range(h):
    char=''
    if row[i]:
        for j in range(w):
            if col[j]:
                char+=a[i][j]
            else:
                continue
    else:
        continue
    print(char)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<62;
const double eps=1e-5;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	int n;cin>>n;
	vector<ll> x(n+10),lo(n+10);
	for(int i=0;i<n;i++)cin>>x[i];
	for(int i=1;i<n;i++){
		lo[i]=x[i]-x[i-1];
	}
	int m;ll k;cin>>m>>k;
	vector<int> a(m+10);
	for(int i=0;i<m;i++){
		cin>>a[i];
	}
	vector<vector<int>> v(70,vector<int>(n));
	for(int i=1;i<n;i++)v[0][i]=i;
	for(int i=0;i<m;i++){
		swap(v[0][a[i]],v[0][a[i]-1]);
	}
	for(int i=0;i<=61;i++){
		for(int j=1;j<n;j++){
			v[i+1][j]=v[i][v[i][j]];
		}
	}
	vector<int> s(n);
	for(int i=1;i<n;i++){
		int pos=i;
		for(ll j=0;j<=61;j++){
            if(k&(1LL<<j)){
                pos=v[j][pos];
            }
        }
		s[i]=pos;
	}
	vector<ll> ans(n);
	ans[0]=x[0];
	for(int i=1;i<n;i++){
		ans[i]=ans[i-1]+lo[s[i]];
	}
	assert(ans[n-1]==x[n-1]);
	for(int i=0;i<n;i++){
		cout<<ans[i]<<endl;
	}
}


Measured memory_bytes: 31864
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 62;
int main() {
  //
  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  ll s = 0;
  rep(i, n) s ^= a[i];
  ll ans = s;
  rep(i, n) { a[i] &= ~s; }
  int r = 0;
  for (int i = 60; i >= 0; i--) {
    int j = r;
    for (; j < n; j++) {
      if (a[j] >> i & 1) {
        swap(a[r], a[j]);
        break;
      }
    }
    if (j == n) continue;
    rep(k, n) {
      if (k == r) continue;
      if (a[k] >> i & 1) a[k] ^= a[r];
    }
    ++r;
  }

  ll x = 0;
  rep(j, r) {
    x = x ^ a[j];

  }
  ans += x * 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <stack>
#include <cmath>

int c2i(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return -1;
	}
}

int str2i(std::string str) {
	int x = 0;
	for (int i = 0; i < str.size(); i++)
		x += c2i(str[str.size()-1 -i]) * std::pow(10,i);
	return x;
}


int main() {
	std::string in;
	std::stack<int> s;
	while (std::cin >> in) {
		if (in == "+" || in == "-" || in == "*" || in == "/") {
			char op = in[0];
			int b = s.top();
			s.pop();
			int a = s.top();
			s.pop();
			switch (op) {
			case '+':
				s.push(a + b);
				break;
			case '-':
				s.push(a - b);
				break;
			case '/':
				s.push(a / b);
				break;
			case '*':
				s.push(a * b);
				break;
			}
		}
		else 
			s.push(str2i(in));
		//std::cout << s.top() << std::endl;
	}
	std::cout << s.top() << std::endl;


	return 0;
}

Measured memory_bytes: 3384
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {
	int a, b, ans;

	while ((cin >> a >> b) != 0) {
		a = a + b;
		for (ans = 0; a > 0; ans++) a /= 10;
		cout << ans << endl;
	}

	return 0;
}

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

typedef long long ll;

int dp[5005][5005];

int main() {
    int N;
    cin >> N;
    if (N%2 == 0) cout << fixed <<  setprecision(6) << 0.5 << endl;
    else cout << fixed << setprecision(6) << (double)(N+1)/2/N << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define D 4

struct LIST{
	char data[13];
	struct LIST *left,*right;
};

int convert(char s){
	if(s=='A'){
		return 0;
	}else if(s=='C'){
		return 1;
	}else if(s=='G'){
		return 2;
	}else{
		return 3;
	}
}

int show(struct LIST *L){
	
	if(L==NULL){return 0;}

	printf("%s\n",L->data);
	show(L->left);
	show(L->right);
	
	return 0;
}

void insert(struct LIST *L,char data[]){
	struct LIST *add=(struct LIST*)malloc(sizeof(struct LIST));
	strcpy(add->data,data);
	add->left=NULL;
	add->right=NULL;
	
	while(1){
		if(strcmp(L->data,data)==NULL){break;}

		if(strcmp(data,L->data)<0){
			if(L->left==NULL){
				L->left=add;
				break;
			}
			L=L->left;
		}else{
			if(L->right==NULL){
				L->right=add;
				break;
			}
			L=L->right;
		}
	}
}

void find(struct LIST *L,char data[]){
	while(L!=NULL){
		if(strcmp(L->data,data)==0){
			printf("yes\n");
			break;
		}

		if(strcmp(data,L->data)<0){
			L=L->left;
		}else{
			L=L->right;
		}
		if(L==NULL){
			printf("no\n");
		}
	}
}

int main(){
	int n;
	char command[13],data[13];
	struct LIST L;

	strcpy(L.data,"E");
	L.left=NULL;
	L.right=NULL;
	
	scanf("%d",&n);

	for(int i=0;i<n;i++){
		scanf("%s %s",command,data);
		if(strcmp(command,"insert")==0){
			insert(&L,data);
		}else{
			find(&L,data);
		}
		//show(&L);
	}

	return 0;
}


Measured memory_bytes: 28536
#include<iostream>

using namespace std;

int main(void)
{
  string s; cin>>s;
  
  if((s[2]=='1')&&(s[3]=='9')){
    if((s[5]=='0')&&(s[6]<='4')){puts("Heisei");}
    else{puts("TBD");}
  }
  
  return 0;
}

Measured memory_bytes: 256
<?php

$sum = 0;
$min = 10;
for($i=0;$i<5;$i++){
    list($t) = fscanf(STDIN, '%d');
    if($t%10 === 0) $sum += $t;
    else if(substr($t,-1)<$min) {
        $sum += ceil($t/10)*10;
        $min = substr($t,-1);
    }
    else $sum += ceil($t/10)*10;
}
$sum -= (10 - $min);
echo $sum;

Measured memory_bytes: 4856
object Main extends App {
  import java.util.Scanner
  import scala.collection.mutable.ArrayBuffer
  val sc = new Scanner(System.in)
  val n = sc.nextInt()
  val m = sc.nextInt()
  val h = (1 to n).map { i =>
    sc.nextInt()
  }
  val flags = ArrayBuffer.fill(n)(true)
  (1 to m).foreach { _ =>
    val a = sc.nextInt() - 1
    val b = sc.nextInt() - 1
    val ha = h(a)
    val hb = h(b)
    if (ha == hb) {
      flags(a) = false
      flags(b) = false
    } else if (ha > hb) {
      flags(b) = false
    } else {
      flags(a) = false
    }
  }

  val result = flags.count(_ == true)
  println(result)
}


Measured memory_bytes: 63884
/*Allah Vorosha*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define n_p next_permutation
#define p_p prev_permutation
#define in insert
#define rev reverse
#define pf push_front
#define pob pop_back
#define uniq(v)         v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define all(x) (x).begin(),(x).end()
#define pof pop_front
#define ios ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define scn scanf
#define prt printf
#define rep(i, a, n) for(int i = a; i < n; i++)
#define mod 1000000007
#define yes cout << "YES\n"
#define no cout << "NO\n";
#define take for(auto &it : a) cin >> it;
#define out cout << a << "\n";
#define l_b lower_bound
#define u_b upper_bound
#define Max 100005
template<typename T> T mymax(T x, T y) {
    return (x > y ? x : y);
}
 
using namespace std;
 
const int N = 2e5 + 5;
int n;
vector<int> a;
int dp[N][3];
 
int myfucn(int i, int t) {
    if(i >= n) return 0;
    if(dp[i][t] != -1) return dp[i][t];
    int ret;
    if(t) {
        ret = myfucn(i + 1, 0);
        ret = min(ret, myfucn(i + 2, 0));
    }
    else {
        ret = myfucn(i + 1, 1) + (a[i] == 1);
        int o = 0;
        if(i + 1 < n) o = a[i + 1];
        ret = min(ret, myfucn(i + 2, 1) + (a[i] == 1) + o);
    }
    dp[i][t] = ret;
    return ret;
}
void solve() {
    long long x, k, d;
    cin >> x >> k >> d;
    ll a = x % d;
    ll p = abs(a - x);
    p /= d;
    //cout << p << '\n';
    if(p < k) {
        if(a < 0) {
            ll y = k - p;
          if(y % 2 == 1) a += d;
        }
        else if(a > 0) {
            ll y = k - p;
          if(y % 2 == 1) a -= d;
        }
        else {
            ll y = k - p;
            if(y % 2 == 1) a += d;
        }
    }
    if(p > k) {
        p -= k;
        if(x < 0) a -= (d * p);
        else a += (d * p);
    }
    printf("%lld\n", abs(a));
    return;
}
 
int main() {
 
    solve();
    return 0;
}

Measured memory_bytes: 3756
n,k = map(int,input().split())
sss = input()

now = 1
cnt = 0
x = []

for i in range(n):
    if sss[i] == str(now):
        cnt += 1
    else:
        x.append(cnt)
        now = 1 - now
        cnt = 1
if cnt != 0:
    x.append(cnt)
if len(x) % 2 == 0:
    x.append(0)

Add = 2 * k + 1
ans = 0

y = [0]
for i in range(len(x)):
    y.append(y[i] + x[i])

for i in range(len(x))[::2]:
    left = i
    right = min(i + Add, len(x))
    tmp = y[right] - y[left]    
    
    ans = max(tmp, ans)

print(ans)

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, K; scanf("%d %d", &N, &K);
  map<int, int> freqs;
  int a;
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a);
    ++freqs[a];
  }
  int cnt = freqs.size() - K;
  int ans = 0;
  if (cnt > 0) {
    vector<int> v;
    for (pair<int, int> p : freqs) {
      v.push_back(p.second);
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < cnt; ++i) {
      ans += v[i];
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 10748
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int L, R, D;
  cin >> L >> R >> D;
  int ans = R / D - (L-1) / D;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3632
#include <vector>
#include <iostream>
#include <valarray>
#include <string>
#include <algorithm>
#include <set>
#include <complex>
#include <cmath>
#include <cstdio>
#define fst first
#define snd second
#define rep(i,n) for(ull i = 0;i<(n);i++)
#define rep1(i,n) for(ull i = 1;i<=(n);i++)
#define revrep(i,n) for(ull i = (n-1);i>=0;i--)
#define all(n) (n).begin(),(n).end()
#define show(x) cout << "debug " << #x << ":" << x << endl;
#define showvec(x) cout << endl << "debug " << #x << ";" << endl; \
    for(ull __i = 0;__i < x.size();__i++){ \
        for(ull __j = 0;__j<x[0].size();__j++){ \
            cout << x[__i][__j] << " "; \
        } \
        cout << endl; \
    } \
    cout << endl;
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef complex<double> xy_t;
double dot_product(xy_t a, xy_t b){
	return (conj(a)*b).real();
}

double cross_product(xy_t a, xy_t b){
	return (conj(a)*b).imag();
}

const double eps = 1e-11;
int N;
int main(){
	double x[4],y[4];
	cin >> N;
	rep(_n,N){
		rep(i,4){
			cin >> x[i] >> y[i];
		}
		xy_t a,b;
		a = xy_t(x[0],y[0]) - xy_t(x[1],y[1]);
		b = xy_t(x[2],y[2]) - xy_t(x[3],y[3]);
		cout << ((abs(cross_product(a,b)) < eps) ? "YES" : "NO") << endl;
	}
	return 0;
}

Measured memory_bytes: 1228
#include <stdio.h>
int main(void);

int main(void){

    int i, a, b, c, Yakusu;
    scanf("%d %d %d", &a, &b, &c);
    
    for(i = a; i <= b; i++){
        
        if(c % i == 0){
            
            Yakusu++;
            
        }
    }

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

}


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

int main() {
	const int n = 4;
	const int m = 3;
	const int f = 10;
	
	int dat[n][m][f] = {};
	
	int q;
	cin >> q;
	while (q--) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		dat[a - 1][b - 1][c - 1] += d;
	}
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			for (int k = 0; k < f; k++) {
				cout << ' ' << dat[i][j][k];
			}
			cout << '\n';
		}
		if (i + 1 < n) {
			cout << string(20, '#') << '\n';
		}
	}
	
	return 0;
}


Measured memory_bytes: 3156
#include <stdio.h>
#include <string.h>
#include <algorithm>

#define rep(i,st,ed) for (int i=st;i<=ed;++i)
#define fi first
#define se second

typedef std:: pair <int,int> pair;
const int INF=0x3f3f3f3f;
const int N=200005;

struct edge {int x,y,next;} e[N*2];

int f[N],g[N],h[N],size[N];
int ls[N],edCnt;
int Ah[N],r[N];

char s[N];

int read() {
	int x=0,v=1; char ch=getchar();
	for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):v,ch=getchar());
	for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
	return x*v;
}

void add_edge(int x,int y) {
	e[++edCnt]=(edge) {x,y,ls[x]}; ls[x]=edCnt;
	e[++edCnt]=(edge) {y,x,ls[y]}; ls[y]=edCnt;
}

void dfs1(int x,int fa) {
	size[x]=(s[x]=='W');
	for (int i=ls[x];i;i=e[i].next) {
		if (e[i].y==fa) continue;
		dfs1(e[i].y,x),size[x]+=size[e[i].y];
	}
}

void dfs2(int x,int fa) {
	int sum=0,son=0;
	for (int i=ls[x];i;i=e[i].next) {
		if (e[i].y==fa||!size[e[i].y]) continue;
		dfs2(e[i].y,x),++son;
		sum+=f[e[i].y];
	}
	if (!son&&s[x]=='W') return (void) (f[x]=g[x]=1);
	int wjp=son&1;
	f[x]=g[x]=sum;
	f[x]+=son+1;
	if (s[x]=='W') f[x]+=wjp;
	else f[x]+=!wjp;
	for (int i=ls[x];i;i=e[i].next) {
		if (e[i].y==fa||!size[e[i].y]) continue;
		g[x]=std:: min(g[x],sum-f[e[i].y]+g[e[i].y]);
	}
	g[x]+=son;
	if (s[x]=='W') g[x]+=!wjp;
	else g[x]+=wjp;
	g[x]=std:: min(g[x],f[x]);
	h[x]=INF;
	if (son>1) {
		int mx1=0,mx2=0;
		for (int i=ls[x];i;i=e[i].next) {
			if (e[i].y==fa||!size[e[i].y]) continue;
			int v=f[e[i].y]-g[e[i].y];
			if (v>mx1) mx2=mx1,mx1=v;
			else if (v>mx2) mx2=v;
		}
		h[x]=sum-mx1-mx2+son-1;
		if (s[x]=='W') h[x]+=wjp,r[x]=wjp;
		else h[x]+=!wjp,r[x]=!wjp;
	}
	for (int i=ls[x];i;i=e[i].next) {
		if (e[i].y==fa||!size[e[i].y]) continue;
		int v=sum-f[e[i].y]+h[e[i].y]+son+2*!r[e[i].y];
		int t=(s[x]=='W')?(!wjp):wjp;
		if (v+t<h[x]) h[x]=v+t,r[x]=t;
	}
}

int main(void) {
	int n=read();
	rep(i,2,n) add_edge(read(),read());
	scanf("%s",s+1);
	dfs1(1,0);
	dfs2(1,0);
	// solve(1,0);
	int ans=INF;
	rep(i,1,n) if (size[i]==size[1]) {
		ans=std:: min(ans,f[i]);
		ans=std:: min(ans,g[i]);
		ans=std:: min(ans,h[i]);
	}
	ans=(size[1]<=1)?size[1]:ans;
	printf("%d\n", ans);
	return 0;
}

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

int main()
{
  int N;
  while (cin >> N && N != 0) {
    vector<vector<int> > v(N, vector<int>(31, 0));
    for (int i = 0; i < N; i++) {
      int n;
      cin >> n;
      for (int j = 0; j < n; j++) {
        int x;
        cin >> x;
        v[i][x] = 1;
      }
    }

    vector<unsigned long long> w(N, 0);
    for (int i = 0; i < N; i++) {
      w[i] = 1ULL<<i;
    }

    for (int d = 1; d <= 30; d++) {
      vector<int> us(N, 0);
      unsigned long long s = 0ULL;
      for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
          if (v[i][d] && v[j][d]) {
            us[i] = us[j] = 1;
            s |= w[i] | w[j];
          }
        }
      }
      if (s == (1ULL<<N)-1) {
        cout << d << endl;
        goto NEXT;
      }
      for (int i = 0; i < N; i++) {
        if (us[i]) {
          w[i] = s;
        }
      }
    }
    cout << -1 << endl;
NEXT:
    ;
  }
}

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

int main(){
int N, Y;
  cin >> N >> Y;
 int x=-1,y=-1, z=-1;
  for(int a=0 ;a<=N ; a++){
     for(int b=0 ;a+b <=N ; b++){
         int c=N-a-b;
         int total = 10000*a + 5000*b +1000*c;
         if(total==Y){
            x=a;
            y=b;
            z=c;
         }
         
     }
  
  }
  cout << x <<" "<< y << "  "<< z << endl;
}


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

using namespace std;

int main(void)
{
    int N, K;
    double s = 0, p, t;
    int i;
    cin >> N >> K;
    for(i = 1; i <= N; i++) {
        p = N;
        for(t = i;t < K; t*=2) {
            p *= 2.0;
        }
     //   cout << i << " " << p << endl;
        s += 1 / p;
    }
    cout << setprecision(13) << s << endl;

}


Measured memory_bytes: 256
function main(input){
  var _input = input.split(' ')
  var N = parseInt(_input[0]) 
  var min = parseInt(_input[1]) 
  var max = parseInt(_input[2]) 
  compute(N, min, max)
}
function compute(N, min, max){

  var result = 0
  var ranks = [10000, 1000, 100, 10, 0]

  for(var i = 1; i <= N; i++){
    var tTotal = 0
    var invalid = false
    var _i = i
    for(var d = 0; d < ranks.length; d++) {
      var rank = ranks[d]
      var digit = rank !== 0 ? Math.floor(_i / rank) : _i
      tTotal += digit
      if (tTotal > max) {
        invalid = true
        break
      }
      _i-=(rank * digit)
    }
    if(tTotal >= min && !invalid) result += i
  }
  console.log(result)
  
}

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

Measured memory_bytes: 7624
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a ; i <= b; ++ i) 
const int N = 2005, mo = 924844033 ;
using namespace std ;

int n, m, f[N][N][4], q[N] ;

void upd(int &x, int y) { x = (x + y) % mo ; }

int main() {
	scanf("%d%d", &n, &m) ;
	q[0] = 0 ;
	rep(i, 1, m) for (int j = i ; j <= n ; j += m) q[++ q[0]] = j ;
	f[1][0][0] = 1 ;
	rep(i, 2, n) rep(j, 0, i - 1) {
		if ((q[i] % m) != (q[i - 1] % m)) {
			upd(f[i][j][0], ((ll) f[i - 1][j][0] + f[i - 1][j][1] + f[i - 1][j][2] + f[i - 1][j][3]) % mo) ;
			upd(f[i][j][3], ((ll) f[i - 1][j][0] + f[i - 1][j][1] + f[i - 1][j][2] + f[i - 1][j][3]) * (i - j - 1) % mo) ;
			if (j) upd(f[i][j - 1][3], ((ll) f[i - 1][j][0] + f[i - 1][j][1] + f[i - 1][j][2] + f[i - 1][j][3]) * j % mo) ;
		} else {
			upd(f[i][j][0], ((ll) f[i - 1][j][0] + f[i - 1][j][1] + f[i - 1][j][2] + f[i - 1][j][3]) % mo) ;
			upd(f[i][j + 2][1], f[i - 1][j][0]) ;
			upd(f[i][j][2], ((ll) f[i - 1][j][1] * 2 % mo + f[i - 1][j][2]) % mo) ;
			upd(f[i][j + 1][2], ((ll) f[i - 1][j][2] + f[i - 1][j][3] * 2) % mo) ;
			if (j) upd(f[i][j - 1][3], ((ll) f[i - 1][j][0] * j % mo + (ll) f[i - 1][j][2] * (j - 1) % mo + (ll) f[i - 1][j][3] * j % mo + (ll) f[i - 1][j][1] * (j - 2) % mo) % mo) ;
			upd(f[i][j][3], ((ll) f[i - 1][j][0] * (i - j - 2) % mo + (ll) f[i - 1][j][2] * (i - j - 2) % mo + (ll) f[i - 1][j][3] * (i - j - 3) % mo + (ll) f[i - 1][j][1] * (i - j - 1) % mo) % mo) ;
		}
	}
	printf("%d\n", ((f[n][0][0] + f[n][0][3]) % mo + mo) % mo);
	return 0 ;
}

Measured memory_bytes: 61184
//32
#include<cstdio>
#include<cmath>
#include<complex>

using namespace std;

int main(){
  double x,y,px,py;
  scanf("%lf,%lf%lf,%lf",&x,&y,&px,&py);
  double s=0;
  complex<double> p(x,y),pp(px,py);
  for(double cx,cy;scanf("%lf,%lf",&cx,&cy)!=EOF;){
    complex<double> cp(cx,cy);
    double a=abs(pp-p),b=abs(cp-p),c=abs(cp-pp);
    double z=(a+b+c)/2;
    s+=sqrt(z*(z-a)*(z-b)*(z-c));
    pp=cp;
  }
  printf("%.6f\n",s);
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
vector<int> toposort(int n,vector<int> G[],int h[]){
    stack<int> st;
    vector<int> res;
    for(int i=0;i<n;i++){
        if(!h[i])st.push(i);
    }
    while(!st.empty()){
        int id=st.top();
        st.pop();
        res.push_back(id);
        for(auto e:G[id]){
            h[e]--;
            if(!h[e])st.push(e);
        }
    }
    return res;
}
int main(){
    int n,m;cin>>n>>m;
    vector<int> G[10010];
    int h[10010];
    for(int i=0;i<m;i++){
        int s,t;cin>>s>>t;
        G[s].push_back(t);
        h[t]++;
    }
    vector<int> ans=toposort(n,G,h);
    for(auto e:ans){
        cout<<e<<endl;
    }
}



Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin>>H>>W;
  vector<string>data(H);
  int count=0;
  for(int i=0;i<H;i++)cin>>data[i];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(data[i][j]=='#')
      count++;
    }
  }

  vector<vector<int>>dist(H,vector<int>(W,-1));
  using pir=pair<int,int>;
  queue<pir> que;

  dist[0][0]=1;
  que.push(pir(0,0));

  int dx[4]={0,0,1,-1};
  int dy[4]={1,-1,0,0};
  while(!que.empty()){
    auto v=que.front();
    que.pop();
    for(int i=0;i<4;i++){
      int nx=v.second+dx[i];
      int ny=v.first+dy[i];
      if(nx<0||nx>=W||ny<0||ny>=H)continue;
      if(dist[ny][nx]!=-1)continue;
      if(data[ny][nx]=='#')continue;
      dist[ny][nx]=dist[v.first][v.second]+1;
      que.push(pir(ny,nx));
    }
  }
  if(dist[H-1][W-1]==-1){
    cout<<-1<<endl;
    return 0;
  }
  int ans=H*W-dist[H-1][W-1]-count;
  cout<<ans<<endl;
}


Measured memory_bytes: 3652
import Control.Monad
import Control.Applicative

main :: IO ()
main = do
  [k,s] <- map read . words <$> getLine
  let ans = [s-a-b | a <- [0..k], b <- [0..k], 0 <= (s - a - b) && (s - a - b) <= k]
  print $ length ans


Measured memory_bytes: 1148
#include <iostream>

using namespace std;

int main() {
    string S, T;
    cin >> S >> T;
    int n = S.length();
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(S[i] != T[i]){
            ans++;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3920