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

using std::cerr;
using std::endl;

inline int rd() {
  int x; scanf("%d", &x);
  return x;
}

const int N = 2e5 + 233, P = 1e9 + 7;

inline long long fpow(long long x, int y) {
  long long ret = 1;
  for ( ; y; y >>= 1, x = x * x % P)
    if (y & 1) ret = ret * x % P;
  return ret;
}

int n, X[N], Y[N];
std::vector<int> G[N];
long long fac[N], inv[N];

// sides of circle
int sx, sy;
int cnt_ver, cnt_edge;
int vis[N];

void dfs1(int x, int fa) {
  vis[x] = 1;
  ++cnt_ver;
  for (int y : G[x]) {
    ++cnt_edge;
    if (y == fa)
      continue;
    if (vis[y]) {
      sx = x;
      sy = y;
    } else {
      dfs1(y, x);
    }
  }
}

int last[N];
int stk[N], top;

void dfs2(int x, int fa) {
  last[x] = fa;
  stk[++top] = x;
  for (int y : G[x]) {
    if (y != fa && y != sx) {
      dfs2(y, x);
    }
  }
}

std::vector<int> T[N];
int deg[N];
int size[N];

void dfs3(int x, int fa) {
  size[x] = 1;
  for (int y : T[x]) {
    if (y != fa) {
      dfs3(y, x);
      size[x] += size[y];
    }
  }
}

inline long long work() {
  top = 0;
  dfs2(sx, sy);

  for (int v = 1; v <= top; ++v) {
    int x = stk[v];
    T[x].clear();
    deg[x] = 0;
  }

  for (int v = 1; v <= top; ++v) {
    int x = stk[v];
    for (int y : G[x]) {
      if (y < last[x]) {
        T[x].push_back(y);
        ++deg[y];
      }
    }
  }

  for (int v = 1; v <= top; ++v) {
    int x = stk[v];
    if (!deg[x]) {
      dfs3(x, x);
    }
  }

  long long ret = fac[cnt_ver];



  for (int v = 1; v <= top; ++v) {
    int x = stk[v];
    ret = ret * fac[size[x] - 1] % P * inv[size[x]] % P;
  }

  return ret;

}

int main() {
  n = rd();
  for (int i = 1; i <= n * 2; ++i) {
    X[i] = rd();
    Y[i] = rd() + n;
    G[X[i]].push_back(Y[i]);
    G[Y[i]].push_back(X[i]);
  }
  n *= 2;

  for (int i = fac[0] = 1; i <= n; ++i) {
    fac[i] = fac[i - 1] * i % P;
  }
  inv[n] = fpow(fac[n], P - 2);
  for (int i = n; i; --i) {
    inv[i - 1] = inv[i] * i % P;
  }


  long long ans = fac[n];

  for (int i = 1; i <= n; ++i) {
    if (!vis[i]) {
      cnt_edge = cnt_ver = 0;
      dfs1(i, 0);
      if (cnt_edge != cnt_ver * 2) {
        puts("0");
        return 0;
      }
      long long tmp = work();
      std::swap(sx, sy);
      tmp += work();
      ans = ans * tmp % P * inv[cnt_ver] % P;
    }
  }

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



Measured memory_bytes: 30208
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(void)
{
    int h, w, a, b;
    scanf("%d%d%d%d", &h, &w, &a, &b);

    int s[h][w];
    rep(i, h)
        rep(j, w)
        {
            if (j < a && i < b)
                s[i][j] = 0;
            else
                s[i][j] = 1;
        }
    for (int i = b; i < h; i++)
        for (int j = a; j < w; j++)
            s[i][j] = 0;

    rep(i, h)
    {
        rep(j, w)
            printf("%d", s[i][j]);
        printf("\n");
    }

    return 0;
}

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

ll gcd(ll a, ll b) {
  if (b==0) return a;
  else return gcd(b, a%b);
}

int main() {
  ll a,b;
  cin>>a>>b;
  
  ll n=gcd(a, b);
  int ans=1;
  for (ll i=2; i*i<=n; i++) {
    if (n%i) continue;
    ans++;
    while (n%i==0) n/=i;
  }
  if (n!=1) ans++;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ld long double
#define sz(a) (ll)(a).size()

typedef tree<pair<ll,ll> ,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest
//cout << k << "kth smallest: " << *A.find_by_order(k-1) << endl;
//NO OF ELEMENTS < X
//cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

const int MAXN = 100005;

ll dp[MAXN], n, h[MAXN], k;    // Minimum cost to reach from i to N

ll rec(ll index)
{
	if(index == n - 1) return 0;
	if(dp[index] != -1) return dp[index];
	ll ans = 1e18;
	for(int i=1;i<=k;i++)
	{	
		if(index + i < n)
			ans = min(ans, rec(index + i) + abs(h[index] - h[index + i]));
		else
			break;
	}
	return dp[index] = ans;
}

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

 	cin >> n >> k;
 	for(int i=0;i<n;i++) cin >> h[i];
 	memset(dp, -1, sizeof(dp));	
 	cout << rec(0) << endl;
    return 0;
}

Measured memory_bytes: 4608
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();
    if (a > 0 && b > 0) {
      System.out.println("Positive");
    }
    if (a == 0 || b == 0 || (a < 0 && b > 0)) {
      System.out.println("Zero");
    }
    if (a < 0 && b < 0) {
      if (Math.abs(a - b) % 2 == 1) {
        System.out.println("Positive");
      } else {
        System.out.println("Negative");
      }
    }
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>

using namespace std;

int dt[8][2]={{-1,0},{-1,1},{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1}};

int main()
{
	int h,w;
	cin >> h >> w;
	vector<string> s(h);
	for(int i=0;i<h;i++)
		cin >> s[i];
	
	vector<vector<int> > map(h,vector<int>(w));

	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			for(int k=0;k<8;k++)
			{
				int x=i+dt[k][0];
				int y=j+dt[k][1];
				if(x>=0 and x<h and y>=0 and y<w)
					if(s[x][y]=='#')map[i][j]++;
			}
	
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
			if(s[i][j]=='#')cout << '#';
			else cout<<map[i][j];
		cout << endl;

	}



}

Measured memory_bytes: 256
N = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            if l[i] != l[j] != l[k] and l[i] + l[j] > l[k]:
                ans += 1
print(ans)

Measured memory_bytes: 9092
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <functional>

#define big ((long long)(1e9) + 7)

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define DBG(x) cerr << #x << ": " << (x) << " (L" << __LINE__ << ")" << endl;

ll max_ll(ll a, ll b)
{
    if (a < b)
    {
        a = b;
    }
    return a;
}

int main()
{
    string s;
    cin >> s;
    vector<ll> a;
    ll nl = 0;
    ll nr = 0;
    if (s.at(0) == '<')
    {
        nl++;
        for(ll i = 1;i < s.size();i++)
        {
            if(s.at(i-1) != s.at(i) && nl != 0 && nr != 0)
            {
                a.push_back(max_ll(nl,nr));
                if(nl >= nr && nr >= 2)
                {
                    a.push_back(nr-1);
                }
                else if(nl <= nr && nl >= 2)
                {
                    a.push_back(nl-1);
                }
                nl = 0;
                nr = 0;
            }
            if(s.at(i) == '<') nl++;
            else nr++;
        }
    }
    else
    {
        bool flag = true;
        nr++;
        for(ll i = 1;i < s.size();i++)
        {
            if(flag && s.at(i-1) != s.at(i))
            {
                a.push_back(max_ll(nl,nr));
                nl = 0;
                nr = 0;
                flag = false;
            }
            if(s.at(i-1) != s.at(i) && nl != 0 && nr != 0)
            {
                a.push_back(max_ll(nl,nr));
                if(nl >= nr && nr >= 2)
                {
                    a.push_back(nr-1);
                }
                else if(nl <= nr && nl >= 2)
                {
                    a.push_back(nl-1);
                }
                nl = 0;
                nr = 0;
            }
            if(s.at(i) == '<') nl++;
            else nr++;
        }
    }
    a.push_back(max_ll(nl,nr));
    ll ans = 0;
    for(ll i = 0;i < a.size();i++)
    {
        ans += a[i]*(a[i]+1)/2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3068
A,B,C,X,Y = gets.chomp.split.map(&:to_i)
a = 0
b = 0
cost = 0
if A+B >= C*2
	a = [X,Y].min
	b = a
	cost += a*C*2
end
if A >= C*2
	cost += (X-a)*C*2
	b += (X-a)
else
	cost += (X-a)*A
end
if B >= C*2
	cost += (Y-b)*C*2
else
	cost += (Y-b)*B
end
p cost

Measured memory_bytes: 1788
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1000000000
#define rep(i,a,b) for (int i=(a);i<(b);i++)
#define rev(i,a,b) for (int i=(a)-1;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef queue<int> qi;
typedef vector<int> vi;
typedef vector<string> vs;
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

int main() {
	cin.tie(0);

	while(true) {
		int n;
		cin >> n;
		if(n == 0) break;

		vector<pii> vp;
		rep(i,0,n) {
			int h,m,s;
			scanf("%d:%d:%d", &h, &m, &s);
			vp.push_back(pii(h*3600 + m*60 + s, 1));
			scanf("%d:%d:%d", &h, &m, &s);
			vp.push_back(pii(h*3600 + m*60 + s, -1));
		}

		sort(vp.begin(), vp.end());

		int ans = 0, tmp = 0;
		rep(i,0,vp.size()) {
			tmp += vp[i].second;
			ans = max(ans, tmp);
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1492
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define all(a) a.begin(),a.end()
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define INT_INF 0x3f3f3f3f
#define LL_INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define MOD2 1494318097
#define SEED 131
#define mp make_pair
#define fastio cin.tie(0); cin.sync_with_stdio(0);

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

mt19937 g1(time(0));

int randint(int a, int b){return uniform_int_distribution<int>(a, b)(g1);}
ll randlong(ll a,ll b){return uniform_int_distribution<ll>(a, b)(g1);}

ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}

//ll fmul(ll a, ll b, ll mod){ll res=0;while(a){if(a&1)res=(res+b)%mod;a>>=1;b=(b<<1)%mod;}return res;}
//ll fpowfast(ll b, ll exp, ll mod){ll res=1;while(exp){if(exp&1)res=fmul(res,b,mod);b=fmul(b,b,mod);exp>>=1;}return res;}
//inline bool rabbin_miller(ll x){if(x%2==0) return false;for(int i=0;i<5;i++){ll rd=randlong(2,x-2);if(fpowfast(rd,x-1,x)!=1)return false;}return true;}

ll A,B,res=1;

ull fmul(ull a, ull b, ull mod){
	ull res = 0;
	while(a){
		if(a&1) res = (res+b)%mod;
		a>>=1;
		b = (b<<1)%mod;
	}
	return res;
}

ll fpowfast(ll b, ll exp, ll mod){
	ll res = 1;
	while(exp){
		if(exp&1) res = fmul(res,b,mod);
		b = fmul(b,b,mod);
		exp>>=1;
	}
	return res;
}

inline bool prim(ll x){
	if(x == 2 || x == 3) return true;
//	if(x%2 == 0) return false;
	for(int i=0; i<30; i++){
		ll rd = randlong(2,x-2);
		if(fpowfast(rd,x-1,x) != 1)
			return false;
	}
	return true;
}

//inline bool prim(ull x){
//	if(x == 2) return true;
//	ull lim = sqrt(x);
//	while(lim*lim < x) lim++;
//	while(lim*lim > x) lim--;
//	for(ull k=2; k<=lim; k++){
//		if(x%k == 0) return false;
//	}
//	return true;
//}

int main(){
	scanf("%lld %lld",&A,&B);
	ll gg = __gcd(A,B);
	ll lim = sqrt(gg);
	while(lim*lim < gg) lim++;
	while(lim*lim > gg) lim--;
	for(ll i=2; i<=lim; i++){
		if(gg%i == 0){
			if(prim(i))
				res++;
			if(i*i != gg && prim(gg/i))
				res++;
		}
	}
	if(prim(gg) && gg != 1) res++;
	printf("%lld\n",res);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int n, m;
    
    scanf("%d %d", &n, &m);
    
    int sum;
    int matrix[n][m];
    int vector;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            scanf("%d", &matrix[i][j]);
        }
    }

    for (int i = 0; i < m; i++) {
        scanf("%d", &vector);
        for (int j = 0; j < n; j++) {
            matrix[j][i] *= vector; 
        }
    }

    for (int i = 0; i < n; i++) {
        sum = 0;
        for (int j = 0; j < m; j++) {
        sum += matrix[i][j];
        }
        printf("%d\n", sum);
    }

    return 0;
}


Measured memory_bytes: 2148
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();

		sc.close();

		out.println(N * N * N);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;

int calc(int card[], int num) {
  int sum = 0;
  int A = 0;
  int Ap[12][2] = {{0,0},{1,11},{2,12},{3,13},{4,14},{5,15},{6,16},{7,17},{8,18},{9,19},{10,20},{11,21}};
  for(int i = 0; i < num; i++) {
    if(card[i] != 1) {
      if(card[i] >= 10) {
	sum += 10;
      } else {
	sum += card[i];
      }
    } else {
      A++;
    }
  }
  int best = -1;
  if(A >= 12) {
    sum += A;
    A = 0;
  }
  for(int i = 0; i < 2; i++) {
    int temp = sum + Ap[A][i];
    if(temp > 21) temp = 0;
    if(temp > best) best = temp;
  }

  return best;
}

int main() {
  while(1) {
    string str;
    getline(cin, str);
    if(str == "0") break;

    stringstream sin;
    sin << str;
    int card[1000];
    fill(&card[0], &card[999]+1, 0);
    int num;
    for(int i = 0; i < 1000; i++) {
      if(!(sin >> card[i])) {
	num = i;
	break;
      }
      if(i+1 == 1000) {
	num = 1000;
	break;
      }
    }
    cout << calc(card, num) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

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

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

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int l,r,d;
  cin>>l>>r>>d;
  int cnt=0;
  for(int i=l;i<=r;i++){
    if(i%d==0){
      cnt++;
    }
  }
  cout<<cnt<<endl;

  return 0;
}



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

using namespace std;

void rotateString(string *str)
{
	*str = str->substr(str->size() - 1, 1) + str->substr(0, str->size() - 1);
}

int main()
{
	
	string s = "tokyo";
	string t = "kyoto";

	//Rotate
	//s = s.substr(s.size()-1, 1) + s.substr(0,s.size() - 1);

	cin >> s >> t;

	int size = s.size();
	for (int i = 0; i < size; i++) {
		rotateString(&s);
		if (t.compare(s) == 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main() {
    int N; cin >> N;    
    bool flag = false;
    int ans;
    for (int i = 1; i <= 50000; i++) {
        if (floor(i * 1.08) == N) {
            ans = i;
            flag = true;
            break;
        }
    }
    if (flag) cout << ans << endl;
    else cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	string S;
	cin >> S;

	for (int i = 0; i < S.size(); i++)
	{
		if (S[i] == ',')
		{
			S[i] = ' ';
		}
	}

	cout << S;

	return 0;
}


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

using namespace std;

const int N = 2005;
int u[N][N], d[N][N], l[N][N], r[N][N];
char s[N][N];

int main() {
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            u[i][j] = 0;
            d[i][j] = 0;
            l[i][j] = 0;
            r[i][j] = 0;
        }
    }

    int H, W;
    cin >> H >> W;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; ++j) {
            cin >> s[i][j];
        }
    }

    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (s[i][j] != '#') {
                u[i][j] = u[i - 1][j] + 1;
                l[i][j] = l[i][j - 1] + 1;
            }
        }
    }

    for (int i = H; i >= 1; i--) {
        for (int j = W; j >= 1; j--) {
            if (s[i][j] != '#') {
                d[i][j] = d[i + 1][j] + 1;
                r[i][j] = r[i][j + 1] + 1;
            }
        }
    }

    int ans = 0;
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (s[i][j] != '#') {
                ans = max(ans, u[i][j] + d[i][j] + l[i][j] + r[i][j] - 3);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 66944
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
long long m[100000];
int main() {
	int n;
	cin >> n;
	for (int z = 0; z < n; z++) {
		long long a;
		cin >> a;
		int sum = 0;
		while (to_string(a).length() != 1) {
			string h = to_string(a), c, d;
			long long b = 0;
			for (int i = 0; i < h.length() - 1; i++) {
				c = h.substr(0, i+1);
				d = h.substr(i+1, h.length()-i-1);
				b = max((stoll(c)*stoll(d)), b);
			}
			a = b;
			int s = 0, e = sum - 1, t;
			while (e - s > 1) {
				t = (e + s) / 2;
				if (m[t] >= a) s = t;
				if (m[t] < a) e = t;
			}
			if ((m[s] == a || m[e] == a)&&s>=0&&e>=0) {
				sum = -1;
				break;
			}
			m[sum] = a;
			sort(m, m + sum);
			sum++;
		}
		cout << sum << endl;
	}
}

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

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

using namespace std;

class mint{
	static const int MOD=998244353;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long x,const mint& m){ return m+x; }
mint operator*(long long x,const mint& m){ return m*x; }

mint pow(mint m,long long k){
	mint res=1;
	for(;k>0;k>>=1,m*=m) if(k&1) res*=m;
	return res;
}

mint fact(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		for(;k<=n;k++) memo[k]=memo[k-1]*k;
	}
	return memo[n];
}

mint fact_inverse(int n){
	static vector<mint> memo={1};
	if(memo.size()<=n){
		int k=memo.size();
		memo.resize(n+1);
		memo[n]=inverse(fact(n));
		for(int i=n;i>k;i--) memo[i-1]=memo[i]*i;
	}
	return memo[n];
}

mint choose(int n,int k,int type=0){
	if(k==0) return 1;
	if(n< k) return 0;
	if(type==0){
		return fact(n)*fact_inverse(k)*fact_inverse(n-k);
	}
	else{
		if(k>n-k) k=n-k;
		mint res=fact_inverse(k);
		rep(i,k) res*=n-i;
		return res;
	}
}

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

	mint ans=0;
	rep(i,k+1) ans+=choose(n-1,i)*m*pow(mint(m-1),n-i-1);
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 5396
N,W = map(int,input().split())
items = []
for i in range(N):
  items.append(list(map(int,input().split())))

dp = [ [0]*(W+1) for _ in range(N+1) ]
for i in range(1, N+1):
  val,wei = items[i-1]
  for w in range(W+1):
    if w >= wei:
      dp[i][w] = max(dp[i-1][w], dp[i][w-wei]+val)
    else:
      dp[i][w] = max(dp[i-1][w], dp[i][w-1])

print(dp[N][W])


Measured memory_bytes: 15700
fn read_ls<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main(){
    for _ in 0..{
       let r:Vec<String> = read_ls();
        let (a, b): (i32,i32) = (r[0].parse().ok().unwrap(), r[2].parse().ok().unwrap());
        if r[1] == "?" {
            break
        }else if r[1] == "+" {
            println!("{}", a+b)
        }else if r[1] == "-"{
            println!("{}", a-b)
        }else if r[1] == "/"{
            println!("{}", a/b)
        }else if r[1] == "*"{
            println!("{}", a*b)
        }
    }
}



Measured memory_bytes: 5036
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char c = sc.next().toCharArray()[0];

		if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
			System.out.println("vowel");
		} else {
			System.out.println("consonant");
		}
	}
}


Measured memory_bytes: 9044
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        double[] v = new double[N];
        for (int i = 0; i < v.length; i++) {
            v[i] = sc.nextDouble();
        }
        Arrays.sort(v);
        double res = v[0];
        for (int i = 1; i < v.length; i++) {
            res = (res + v[i]) / 2;
        }
        System.out.println(res);
        sc.close();
    }
}

Measured memory_bytes: 23252
# 木によってLISを作り、dfsで抜けるときにLISをその前の状態まで復元する

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_ints(): return list(map(int, read().split()))


def read_a_int(): return int(read())


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


from bisect import bisect_left, bisect_right
from collections import defaultdict
N = read_a_int()
A = read_ints()
U, V = read_col(N - 1)
U = mina(*U)
V = mina(*V)
tree = defaultdict(lambda: [])
for u, v in zip(U, V):
    tree[u].append(v)
    tree[v].append(u)

LIS = []
ans = [0] * N  # 各ノードのlen(LIS)を記録


def dfs(now, p):  # 現在のノード、親
    a = A[now]
    # LISの更新
    idx = bisect_left(LIS, a)
    is_append = False
    if idx == len(LIS):
        LIS.append(a)
        is_append = True
    else:
        old = LIS[idx]   # なんの値だったか持っておく
        LIS[idx] = a  # aに更新

    ans[now] = len(LIS)  # 答えを記録
    # 次のノードを探索
    for to in tree[now]:
        if to == p:
            continue
        dfs(to, now)

    # 抜けるときにLISを復元
    if is_append:
        del LIS[idx]
    else:
        LIS[idx] = old


dfs(0, -1)
print(*ans, sep='\n')


Measured memory_bytes: 539508
package main

import (
	"fmt"
)

func BubbleSort(A []int) int{
	var cnt int
	for i:=0; i<len(A)-1; i++{
		for j:=len(A)-1; j>=i+1; j--{
			if A[j] < A[j-1]{
				A[j], A[j-1] = A[j-1], A[j]
				cnt++
			}
		}
	}
	return cnt
}
func main(){
	var n int
	fmt.Scan(&n)
	A := make([]int, n)
	for i:=0; i<n; i++{
		fmt.Scan(&A[i])
	}
	cnt := BubbleSort(A)
	for i:=0; i<n; i++{
		fmt.Print(A[i])
		if i == n-1{
			fmt.Print("\n")
		} else {
			fmt.Print(" ")
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;  
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  
  vector<vector<Int> > G(n);
  for(Int i=1;i<n;i++){
    Int x,y;
    cin>>x>>y;
    x--;y--;   
    G[x].emplace_back(y);
    G[y].emplace_back(x);
  }

  const Int INF = 1e17;
  vector<vector<Int> > dp1(n),dp2(n);
  function<void(Int, Int)> dfs=
    [&](Int v,Int p){
      for(Int u:G[v])
        if(u!=p) dfs(u,v);
      
      dp1[v].assign(1,INF);
      dp2[v].assign(1,INF);

      if(a[v]>0) dp1[v][0]=a[v];
      if(a[v]<0) dp2[v][0]=a[v];

      for(Int u:G[v]){
        if(u==p) continue;
        Int x=dp1[v].size();        
        Int y=dp1[u].size();        
        vector<Int> nx1(x+y,INF),nx2(x+y,INF);
        for(Int i=0;i<x;i++){
          for(Int j=0;j<y;j++){
            chmin(nx1[i+j],dp1[v][i]+dp1[u][j]);
            chmin(nx2[i+j],dp1[v][i]+dp2[u][j]);
            chmin(nx2[i+j],dp2[v][i]+dp1[u][j]);
            chmin(nx2[i+j],dp2[v][i]+dp2[u][j]);
            
            if(i+j+1<x+y){
              if(dp1[u][j]<INF/2) chmin(nx1[i+j+1],dp1[v][i]);
              if(dp1[u][j]<INF/2) chmin(nx2[i+j+1],dp2[v][i]);
              if(dp2[u][j]<0) chmin(nx1[i+j+1],dp1[v][i]);
              if(dp2[u][j]<0) chmin(nx2[i+j+1],dp2[v][i]);
            }           
          }
        }        
        swap(dp1[v],nx1);
        swap(dp2[v],nx2);
      }
    };
  dfs(0,-1);
  
  Int ans=n;
  for(Int i=0;i<n;i++){
    //cout<<i<<":"<<dp1[0][i]<<" "<<dp2[0][i]<<endl;
    if(dp1[0][i]<INF/2) chmin(ans,i);
    if(dp2[0][i]<0) chmin(ans,i);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main()
{
    int N;
    cin >> N;
    long long A[N];
    long long S[N];
    cin >> A[0];
    S[0] = A[0];
    for (int i = 1; i < N; i++)
    {
        cin >> A[i];
        S[i] = S[i - 1] + A[i];
    }
    long long left[N][2] = {};
    int center = 0;
    int next_center = 1;
    for (int i = 1; i < N - 2; i++)
    {
        while (
            next_center < i &&
            abs((S[i] - S[center]) - S[center]) > abs((S[i] - S[next_center]) - S[next_center]))
        {
            center++;
            next_center++;
        }
        left[i][0] = S[center];
        left[i][1] = S[i] - S[center];
    }

    long long right[N][2] = {};
    center = 2;
    next_center = 3;
    for (int i = 1; i < N - 2; i++)
    {
        while (
            next_center < N - 1 &&
            abs((S[N - 1] - S[center]) - (S[center] - S[i])) > abs((S[N - 1] - S[next_center]) - (S[next_center] - S[i])))
        {
            center++;
            next_center++;
        }
        right[i][0] = S[center] - S[i];
        right[i][1] = S[N - 1] - S[center];
    }

    long long ans = LONG_LONG_MAX;
    for (int i = 1; i < N - 2; i++)
    {
        max(max(left[i][0], left[i][1]), max(right[i][0], right[i][1])) - min(min(left[i][0], left[i][1]), min(right[i][0], right[i][1]));
        ans = min(ans, max(max(left[i][0], left[i][1]), max(right[i][0], right[i][1])) - min(min(left[i][0], left[i][1]), min(right[i][0], right[i][1])));
    }
    cout << ans << endl;
}


Measured memory_bytes: 9600
import java.util.Scanner;

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

		for(int i=1;i<=n;i+=2) {
			int cnt=0;
			for(int j=1;j<=i;j++) {
				if(i%j==0) {
					cnt++;
				}
			}
			if(cnt==8) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define ll long long
 
//const int INF = 1e8;
typedef pair<int,int>P;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
queue<P> que;

int main(){
  int n;cin >> n;
  int m;cin >> m;
  int s = 0;int ans = 1;
  for(int i = 0;i<n;i++){
    int ai;cin >> ai;
    s +=  ai;
    if(s <= m) ans += 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;

ll gcd(ll a,ll b){
  if(a%b==0) return b;
  else return gcd(a,a%b);
}
ll lcm(ll a,ll b){
  ll g = gcd(a,b);
  return a/g*b;
}

int main(){
  ll x,y;
  cin >> x >> y;
  ll ans = INFL;

  if(y>x) ans = min(ans,y-x);
  if(y>=-x) ans = min(ans,y+x+1);
  if(-y>x) ans = min(ans,-y-x+1);
  if(-y>-x) ans = min(ans,-y+x+2);

  cout << ans << endl;
}


Measured memory_bytes: 3584
import java.util.Scanner;

/**
 * @author subaru
 */
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();
        if (A < C && B > C || A > C && B < C) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21588
/**
 *  author: andychen
 *  created: 09.13.2020 20:07:52
**/

#include <bits/stdc++.h>

using namespace std;

const long long mod = 1e9 + 7;

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

    if (n == 1){
        cout << 0 << '\n';
        return 0;
    }

    long long ans = 1, minus = 1, one = 1;
    for (int i = 0; i < n; i++){
        ans *= 10;
        ans %= mod;
        minus *= 8;
        minus %= mod;
        one *= 9;
        one %= mod;
    }

    one *= 2;
    one %= mod;

    ans = (ans - one + minus) % mod;

    while (ans < 0)
        ans += mod;

    cout << ans % mod << '\n';

    return 0;
}


Measured memory_bytes: 3652
def main():
    N, K, *A = map(int, open(0).read().split())
    visited = [-1]*N
    pos = A[0]
    visited[0] = 0
    visited[pos - 1] = 1
    step = 2
    order = 0
    start = 0
    step_to_start = 0
    while True:
        pos = A[pos - 1]
        if visited[pos - 1] == -1:
            visited[pos - 1] = step
        else:
            step_to_start = visited[pos - 1]
            order = step - step_to_start
            start = pos
            break
        step += 1
    # print(start, step_to_start, order)

    if K <= step_to_start:
        ans = 1
        for i in range(K):
            ans = A[ans - 1]
        print(ans)
        return
    remain = (K - step_to_start) % order
    ans = start
    for i in range(remain):
        ans = A[ans - 1]
    print(ans)

if __name__ == '__main__':
  main()


Measured memory_bytes: 32424
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=110;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,a[N],ans=0;
int main() {
    n=gi();
    for(int i=1;i<=n;i++) {
        a[i]=gi();
        if(a[i]==a[i-1]) a[i]=-1,++ans;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC049A
{
    class Program
    {
        static void Main(string[] args)
        {
            var c = Console.ReadLine();
            var a = new string[] { "a", "e", "i", "o", "u" };
            for (var i=0;i<5;i++)
            {
                if (a[i] == c)
                {
                    Console.WriteLine("vowel");
                    return;
                }
                
            }
            Console.WriteLine("consonant");
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define EPS (1e-10)
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))





signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int a, b, c; cin >> a >> b >> c;
	int ans = gcd(a, gcd(b, c));
	if (a == b && b == c) {
		if (a % 2 == 0)cout << -1 << endl;
		else cout << 0 << endl;
		return 0;
	}
	int cnt = 0;
	while (true) {
		if (a % 2 != 0 || b % 2 != 0 || c % 2 != 0) {
			cout << cnt << endl; return 0;
		}
		int ta = (b + c) / 2;
		int tb = (a + c) / 2;
		int tc = (a + b) / 2;
		a = ta; b = tb; c = tc;
		cnt++;
	}
	return 0;
}

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

int main() {
    int N, A, ans;
    cin >> N;
    ans = 10000;

    int n;
    rep(i, N){
        n = 0;
        cin >> A;
        while (A % 2 == 0) {
            A /= 2;
            n++;
        }
        if (n < ans) {
            ans = n;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

class cake{
public:
	int id,x,y;
	cake(int _id, int _x, int _y){
		id=_id; x=_x; y=_y;
	}
	bool operator<(const cake& a)const{
		return x*y < a.x*a.y;
	}
};
int main(){
	int n,w,d,p,s;
	vector<cake> v;
	while(scanf("%d%d%d",&n,&w,&d),n|w|d){
		v.clear();
		v.push_back(cake(1,w,d));
		
		rep(i,n){
			scanf("%d%d",&p,&s);
			int vz = v.size();
			rep(j,vz)if( p==v[j].id ){
				//printf("%d , %d , %d  --> kirikuti:%d , %d\n",s,v[j].x,v[j].y,
				//	s-(2*(v[j].x+v[j].y)),s%(2*(v[j].x+v[j].y)));
				/*
				if( 2*(v[j].x+v[j].y)<s ){
					s -= (2*(v[j].x+v[j].y));
				}
				*/
				s %= (2*(v[j].x+v[j].y));
				if( s<v[j].x || v[j].x+v[j].y<s && s<2*v[j].x+v[j].y ){ //tate
					if( s>v[j].x ){
						s = s-(v[j].x+v[j].y);
					}
					int pe1_x = s;
					int pe2_x = v[j].x-s;
					int sz = v.size();
					//v[j].x = min(pe1_x, pe2_x);
					v.push_back( cake(sz+1, min(pe1_x, pe2_x), v[j].y) );
					v.push_back( cake(sz+2, max(pe1_x, pe2_x), v[j].y) );
					v.erase(v.begin()+j);
					rep(j,v.size())v[j].id=j+1;
					
					
					/*
					printf("x:%d,%d\n",pe1_x, pe2_x);
					rep(k,v.size()){
						printf("%d,%d,%d\n",v[k].id, v[k].x, v[k].y);
					}
					*/
					
					
				}else{
					//printf("YYYY: s:%d , %d\n",s,2*v[j].x+v[j].y);
					if( s>2*v[j].x+v[j].y ){
						s = 2*(v[j].x+v[j].y) - s;
						//printf("YYYY: after_1s:%d\n",s);
					}else{
						s -= v[j].x;
						//printf("YYYY: after_2s:%d\n",s);
					}
					int pe1_y = s;
					int pe2_y = v[j].y-s;
					if( pe1_y==-1 || pe2_y==-1 ){
						printf("__________________________________\n");
					}
					int sz = v.size();
					//v[j].y = min(pe1_y, pe2_y);
					v.push_back( cake(sz+1, v[j].x, min(pe1_y, pe2_y)) );
					v.push_back( cake(sz+2, v[j].x, max(pe1_y, pe2_y)) );
					v.erase( v.begin()+j );
					
					rep(j,v.size())v[j].id=j+1;
					
					/*
					printf("y:%d,%d\n",pe1_y, pe2_y);
					rep(k,v.size()){
						printf("%d,%d,%d\n",v[k].id, v[k].x, v[k].y);
					}
					*/
					
				}
				break;
			}
		}
		sort(all(v));
		rep(i,v.size()){
			if( i!=0 )putchar(' ');
			printf("%d",v[i].x*v[i].y);
		}puts("");
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    int x,i;
    while(scanf("%d",&x)==1)
    {
        for(i=pow(x,0.5);i/2.0*(i+1)<x;i++);
        printf("%d\n",i);
    }
    return 0;
}


Measured memory_bytes: 512
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
	static final long MOD1 = 1000000007L;
	static final long MOD2 = 1000000009L;
	static final long BASE = 31L;
	
	static final int INF = 1000000007;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		
		int N = sc.ni();
		String[] strs = new String[N];
		boolean[][][] contains = new boolean[N][][];
		for (int i = 0; i < N; i++) {
			strs[i] = sc.next();
			int M = strs[i].length();
			contains[i] = new boolean[M][26];
			for (int j = 0; j < M; j++) {
				contains[i][j][strs[i].charAt(j)-'a'] = true;
				if (j==0)continue;
				for (int k = 0; k < 26; k++) {
					contains[i][j][k] |= contains[i][j-1][k];
				}
			}
		}
		
		HashSet<Long> hashes = new HashSet<Long>();
		for (String s: strs) {
			int M = s.length();
			long h1 = 0;
			long h2 = 0;
			long pow1 = 1;
			long pow2 = 1;
			for (int i = M-1; i >= 0; i--) {
				h1 = (h1+pow1*(s.charAt(i)-'a'+1))%MOD1;
				h2 = (h2+pow2*(s.charAt(i)-'a'+1))%MOD2;
				pow1 = (pow1*BASE)%MOD1;
				pow2 = (pow2*BASE)%MOD2;
			}
			long hash = MOD2*h1+h2;
			hashes.add(hash);
		}

		long ans = 0;
		for (int a = 0; a < N; a++) {
			String s = strs[a];
			int M = s.length();
			long h1 = 0;
			long h2 = 0;
			long pow1 = 1;
			long pow2 = 1;
			for (int i = M; i >= 1; i--) {
				if (i < M) {
					h1 = (h1+pow1*(s.charAt(i)-'a'+1))%MOD1;
					h2 = (h2+pow2*(s.charAt(i)-'a'+1))%MOD2;
					pow1 = (pow1*BASE)%MOD1;
					pow2 = (pow2*BASE)%MOD2;
				}

				long hash = MOD2*h1+h2;
				for (int j = 0; j < 26; j++) {
					if (contains[a][i-1][j]) {
						long h1C = (h1+pow1*(j+1))%MOD1;
						long h2C = (h2+pow2*(j+1))%MOD2;
						long hashC = MOD2*h1C+h2C;
						if (hashes.contains(hashC)) {
							ans++;
						}
					}
				}
			}
		}
		pw.println(ans-N);
		
		pw.close();
	}
	
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        }
        
        int ni() { 
            return Integer.parseInt(next()); 
        }
  
        long nl() { 
            return Long.parseLong(next()); 
        } 
  
        double nd() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() {
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str;
        }
    }
}

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

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; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

ll pow(ll a, ll n) {
	ll ret = 1LL;
	for (; n > 0LL; n >>= 1LL, a = a * a) {
		if (n % 2LL == 1LL) {
			ret = ret * a;
		}
	}
	return ret;
}

int main() {
  ll K;
  cin>>K;
  ll ans = 0LL;
  ll cnt = 0LL;
  ll t = 0LL;
  while(cnt<K){
    ans = ans+ pow(10LL,t);
    ll a = (ans/pow(10LL,t+1LL))%10LL,b=(ans/pow(10LL,t+2))%10LL;
    if(9*t-1LL<9LL*a+99LL*b&&ans>9LL){
      ans-=pow(10LL,t);
      t++;
      ll c = pow(10LL,t)-1LL+(ans/pow(10LL,t))*pow(10LL,t);
      if(ans==c) c+=pow(10LL,t);
      ans=c;
    }
    cout<<ans<<endl;
    cnt++;
  }
}

Measured memory_bytes: 256
// G++ MACRO.CPP -STD=C++17
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#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 possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
 
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}
 
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}
 
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<ll,ll>
#define V vector<ll>
#define M map<ll,ll>
#define S set<ll>
 
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  CIN(n);
  COUT(800*n - 200 * (n/15));


  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include<numeric>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[0] << " " << a[1] << " " << a[2] << endl;
	return 0;
}


Measured memory_bytes: 3172
import java.util.Scanner
object Main extends App {
  val sc = new Scanner(System.in)
  val ds = Array.fill(5)(sc.nextInt)
  val sum = ds.map(d => (d + 9) / 10 * 10).sum
  val correct = ds.map(_ % 10).filter(_ != 0) match {
    case Array() => 0
    case l => 10 - l.min
  }
  println(sum - correct)
}

Measured memory_bytes: 25516
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll INF = ll(1e18)+1;


int main(void) {
  int a[9];
  rep(i, 9) {
    cin >> a[i];
  }


  int n;
  cin >> n;
  int c = 9;
  rep(i, n) {
    int b;
    cin >> b;
    rep(j, 9) {
      if(b == a[j]) {
        a[j] = 0;
        c--;
      }
    }
    if(c == 0) {
      cout << "Yes" << endl;
      return 0; 
    }
  }
  for(int i = 0; i < 3; ++i) {
    if(a[i] == 0) {
      if(a[i+3] == 0) {
        if(a[i+6] == 0) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }

  for(int i = 0; i < 7; i+=3 ) {
    if(a[i] == 0) {
      if(a[i+1] == 0) {
        if(a[i+2] == 0) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }
  
  if(a[0] == 0) {
    if(a[4] == 0) {
      if(a[8] == 0) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  if(a[2] == 0) {
    if(a[4] == 0) {
      if(a[6] == 0) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;

  return 0;
}

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

int main() {
  int N, a, b, c, d;
  cin >> N;
  a = N%10;
  b = N%100/10;
  c = N%1000/100;
  d = N/1000;
  if(b==c){
    if(a==b || d==b){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" <<endl;
    }
  }
  else{
     cout << "No" <<endl;
  }
}

Measured memory_bytes: 256