akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

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

    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();

    int X = sc.nextInt();
    int Y = sc.nextInt();

    int result ;

      if(A + B <= 2 * C){
        result = A * X + B * Y ;
      }else {
        if(X <= Y ){
          if(B <= 2 *C){
            result = C * 2 * X + B * (Y - X);
          } else {
            result = C * 2 * Y ;
          }
        } else{
          if(A <= 2 * C){
            result = C * 2 * Y + A * (X - Y);
          } else {
            result = C * 2 * X;
          }
        }
      }
      System.out.println(result);
    }
  }


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
using P = pair<long long, long long>;

struct data {
  long long u, v, c;
};

long long n, m;
string bw;
vector<data> edge;
vector<P> d;
vector<map<long long, long long>> memo;
vector<set<long long>> lst;
vector<bool> ch;
vector<long long> dnum;

bool solve();

int main() {
  cin >> n >> m;
  dnum.resize(n);
  ch.assign(n, 0);
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    dnum[i] = x;
    d.push_back({x, i});
    bw += "-";
  }
  sort(d.begin(), d.end());
  memo.resize(n);
  for(int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    edge.push_back({u, v, (long long)1e9});
    memo[u][v] = i;
    memo[v][u] = i;
  }
  if(solve()) {
    cout << bw << endl;
    for(int i = 0; i < m; ++i) cout << edge[i].c << endl;
  }
  else
    cout << -1 << endl;
  return 0;
}

bool solve() {
  lst.resize(n);
  for(int i = 0; i < n;) {
    long long numd = d[i].fi, id = i;
    while(i < n && d[i].fi == numd) {
      for(auto now : memo[d[i].se])
        if(edge[now.se].c == (long long)1e9)
          lst[now.fi].insert(d[i].se);
      ++i;
    }
    for(int j = i - 1; j >= id; --j) {
      P nowd = d[j];
      if(ch[nowd.se]) continue;
      if(lst[nowd.se].size() == 0) return 0;
      int nowid = *(lst[nowd.se].begin());
      if(bw[nowid] == 'B')
        bw[nowd.se] = 'W';
      else {
        bw[nowd.se] = 'B';
        if(bw[nowid] == '-') bw[nowid] = 'W';
      }
      edge[memo[nowd.se][nowid]].c = nowd.fi;
      lst[nowid].erase(nowd.se);
      if(dnum[nowid] == numd) ch[nowid] = 1;
    }
  }
  return 1;
}


Measured memory_bytes: 60424
#include<stdio.h>
int main()
{
    long long int n,i,j,p,q,r,s;
    scanf("%lld",&n);
    long long int a[n],t[n];
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
        s=a[0];
    }
    if(s<0) s=s*-1;
    for(i=0;i<n-1;i++)
    {
        p=a[i]-a[i+1];
        if(p<0) p=p*-1;
        s=s+p;
    }
    p=a[n-1];
    if(p<0) p=p*-1;
    s=s+p;
    for(i=0;i<n;i++)
    {
        if(i==0)
        {
            p=0-a[i];
            if(p<0) p=p*-1;
            q=a[i]-a[i+1];
            if(q<0) q=q*-1;
            r=0-a[i+1];
            if(r<0) r=r*-1;
            t[i]=s-p-q+r;
        }
        else if(i==(n-1))
        {
            p=a[i-1]-a[i];
            if(p<0) p=p*-1;
            q=a[i];
            if(q<0) q=q*-1;
            r=a[i-1];
            if(r<0) r=r*-1;
            t[i]=s-p-q+r;
        }
        else
        {
            p=a[i-1]-a[i];
            if(p<0) p=p*-1;
            q=a[i]-a[i+1];
            if(q<0) q=q*-1;
            r=a[i-1]-a[i+1];
            if(r<0) r=r*-1;
            t[i]=s-p-q+r;
        }
    }
    for(i=0;i<n;i++)
    {
        printf("%lld\n",t[i]);
    }
    return 0;
}


Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a;i<b;i++)
#define vi vector<int>
#define vii vector<ll>
#define all(x) x.begin(),x.end()
#define mod 998244353
#define pb push_back
#define ii pair<int,int>
#define iii pair<ll,ll>
#define MAX 10000000000000
typedef long long ll;
int main()
{
  ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
  int n,k; cin>>n>>k;
  vii a(n),dp(n,MAX);
  f(i,0,n) cin>>a[i];
  dp[0]=0;
  f(i,1,n)
  {
    f(j,1,min(i,k)+1) dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
  }
  cout<<dp[n-1]<<endl;
  return 0;
}


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

int main(){
    int n,T;
    cin >> n >> T;
    int ans=10000;
    rp(i,n){
        int c,t;
        cin >> c >> t;
        if(t<=T) ans=min(ans,c);
    }
    if(ans==10000)cout << "TLE" << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int seg[1200006], ss;
int max(int a, int b)
{
	if (a > b)
		return a;
	else
		return b;
}
int min(int a, int b)
{
	if (a < b)
		return a;
	else
		return b;
}
void set(int x, int v)
{
	x += ss - 1;
	seg[x] = v;
	while (x > 0)
	{
		x = (x - 1) / 2;
		seg[x] = max(seg[2 * x + 1], seg[2 * x + 2]);
	}
	return;
}
int get(int l, int r)
{
	l += ss - 1;
	r += ss - 1;
	int res = 0;
	while (l < r)
	{
		if (l % 2 == 0)
			res = max(res, seg[l]);
		l /= 2;
		if (r % 2 > 0)
			res = max(res, seg[r]);
		r = r / 2 - 1;
	}
	if (l == r)
		res = max(res, seg[l]);
	return res;
}
int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	int i;
	int a[300005];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	ss = 1;
	while (ss < 300005)
		ss *= 2;
	for (i = 0; i < 2 * ss - 1; i++)
		seg[i] = 0;
	for (i = 0; i < n; i++)
		set(a[i], get(max(a[i] - k, 0), min(a[i] + k, ss - 1)) + 1);
	printf("%d\n", seg[0]);
	return 0;
}

Measured memory_bytes: 7008
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7;
int lt[2000050],tlt[2000050],n,ans,cnt;
int binpow(int a,int b){
	if(b==0) return 1;
	if(b==1) return a%mod;
	int mid=binpow(a,b/2);
	if(b%2==0) return mid*mid%mod;
	else return mid*mid%mod*a%mod;
}
int c(int n,int k){
	if(n<k) return 0;
	else{
		int tmp=lt[n];
		tmp*=tlt[k];
		tmp%=mod;
		tmp*=tlt[n-k];
		tmp%=mod;
		return tmp;
	}
}
signed main(){
//	freopen(".inp","r",stdin);
//	freopen(".out","w",stdout);
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	lt[0]=1;
	for(int i=0;i<2000004;i++){
		if(i) lt[i]=lt[i-1]*i%mod;
	}
	cin>>n;
	tlt[n] = binpow(lt[n],mod-2);
	for(int i=n;i>=1;i--) tlt[i-1]=(tlt[i]*i)%mod;
	for(int i=(n+1)/2;i<n;i++){
		int tmp=((c(i-1,n-i-1)%mod*lt[i]%mod*lt[n-i-1]%mod)%mod-cnt+mod*mod)%mod;
		ans+=tmp*i;
		ans%=mod;
		cnt+=tmp;
		cnt%=mod;
	}
	cout<<ans;
}	


Measured memory_bytes: 25344
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef pair<int,int>P;
typedef pair<ll,ll>pl;

const int MAX_N = 40;

ll v[MAX_N];
ll w[MAX_N];
vector<pl> x,y;

void solve(int s,int t,vector<pl> &x)
{
	int z = t-s;
	rep(i,1<<z){
		pl p = pl(0,0);
		rep(j,z){
			if(i&(1<<j)){
				p.first += w[s+j];
				p.second += v[s+j];
			}
		}
		x.push_back(p);
	}
}

int main()
{
	int n;
	ll lm;
	cin >> n >> lm;
	rep(i,n){
		cin >> v[i] >> w[i];
	}
	solve(0,n/2,x);
	solve(n/2,n,y);
	sort(x.begin(),x.end());
	sort(y.begin(),y.end());
	ll t=0;
	ll maxv = -(1LL<<60);
	ll ans = 0;
	for(int i=x.size()-1;i>=0;i--){
		while(t < y.size() && x[i].first+y[t].first <= lm){
			maxv = max(maxv,y[t].second);
			t++;
		}
		ans = max(ans,maxv+x[i].second);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 43724
#include<iostream>  
#include<cstdio>  
#include<cstring>  
#include<algorithm>  
#include<cmath>  
typedef long long LL;  
using namespace std;  
#define REPF( i , a , b ) for ( int i = a ; i <= b ; ++ i )  
#define REP( i , n ) for ( int i = 0 ; i < n ; ++ i )  
#define CLEAR( a , x ) memset ( a , x , sizeof a )  
const int N=1e7;  
int vis[N];  
void initPrime()  
{  
    int num = 0, m = sqrt (N + 0.5);  
    REPF(i,1,N)   vis[i]=1;  
    for (int i = 2; i <= m; ++i)  
        if (vis[i] == 1)  
            for (int j = i * i; j <= N; j += i) vis[j] = 0;  
    vis[1]=0;  
    for(int i=2;i<=N;i++)  
         vis[i]+=vis[i-1];  
//    for(int i=2;i<=10;i++)  
//        cout<<"233  "<<sum[i]<<endl;  
}  
int main()  
{  
    int n;  
    initPrime();  
    while(~scanf("%d",&n))  
        printf("%d\n",vis[n]);  
    return 0;  
}  

Measured memory_bytes: 40248
n = int(input())
r = 0
for p in range(2, int(n**0.5)+1):
    e = 0
    while n%p == 0:
       e += 1
       n /= p
    i = 1
    while e >= i:
        e -= i
        r += 1
        i += 1
if n != 1:
    r += 1
print(r)

Measured memory_bytes: 9440
#include<bits/stdc++.h>
using namespace std;
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; }

const long long INF = 1LL << 60;

// 入力
int N;
vector<long long> h(100010, INF);
// DP テーブル
vector<long long> dp(100010, INF);

int main() {
    int N, K;
    cin >> N  >> K;
    for (int i = 0; i < N; i++)
	cin >> h[i];

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N; i++) {
	for(int j=1; j<=K; j++){
	    chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
	}
    }

    // 答え
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1920
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <cctype>
#define rep(x,y,z) for(long long x=y;x<z;++x)
#define dwn(x,y,z) for(long long x=y;x>z;--x)
using namespace std;

typedef long long ll;

int main() {
    ll n, t;
    cin >> n >> t;
    vector<pair<ll, ll>> v(n);
    rep(i,0,n) cin >> v[i].second >> v[i].first;
    sort(begin(v), end(v));
    ll min_c = -1;
    for (int i = 0; i < n && v[i].first <= t; i++) {
        if (min_c == -1) min_c = v[i].second;
        if (min_c > v[i].second) min_c = v[i].second;
    }
    if (min_c == -1) {
        cout << "TLE" << endl;
        return 0;
    }
    cout << min_c << endl;
    return 0;
}


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)

#define BR "\n"
#define SP " "

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

  vector<int> A(N);
  rep0(i, N) cin >> A[i];

  int Q;
  cin >> Q;
  rep0(i, Q) {
    int c, b, e;
    cin >> c >> b >> e;
    if (c == 0) cout << *min_element(A.begin() + b, A.begin() + e) << BR;
    else cout << *max_element(A.begin() + b, A.begin() + e) << BR;
  }
  return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<cstdio>
#include<vector>
#include<bitset>
using namespace std;
int n;
int s;
int mn=1e9;
int a[2010];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i),s+=a[i];
	bitset<4000010>f;
	f[0]=1;
	for(int i=1;i<=n;i++)
	{
		f|=(f<<a[i]);
	}
	for(int i=0;i*2<=s;i++)
	{
		if(f[i])
		{
			mn=min(mn,s-i);
		}
	}
	printf("%d",mn);
	return 0;
} 

Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
using namespace std;
const int MAX=10000+5;
int F[MAX];
void f(){
	int t;
	for(int x=1;x<99;x++){
		for(int y=1;y<99;y++){
			for(int z=1;z<99;z++){
				t = x*x+y*y+z*z+x*y+x*z+y*z;
				if(t>10000)
					break;
				else
					F[t]++;
			}			
		}
	}
}
int main()
{
	int N;
	scanf("%d",&N);
	f();
	for(int i=1;i<=N;i++){
		
		printf("%d\n",F[i]);
	}
	return 0; 
}

Measured memory_bytes: 3728
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

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

void solve() {
  ll n, p; cin >> n >> p;
  ll ans = 1;

  vector<P> v;
  ll q = p;
  for (ll d = 2; d * d <= p; d++) {
    if (q % d > 0) continue;
    // debug(d);
    ll cnt = 0;
    while (q % d == 0) {
      cnt++;
      q /= d;
    }
    v.push_back(make_pair(d, cnt));
  }
  if (q > 1) v.push_back(make_pair(q, 1));

  for (int vi = 0; vi < v.size(); vi++) {
    // debug2(v[vi].first, v[vi].second);
    if (v[vi].second / n > 0) ans *= mypow(v[vi].first, (v[vi].second / n));
  }

  outl(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
typedef pair <PP,bitset<8100> > Pv;

static const double EPS = 1e-8;


int tx[] = {-1,0,1,0};
int ty[] = {0,1,0,-1};

int main(){
	int m,n;
	while(~scanf("%d %d",&m,&n)){
		if(m==n && n==0) break;

		vector<P> pos;

		bitset<8100> field;
		for(int y=0;y<n;y++){
			for(int x=0;x<m;x++){
				int ice;
				scanf("%d",&ice);
				field[y*m+x] = ice ? true : false;
				if(ice) pos.push_back(P(x,y));
			}
		}

		int res=0;
		for(int p=0;p<pos.size();p++){
			queue<Pv> que;
			que.push(Pv(PP(1,pos[p]),field));
			
			while(!que.empty()){
				int cost = que.front().first.first;
				int x = que.front().first.second.first;
				int y = que.front().first.second.second;
				bitset<8100> now = que.front().second;
				now[y*m+x] = 0;
				res = max(res,cost);
				que.pop();
				for(int i=0;i<4;i++){
					int dx = x + tx[i];
					int dy = y + ty[i];

					if(dx<0 || dx >=m || dy<0 || dy>=n) continue;
					if(now[dy*m+dx]==0) continue;
					que.push(Pv(PP(cost+1,P(dx,dy)),now));
				}
			}
			
		}
		printf("%d\n",res);
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>
#include <cassert>
#include <numeric>
#include <bitset>
#include <set>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define INPUT(x) scanf("%d",&x)
#define PUT(x) printf("%d\n",x)
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)
#define SP_END (i != n - 1 ? ' ' : '\n') ;

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };
const int disLD[3] = { 0,1,0 };

const char disC[4] = { 'U','D','R','L' };
const char disY[4] = { -1,1,0,0 };
const char disX[4] = { 0,0,1,-1 };

int x[200000];

int main(void)
{
	int N;

	cin >> N;



	for (int i = 0; i < N; i++) {
		cin >> x[i];
	}

	int* m = max_element(x, x + N),t = -1000000000;

	for (int i = 0; i < N; i++) {
		if (x != m - i && abs(x[i] - *m / 2) < abs(t - *m / 2)) {
			t = x[i];
		}
	}

	cout << *m << " " << t << endl;


	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    int p[n];
    for(int i = 0; i < n; i++){
        cin >> p[i];
    }
    int count = 0;
    for(int i = 0; i < n; i++){
        if(i+1 == p[i]){
            if(i == 0){
                swap(p[i],p[i+1]);
                count++;
            }else if (i == n-1){
                swap(p[i], p[i-1]);
                count++;
            }else{
                swap(p[i],p[i+1]);
                count++;
            }
        }
    }

    cout << count << endl; 
    return 0;
}

Measured memory_bytes: 640
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    'outer: loop {
        let v = read_vec::<usize>();
        let (w, h) = (v[0], v[1]);
        if w == 0 && h == 0 {
            break;
        }
        let mut vertical_lines = vec![vec![]; h];
        let mut horizontal_lines = vec![vec![]; h - 1];
        for i in 0..h - 1 {
            vertical_lines[i] = read_vec::<usize>();
            horizontal_lines[i] = read_vec::<usize>();
        }
        vertical_lines[h - 1] = read_vec::<usize>();

        let mut checked = vec![vec![false; w]; h];
        let mut que = VecDeque::new();
        que.push_back((1, 0, 0));

        while let Some((count, x, y)) = que.pop_front() {
            if checked[y][x] {
                continue;
            }
            checked[y][x] = true;
            if x == w - 1 && y == h - 1 {
                println!("{}", count);
                continue 'outer;
            }
            if x < w - 1 && vertical_lines[y][x] == 0 {
                que.push_back((count + 1, x + 1, y));
            }
            if x > 0 && vertical_lines[y][x - 1] == 0 {
                que.push_back((count + 1, x - 1, y));
            }
            if y < h - 1 && horizontal_lines[y][x] == 0 {
                que.push_back((count + 1, x, y + 1));
            }
            if y > 0 && horizontal_lines[y - 1][x] == 0 {
                que.push_back((count + 1, x, y - 1));
            }
        }
        println!("0");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}



Measured memory_bytes: 5056
import scala.io.StdIn

object Main extends App {
  val s = StdIn.readLine().trim.toInt
  val basemin   = 60
  val basehour  = 60 * 60

  val rs = s % 60
  var temp = s - rs
  val rh = temp / basehour

  temp = temp - basehour * rh

  val rm = temp / basemin

  println(s"$rh:$rm:$rs")
}



Measured memory_bytes: 43640
import sys

sys.setrecursionlimit(10 ** 5 + 1)

def dfs(i, V, E):
    for k in E[i].keys():
        if V[k] >= 0:
            continue
        if E[i][k] % 2:
            V[k] = 1 - V[i]
        else:
            V[k] = V[i]
        V = dfs(k, V, E)
    return V

n = int(input())
E = {}
for i in range(n - 1):
    ui, vi, wi = map(int, input().split())
    if ui in E.keys():
        E[ui][vi] = wi
    else:
        E[ui] = {vi: wi}
    if vi in E.keys():
        E[vi][ui] = wi
    else:
        E[vi] = {ui: wi}
V = [-1 for _ in range(n + 1)]
V[1] = 0
V = dfs(1, V, E)
for vi in V[1:]:
    print(vi)


Measured memory_bytes: 91604
#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 sx, sy, tx, ty; scanf("%d %d %d %d", &sx, &sy, &tx, &ty);
  int xdiff = abs(tx - sx), ydiff = abs(ty - sy);
  string ans = string(ydiff, 'U') + string(xdiff, 'R');
  ans += string(ydiff, 'D') + string(xdiff, 'L');
  ans += string(1, 'L') + string(ydiff + 1, 'U') + string(xdiff + 1, 'R') + string(1, 'D');
  ans += string(1, 'R') + string(ydiff + 1, 'D') + string(xdiff + 1, 'L') + string(1, 'U');

  // int x = sx, y = sy;
  // for (int i = 0; i < (int)ans.size(); ++i) {
  //   switch (ans[i]) {
  //     case 'U': ++y; break;
  //     case 'D': --y; break;
  //     case 'L': --x; break;
  //     case 'R': ++x; break;
  //   }
  //   if (x == tx and y == ty) {
  //     fprintf(stderr, "DEBUG: arrived at (tx, ty)\n");
  //   }
  //   else if (x == sx and y == sy) {
  //     fprintf(stderr, "DEBUG: arrived at (sx, sy)\n");
  //   }
  // }

  printf("%s\n", ans.c_str());
  return 0;
}


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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int N, D;
    int ans;
    scanf("%d %d", &N, &D);
    REP(int, i, 1, 20){
        if ( i * (2 * D + 1) >= N ){ ans = i; break;}
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
n,k,*a=map(int,open(0).read().split())
l,r,*b=[[]for _ in range(10**6)]
for i,v in enumerate(a):
  b[v]+=i,
  l+=len(b[v]),
s=a[0]
i=c=0
while i<n:
  j=l[i]%len(b[s])
  c+=j<1
  i=b[s][j]+1
  s=a[i%n]
k%=c+1
i=c=0
while i<n:
  j=l[i]%len(b[s])
  if(c>k-2)>j:
    r+=s,
    i+=1
  else:i=b[s][j]+1
  c+=j<1
  s=a[i%n]
print(*r)

Measured memory_bytes: 105764
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N,D,X;

int main(){
    cin >> N >> D >> X;
    vector<int> a(N);
    rep(i,N) cin >> a[i];
    int sum = 0;
    rep(i,N) rep(j,D) if(j*a[i]+1 <= D) sum++;
    cout << sum + X << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#define MOD_P 1000000007
#define ll long long
using namespace std;



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

	for (int i = x - k + 1; i < x + k; i++) {
		printf("%d ", i);
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T>
bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,M; cin>>N>>M;
    vector<ll> A(N);
    vector<ll> B(M);
    rep(i,N) cin>>A[i];
    rep(i,M) cin>>B[i];
    sort(ALL(A),greater<ll>());
    sort(ALL(B),greater<ll>());
    ll ans=1;
    ll act=0,bct=0;
    A.emplace_back(-1);
    B.emplace_back(-1);
    repr(i,N*M,1){
        if(A[act]==i){
            ++act;
            if(B[bct]==i){
                ++bct;
            }
            else{
                ans=ans*bct%MOD;
            }
        }
        else{
            if(B[bct]==i){
                ++bct;
                ans=ans*act%MOD;
            }
            else{
                ans=ans*(act*bct-((N*M)-i))%MOD;
            }
        }
    }
    //if(act!=N or bct!=M) ans=0;

    cout<< ans <<"\n";
}
    
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
from collections import defaultdict
residents = defaultdict(int)
n=int(input())
q = [map(int, input().split()) for _ in range(n)]
for b, f, r, v in q:
    residents[(b,f,r)] += v
print(f'\n{"#"*20}\n'.join(['\n'.join([' ' + ' '.join([str(residents[(b,f,r)]) for r in range(1,11)]) for f in range(1,4)]) for b in range(1,5)]))


Measured memory_bytes: 6016
package main

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

func main() {
	In := readLineInt()
	Count, DefaultPoint, Problems := In[0], In[1], In[2]
	Members := make([]int, Count)

	Loop(0, Problems, func(i int) {
		Correct, _ := strconv.Atoi(readLine())
		Correct--
		v := Members[Correct]
		Members[Correct] = v + 1
	})

	for _, v := range Members {
		v = v - Problems + DefaultPoint
		if v > 0 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}
}

/////////////////////////////////////////
var scanner = bufio.NewScanner(os.Stdin)

func init() {
	//scanner.Split(bufio.ScanWords)
}
func readLine() string {
	scanner.Scan()
	return scanner.Text()
}

func Loop(start, end int, f func(i int)) {
	for i := start; i < end; i++ {
		f(i)
	}
}

func readLineInt() []int {
	result := make([]int, 0)
	for _, v := range strings.Split(readLine(), " ") {
		r, _ := strconv.Atoi(v)
		result = append(result, r)
	}
	return result
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>
#define REP(i,n)    for(int i = 0; i < (n); ++i)
#define RREP(i,n)   for(int i = (n); i >= 0; --i)
#define FOR(i,m,n) for(int i = (m); i < (n); ++i)
#define SZ(x)       ( (int)(x).size() )
#define BIT(n)      ( 1LL << (n) )
#define EXIST(x)    ( (x).find()		!= (x).end() )
#define DEBUG(n)    cerr << #n << " : " << n << '\n';
#define PB  push_back
#define UB  upper_bound			//k <
#define LB  lower_bound			//k	<= 
#define F   first
#define S   second
#define INF 1.0e9


using namespace std;

typedef long long			ll;
typedef pair<int, int>		pii;
typedef pair<long			long, long long>   pll;
typedef vector<int>			vi;
typedef vector<double>		vd;
typedef vector<long long>   vll;

template<class T> void chmax(T &	a, const T & b){ if( a < b ) a = b; }
template<class T> void chmin(T &	a, const T & b){ if( a > b ) a = b; }

int r_up(const int a, const int b){ return (a + b - 1) / b; }

const int dx[] = { 0,  0, 1, -1 };
const int dy[] = { 1, -1, 0,  0 };


// int n;
// vi v[100010];
// map<ll, ll> mp;





// int main(){
//   cin>>n;
//   REP(i,n-1){
// 	ll a,b,c;cin>>a>>b>>c;
// 	if(b<a)swap(a,b);
// 	v[a].PB(b);
// 	v[b].PB(a);
// 	mp[a*100010 + b] = c;
//   }
//   vi color(100010,-1);
//   stack<int> st;
//   color[1] = 1;
//   st.push(1);
//   while(!st.empty()){
// 	int now = st.top();
// 	st.pop();
// 	REP(i,SZ(v[now])){
// 	  int a = now, b = v[now][i];
// 	  if(color[b] != -1)continue;
// 	  if(b<a)swap(a,b);
// 	  int c;
// 	  if(mp[a*100010 + b]%2)c = (color[now]+1)%2;
// 	  else c = color[now];
// 	  color[v[now][i]] = c;
// 	  st.push(v[now][i]);
// 	}
//   }
//   REP(i,n)
// 	cout<<color[i+1]<<endl;
//   return 0;
// }


int main(){
  int n;
  cin>>n;
  int a[100010] = {};
  int b[100010] = {};
  ll  w[100010] = {};
  vi v[100010];
  REP(i,n-1){
	cin>>a[i]>>b[i]>>w[i];
	v[a[i]].push_back(i);
	v[b[i]].push_back(i);
  }

  int color[100010];
  fill(color,color+100010,-1);

  stack<int> st;
  color[a[0]] = 0;
  st.push(a[0]);
  while(!st.empty()){
	int e = st.top();
	st.pop();
	REP(i,v[e].size()){
	  int f = a[v[e][i]] == e ? b[v[e][i]] : a[v[e][i]];
	  int g = w[v[e][i]];
	  if(color[f] != -1)continue;
	  color[f] = g%2 ? (color[e]+1)%2 : color[e];
	  st.push(f);
	}
  }
  FOR(i,1,n+1)
	cout << color[i] <<endl;
  return 0;
}


Measured memory_bytes: 7936
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

int n;
long long need;
int p[20], c[20];

int getBit(long long x, int pos) {
  return (x & (1ll << pos)) > 0 ? 1 : 0;
}

int main() { 

  scanf("%d %lld", &n, &need);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &p[i], &c[i]);
  }

  long long ans = 1e6;

  for (int mask = 0; mask < (1 << n); mask++) {
    long long curScore = 0;
    long long curProblems = 0;

    for (int i = 0; i < n; i++) {
      if (getBit(mask, i) == 1) {
        curScore += 100 * (i + 1) * p[i];
        curScore += c[i];
        curProblems += p[i];
      }
    }

    for (int i = n - 1; i >= 0; i--) {
      if (getBit(mask, i) == 0) {
        for (int j = 0; j < p[i]; j++) {
          if (curScore < need) {
            curScore += 100 * (i + 1);
            curProblems++;
          }
        }
      }
    }

    if (curScore >= need) {
      ans = min(ans, curProblems);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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 gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

// 最小公倍数(lcm)
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a / g * b;
}

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

    ll n, m; cin >> n >> m;
    string s, t; cin >> s >> t;
    ll L = lcm(n, m);
    ll l = lcm(L/n, L/m);
    for(ll i = 0; i < L; i+=l) {
        if(s[i / (L/n)] != t[i / (L/m)]){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << L << endl;
}


Measured memory_bytes: 640
#include <iostream>

int main() {
    int num_1_yen_coin, price;
    std::cin >> price >> num_1_yen_coin;

    int rest = price % 500;
    if (rest <= num_1_yen_coin)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;
/**
 * @author yamato
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static boolean kaibun(String S,int N) {
		int i;
		String s1;
		String s2;
		if(N%2 != 0) {
			 s1 = S.substring(0,(N-1)/2);
			 s2 = S.substring((N-1)/2+1);
		}else {
			 s1 = S.substring(0,(N)/2);
			 s2 = S.substring((N)/2);
		}
		
        StringBuffer str2 = new StringBuffer(s2);
        s2 = str2.reverse().toString();
        
        //System.out.println(s1);
        //System.out.println(s2);
        
		if(s1.equals(s2)) {
			return true;
		}else {
			return false;
		}
		
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in);
		String S = scanner.nextLine();
		int N = S.length();
		//System.out.println(kaibun(S,N));
		if (kaibun(S,N)) {
			String S2 = S.substring(0,(N-1)/2);
			int N2 = S2.length();
			
			if (kaibun(S2,N2)) {
				String S3 = S.substring((N+3)/2-1,N);
				int N3 = S3.length();
				
				if (kaibun(S3,N3)) {
					System.out.println("Yes");
				}else {
					System.out.println("No");
				}
				
			}else {
				System.out.println("No");
			}
			
			
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 22612
import java.util.*;

public class Main {

    static int[][] dir4 = new int[][] { { 0, -1 }, { 1, 0 }, { 0, 1 }, { -1, 0 } };
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        boolean[][] g = new boolean[h+2][w+2];
        int wc = 0;
        for (int i = 1; i <= h; i++) {
            char[] a = sc.next().toCharArray();
            for (int j = 0; j < w; j++) {
                if(a[j] == '.'){
                    g[i][j+1] = true; wc++;
                }
            }
        }
        int[][] d = new int[h+2][w+2];
        for (int i = 0; i < h+2; i++) Arrays.fill(d[i], -1);
        d[1][1] = 1;
        ArrayDeque<Integer> q = new ArrayDeque<>();
        q.add(101);
        while(!q.isEmpty()){
            int nex = q.poll();
            int ch = nex/100; int cw = nex%100;
            for(int[] dir : dir4){
                int nh = ch+dir[0]; int nw = cw+dir[1];
                if(!g[nh][nw] || 0 < d[nh][nw])continue;
                d[nh][nw] = d[ch][cw] + 1;
                q.add(nh*100 + nw);
            }
        }
        int ans = d[h][w] < 0 ? -1 : wc - d[h][w];
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 23124
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL<<60LL)
typedef long long ll;

using namespace std;


int main() {
	ll n; cin >> n;
	vector<pair<string, ll>> d(n);
	map< pair<string, ll>, ll> m;
	rep(i, n) {
		string s;
		ll b;
		cin >> s >> b;
		d[i] = { s,-b };
		m[{s, -b}] = i + 1;
	}
	sort(all(d));
	rep(i, n) {
		cout << m[d[i]] << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> A(3);
    rep(i, 0, 3) {
        cin >> A[i];
    }
    int parity = A.front() % 2;
    bool is_same = true;
    rep(i, 0, 3) {
        is_same &= (A[i] % 2 == parity);
    }
    if (!is_same) {
        bool is_ok = false;
        rep(i, 0, 3) {
            rep(j, i + 1, 3) {
                if (A[i] % 2 == A[j] % 2) {
                    ++A[i];
                    ++A[j];
                    is_ok = true;
                    break;
                }
            }
            if (is_ok) {
                break;
            }
        }
    }
    int target = *max_element(all(A));
    int ans = !is_same;
    rep(i, 0, 3) {
        ans += (target - A[i]) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
cnt = 0
is_ok = False
for _ in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        is_ok = True
    else:
        pass
if is_ok:
    print('Yes')
else:
    print('No')


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

int main (){
int x ,z,y;
cin>>x>>z>>y;
int h =min(min(x,z),y);
if (x==h and z<=y ){
    cout<<x+z;
}
else if (z==h and y<=x){
    cout<<z+y;
}
else if ( y==h and z<=x){
    cout<<y+z;
}
else if (z==h and x<=y){
    cout<<z+x;
}
else if (x==h and y<=z){
    cout<<x+y;
}
else if (y==h and x<=z){
    cout<<y+x;
}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <vector>
using namespace std;

void print_table(int A[],int n){
  for(int i=0;i<n;i++){
    cout << (i==0 ? "" : " ") << A[i];
  }
  cout << endl;
}

int bubbleSort(int A[],int N){
  int sw = 0;
  bool flag = 1;
  for(int i=0;flag;i++){
    flag = 0;
    for(int j=N-1;j>=i+1;j--){
      if(A[j-1]>A[j]){
        swap(A[j-1],A[j]);
        flag = 1;
        sw++;
      }
    }
  }
  return sw;
}

int main(){
  int N,sw,A[100];
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  sw = bubbleSort(A,N);

  print_table(A,N);
  cout << sw << endl;
  return 0;
}



Measured memory_bytes: 3092
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i = 0; i < N; ++i) {
    cin >> h[i];
  }

  sort(h.begin(), h.end());
  int gap = h[K - 1] - h[0];
  for (int i = 1; i < N - K + 1; ++i) {
    gap = min(gap, h[K - 1 + i] - h[i]);
  }
  cout << gap << endl;
  return 0;
}


Measured memory_bytes: 640
def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy > 0:
        out = str(X_dumy % n) + out
        X_dumy = int(X_dumy / n)
    return out


N, K = map(int, input().split())
print(len(Base_10_to_n(N, K)))


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<long long, long long> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> ii;
typedef vector<pair<ll,ll> > vii;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;

#define PI 3.141592653589793
#define mod 1000000007
#define N 1000000000
//# define N 2003
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
# define INF 1000000000000000
# define A 1000007

//bool vis[N+5],vis1[N+5];

int main()
{
	IOS;
	string s;
	cin >> s;
	int max1=-1;
	int ans;
	bool found;
	int ans1=0;
	for(int i=0;i<s.length();i++)
		ans1+=(s[i]-'0');
	max1=ans1;
	for(int i=0;i<s.length();i++)
	{
		ans=0;
		found=false;
		for(int j=0;j<i;j++)
		{
			ans+=(s[j]-'0');
		}
		if(s[i]-'0'>0)
			{
				ans+=(s[i]-'0')-1;
				found=true;
			}
		else
			ans+=(s[i]-'0');
		if(found)
		{
			for(int j=(i+1);j<s.length();j++)
			ans+=(9);
		}
		else
		{
			for(int j=(i+1);j<s.length();j++)
			ans+=(s[j]-'0');
		}
		//trace2(ans,max1);
		if(ans>max1)
			max1=ans;
	}
	cout << max1;
	
}

Measured memory_bytes: 256
#include<iostream>
#include <string.h>
#include <algorithm>
using namespace std;

int main()
{
    int n,c[19],v[19],x = 0,y = 0,ans = 0;

    cin >> n;

    for(int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
        for(int i = 0; i < n; i++)
    {
        cin >> c[i];
        if(v[i] > c[i])
        {
  
            x = v[i]-c[i];
           ans += x;
        }
    }


    cout << ans << endl;

    return 0;
}

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

int main()
{
   ll n;
   cin>>n;
   ll h[n],i,j,c=0,d;
   for(i=0;i<n;i++)
   {
      cin>>h[i];
   }
   vector<ll> a;
   if(n==1)
   {
      cout<<"0";
      return 0;
   }

   for(i=1;i<n;i++)
   {
      if(i==n-1)
      {
         if(h[i]<=h[i-1])
         {
            a.push_back(c+1);
         }
         else a.push_back(c);
      }
     else if(h[i]<=h[i-1])
      {
         c++;
      }
      else
      {
         a.push_back(c);
         c=0;
      }
   }
   ll mx=0;
   mx=a[0];
   for(i=1;i<a.size();i++)
   {
      if(a[i]>mx)
      {
         mx=a[i];
      }
   }
   cout<<mx;
}


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

int main(){
    ll n,d;
    cin >> n >> d;
    ll cnt = 0;
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        long double dis = sqrt(x*x+y*y);
        if(dis<=d) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
typedef pair<double, double> P;
typedef pair<P, P> PP;

const double INF = 1e100;

pair<pair<double, double>, pair<double, double>> circle_cross_point(
    double x0, double y0, double r0, double x1, double y1, double r1){
    if((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0) > (r0 + r1) * (r0 + r1) ||
       (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0) < (r0 - r1) * (r0 - r1)){
        return pair<pair<double, double>, pair<double, double>>(
            pair<double, double>(INF, INF), 
            pair<double, double>(INF, INF)
        );
    }
    double a = ((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0) + r0 * r0 - r1 * r1) / 2;
    double z = ((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
    return pair<pair<double, double>, pair<double, double>>(
        pair<double, double>((a * (x1 - x0) + (y1 - y0) * sqrt(z * r0 * r0 - a * a)) / z + x0, 
                             (a * (y1 - y0) - (x1 - x0) * sqrt(z * r0 * r0 - a * a)) / z + y0),
        pair<double, double>((a * (x1 - x0) - (y1 - y0) * sqrt(z * r0 * r0 - a * a)) / z + x0, 
                             (a * (y1 - y0) + (x1 - x0) * sqrt(z * r0 * r0 - a * a)) / z + y0)
    );
}

int main()
{
    int n, k;
    cin >> n >> k;
    double x[100], y[100], c[100];
    for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> c[i];
    double left = 0, right = 1e8;
    while(right - left > right * 1e-8 && right - left > 1e-12){
        double mid = (right + left) / 2;
        bool f = false;
        for(int i = 0; i < n; i++){
            int d = 0;
            for(int j = 0; j < n; j++){
                if((x[j] - x[i]) * (x[j] - x[i]) + (y[j] - y[i]) * (y[j] - y[i]) - right * 1e-8 < (mid / c[j]) * (mid / c[j])) d++;
            }
            if(d >= k) f = true;
        }
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j < n; j++){
                PP p = circle_cross_point(x[i], y[i], mid / c[i], x[j], y[j], mid / c[j]);
                double u = p.first.first, v = p.first.second;
                int d = 0;
                for(int l = 0; l < n; l++){
                    if((x[l] - u) * (x[l] - u) + (y[l] - v) * (y[l] - v) - right * 1e-8 < (mid / c[l]) * (mid / c[l])) d++;
                }
                if(d >= k) f = true;
                u = p.second.first, v = p.second.second;
                d = 0;
                for(int l = 0; l < n; l++){
                    if((x[l] - u) * (x[l] - u) + (y[l] - v) * (y[l] - v) - right * 1e-8 < (mid / c[l]) * (mid / c[l])) d++;
                }
                if(d >= k) f = true;
            }
        }
        if(f) right = mid;
        else left = mid;
    }
    cout << fixed << setprecision(15) << right << endl;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int x,y; cin >> x >> y;
  y /= 2;
  cout << x+y << endl;
  
  return 0;
}


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

int main(){
	double n;
	int money = 100000;
	cin >> n;
	while (n--){
		money *= 1.05;
		if (money % 1000 != 0){
			money += 1000 - (money % 1000);
		}
		

	}
	cout << money << '\n';

	return 0;
}

Measured memory_bytes: 1220
#include<stdio.h>
int main(){
	int a,b,c;
	while(~scanf("%d%d%d",&a,&b,&c)){
		if(a<1868||a==1868&&(b<9||(b==9&&c<8)))printf("pre-meiji\n");
		else if(a<1912||a==1912&&(b<7||(b==7&&c<30)))printf("meiji %d %d %d\n",a-1867,b,c);
		else if(a<1926||a==1926&&(b<12||(b==12&&c<25)))printf("taisho %d %d %d\n",a-1911,b,c);
		else if(a<1989||a==1989&&(b<1||(b==1&&c<8)))printf("showa %d %d %d\n",a-1925,b,c);
		else printf("heisei %d %d %d\n",a-1988,b,c);
	}
}


Measured memory_bytes: 2612
#include<iostream>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
#pragma warning(disable:4996)
int n, m, q, a[200001], b[200001], c[200001], d[200001], e[100001], dist[100001];
vector<pair<int, int>>x[100001], y[100001], z[100001];
vector<int>D[100001];
void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (true) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
int main() {
	reader(&n); reader(&m); reader(&q);
	fill(d, d + m + 1, 1 << 30);
	for (int i = 1; i <= m; i++) reader(&a[i]), reader(&b[i]);
	for (int i = 1; i <= q; i++) reader(&c[i]), d[c[i]] = i;
	for (int i = 1; i <= m; i++) {
		x[a[i]].push_back(make_pair(b[i], d[i]));
		x[b[i]].push_back(make_pair(a[i], d[i]));
	}
	fill(dist, dist + n + 1, -1); dist[1] = 0;
	queue<int> Q1; Q1.push(1);
	while (!Q1.empty()) {
		int a1 = Q1.front(); Q1.pop();
		for (pair<int, int> i : x[a1]) {
			if (dist[i.first] == -1) {
				dist[i.first] = dist[a1] + 1;
				Q1.push(i.first);
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		D[dist[i]].push_back(i);
		for (pair<int, int> j : x[i]) {
			if (dist[i] < dist[j.first]) y[i].push_back(j);
			if (dist[i] > dist[j.first]) z[i].push_back(j);
		}
	}
	e[1] = (1 << 30);
	for (int i = 1; i < n; i++) {
		for (int j : D[i]) {
			for (pair<int, int>k : z[j]) {
				e[j] = max(e[j], min(e[k.first], k.second));
			}
		}
	}
	sort(e + 1, e + n + 1);
	int T = 1;
	for (int i = 1; i <= q; i++) {
		while (e[T] <= i) T++;
		printf("%d\n", T - 1);
	}
	return 0;
}

Measured memory_bytes: 30104