akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

typedef pair<int, int> P;

int main()
{
	ll x;
	cin >> x;

	ll a[6] = { 100,101,102,103,104,105 };

	ll tmp = 0;
	rep(i0, 1000)
	{
		tmp = a[0] * i0;
		if (tmp == x)
		{
			cout << 1 << endl;
			return 0;
		}
		if (tmp > x)
		{
			break;
		}

		rep(i1, 1000)
		{
			tmp = a[0] * i0 + a[1] * i1;
			if (tmp == x)
			{
				cout << 1 << endl;
				return 0;
			}
			if (tmp > x)
			{
				break;
			}

			rep(i2, 1000)
			{
				tmp = a[0] * i0 + a[1] * i1 + a[2] * i2;
				if (tmp == x)
				{
					cout << 1 << endl;
					return 0;
				}
				if (tmp > x)
				{
					break;
				}

				rep(i3, 1000)
				{
					tmp = a[0] * i0 + a[1] * i1 + a[2] * i2 + a[3] * i3;
					if (tmp == x)
					{
						cout << 1 << endl;
						return 0;
					}
					if (tmp > x)
					{
						break;
					}

					rep(i4, 1000)
					{
						tmp = a[0] * i0 + a[1] * i1 + a[2] * i2 + a[3] * i3 + a[4] * i4;
						if (tmp == x)
						{
							cout << 1 << endl;
							return 0;
						}
						if (tmp > x)
						{
							break;
						}

						rep(i5, 1000)
						{
							tmp = a[0] * i0 + a[1] * i1 + a[2] * i2 + a[3] * i3 + a[4] * i4 + a[5] * i5;
							if (tmp == x)
							{
								cout << 1 << endl;
								return 0;
							}
							if (tmp > x)
							{
								break;
							}

						}

					}

				}

			}

		}
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define endl "\n"
typedef long long ll;

const int BIG_NUM = 1e9;

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

    int n;
    cin >> n;
    vector<long long> a(n);
    rep(i, n) {
        cin >> a[i];
    }
    ll ans = 1;
    rep(i, n) {
        if(a[i] == 0) {
            cout << 0 << "\n";
            return 0;
        }
    }
    rep(i, n) {
        if(a[i] <=  1000000000000000000 / ans) {
            ans *= a[i];
        } else {
            ans = -1;
            break;
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3904
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():

    mod = 998244353
    n, k = LI()
    l = [0 for _ in range(k)]
    r = [0 for _ in range(k)]

    for i in range(k):
        l[i], r[i] = LI()

    dp = [0 for _ in range(n+1)]      
    dpsum = [0 for _ in range(n+1)]
    dp[1], dpsum[1] = 1, 1

    for i in range(2,n+1):
        for el, er in zip(l, r):
            dp[i] += dpsum[max(i-el, 0)] - dpsum[max(i-er-1, 0)]
        dp[i] %= mod
        dpsum[i] = (dpsum[i-1] + dp[i])%mod

    print(dp[n])

main()


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  string s;
  cin >> s;
  int a = s.at(0) - '0';
  int b = s.at(1) - '0';
  int c = s.at(2) - '0';
  int d = s.at(3) - '0';
  for (char const &c1 : "+-") {
    for (char const &c2 : "+-") {
      for (char const &c3 : "+-") {
        int tmp = 0;
        if (c1 == '+') {
          tmp = a + b;
        } else {
          tmp = a - b;
        }

        if (c2 == '+') {
          tmp = tmp + c;
        } else {
          tmp = tmp - c;
        }

        if (c3 == '+') {
          tmp = tmp + d;
        } else {
          tmp = tmp - d;
        }

        if (tmp == 7) {
          cout << a << c1 << b << c2 << c << c3 << d << "=7" << endl;
          return 0;
        }
      }
    }
  }

  return 0;
}


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

const int MOD = 1E9 + 7;

int reg[3][3] = {{2, 2, 1}, {1, 1, 1}, {1, 0, 1}}, brk[3][3] = {{1, 2, 1}, {0, 1, 1}, {0, 0, 1}};
int tmp[3][3], ans[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};

void mul (int a[3][3], int b[3][3], int c[3][3]) {
	int tmp[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
	for (int i = 0; i < 3; ++i)
		for (int j = 0; j < 3; ++j)
			for (int k = 0; k < 3; ++k)
				tmp[i][j] = (tmp[i][j] + 1ll * b[i][k] * c[k][j]) % MOD;
	for (int i = 0; i < 3; ++i) for (int j = 0; j < 3; ++j) a[i][j] = tmp[i][j];
}

void pow (int a[3][3], int b[3][3], int c) {
	int res[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, pp[3][3];
	for (int i = 0; i < 3; ++i) for (int j = 0; j < 3; ++j) pp[i][j] = b[i][j];
	while (c > 0) {
		if (c & 1) mul (res, res, pp);
		mul (pp, pp, pp);
		c >>= 1;
	}
	for (int i = 0; i < 3; ++i) for (int j = 0; j < 3; ++j) a[i][j] = res[i][j];
}

int N, M, X[110000];

int main () {
	std::ios::sync_with_stdio (0);
	std::cin >> N >> M;
	for (int i = 0; i < M; ++i) std::cin >> X[i];
	int init = 1;
	for (int i = 0; i < M; ++i) {
		pow (tmp, reg, X[i] - init);
		mul (ans, tmp, ans);
		mul (ans, brk, ans);
		init = X[i] + 1;
	}
	pow (tmp, reg, N - init);
	mul (ans, tmp, ans);
	std::cout << (1ll * ans[0][0] + 1ll * ans[0][1] + 1ll * ans[0][2]) % MOD << std::endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<deque>
#define ll long long
using namespace std;
#define BUF_SIZE 1048576
char _buf[BUF_SIZE],*_is=_buf,*_it=_buf;
inline char rdc(){
	if (_is==_it) _it=(_is=_buf)+fread(_buf,1,BUF_SIZE,stdin);
	return *_is++;
}
inline int rdi(){
	int x=0,f=0;
	register char ch=rdc();
	while ((ch<'0' or ch>'9') and (ch^'-')) ch=rdc();
	if (ch=='-') f=1,ch=rdc();
	while (ch>='0' and ch<='9') x=(x<<3)+(x<<1)+(ch^'0'),ch=rdc();
	return f?-x:x;
}
inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
inline void _write(int x){
	write(x);
	putchar(' ');
}
inline void print(int x){
	write(x);
	putchar('\n');
}
char c[1001][1001];
int dp[1001][1001];
const int md=1000000007;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n,m,i,j;
	cin>>n>>m;
	dp[1][1]=1;
	for(i=1;i<=n;++i) for(j=1;j<=m;++j) cin>>c[i][j];
	for(i=1;i<=n;++i) for(j=1;j<=m;++j){
		if(c[i-1][j]=='.') dp[i][j]+=dp[i-1][j];
		if(c[i][j-1]=='.') dp[i][j]+=dp[i][j-1];
		if(dp[i][j]>=md) dp[i][j]-=md;
	}
	cout<<dp[n][m]<<endl;
	return 0;
}



Measured memory_bytes: 5120
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

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

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTA(a,n) sort(a,a+n)
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int n,k;
    cin >> n >> k;
    int x[110];
    REP(i,0,n) cin >> x[i];
    //処理
    int ans=0;
    REP(i,0,n) ans += min(x[i],k-x[i]);
    //出力
    cout << 2*ans << ENT;
    return 0;
}

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


Measured memory_bytes: 256
import sys
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = map(int, read().split())

L = defaultdict(int)
R = defaultdict(int)
for i, x in enumerate(A, 1):
    l = i + x
    r = i - x
    L[l] += 1
    R[r] += 1
# print('L', L)
# print('R', R)
ans = 0
for key, l_value in L.items():
    r_value = R[key]
    ans += l_value * r_value
print(ans)
# memo = defaultdict(int)
# answer = 0
# for i, x in enumerate(A, 1):
#     answer += memo[i - x]
#     memo[x + i] += 1

# print('memo', memo)
# print(answer)


Measured memory_bytes: 74372
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wsign-compare"

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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	int tc = 1; //cin >> tc;
	while (tc--)
	{
		int i, j, n;
		string s;
		cin >> s;
		char c = s[0];
		bool ans = false;
		for (i = 1; i < s.size (); ++i)
			if (c != s[i]) 
				ans = true;
		if (ans) cout << "Yes\n";
		else cout << "No\n";
	}

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	while(1){
		int h,w;
		cin >> h >> w;
		if(h == 0 && w == 0){
			break;
		}
		for(int n = 0; n < h; n++){
			for(int m = 0; m < w; m++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define fore(i, b, e) for (int i = (int)(b); i < (int)(e); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long i64;
typedef unsigned long long u64;
typedef long double ld;
typedef long long ll;

const int maxn = 100500;
const int K = 200;
const int nbl = maxn / K + 5;

int X;
int n;
int a[maxn];
int id[maxn];
int t[maxn];
int res[maxn];
pii M[maxn];

vi times;
int T = 0;
size_t pos = 0;

void scan() {
    cin >> X;
    int k;
    cin >> k;
    times.resize(k);
    forn(i, k) {
        cin >> times[i];
    }
    cin >> n;
    vector<tuple<int, int, int>> in(n);
    forn(i, n) {
        int x, y;
        cin >> x >> y;
        in[i] = make_tuple(y, x, i);
    }
    sort(all(in));
    forn(i, n) {
        tie(a[i], t[i], id[i]) = in[i];
    }
}

void update(int b) {
    if (M[b] == pii(1, 0)) return;
    int L = b * K;
    int R = min(L + K, n);
    fore(i, L, R) {
        a[i] = a[i] * M[b].fi + M[b].se;
    }
    M[b] = {1, 0};
}

pii minmax(int b) {
    int L = b * K;
    int R = min(L + K, n);

    return pii(
            a[L] * M[b].fi + M[b].se,
            a[R-1] * M[b].fi + M[b].se);
}

int cc(int x) {
    return min(X, max(x, 0));
}

void answer(int i) {
    update(i / K);
    int x = a[i];
    if (pos%2 == 0) {
        x -= t[i] - times[pos];
    } else {
        x += t[i] - times[pos];
    }
    res[id[i]] = cc(x);
}

void addb(int x, int b) {
    update(b);
    int L = b * K;
    int R = min(L + K, n);
    fore(i, L, R) {
        if (pos%2 == 0) a[i] = cc(a[i] - x);
        else a[i] = cc(a[i] + x);
    }
}

void add(int x) {
    x = min(x, X);
    if (pos%2 == 0) {
        forn(i, (n-1)/K+1) {
            int l, r;
            tie(l, r) = minmax(i);
            if (r <= x) M[i] = {0, 0};
            else if (l >= x) M[i] = { M[i].fi, M[i].se - x };
            else addb(x, i);
        }
    } else {
        forn(i, (n-1)/K+1) {
            int l, r;
            tie(l, r) = minmax(i);
            if (r <= X-x) M[i] = { M[i].fi, M[i].se + x};
            else if (l >= X-x) M[i] = { 0, X };
            else addb(x, i);
        }
    }
}

void solve() {
    forn(i, maxn) M[i] = {1, 0};
    vector<pii> byt(n);
    forn(i, n) byt[i] = { t[i], i };
    sort(all(byt));
    int pt = 0;
    times.insert(times.begin(), 0);
    while (pos < times.size() - 1) {
        int nt = times[pos+1];
        while (pt < n && byt[pt].fi <= nt) {
            answer(byt[pt++].se);
        }
        T = nt;
        add(times[pos + 1] - times[pos]);
        ++pos;
    }
    while (pt < n) {
        answer(byt[pt++].se);
    }
    forn(i, n) {
        cout << res[i] << "\n";
    }
}

int main() {
#ifdef LOCAL
    freopen("f.in", "r", stdin);
#endif

    ios::sync_with_stdio(false);

    scan();
    solve();

#ifdef LOCAL
    cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
#endif
    return 0;
}


Measured memory_bytes: 4708
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

mt19937 rng (chrono::steady_clock::now().time_since_epoch().count() );

const int MOD = 998244353;
const ll INF = 1e18;
const int N = 1e6 + 12; //check the limits, dummy


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

    ll n;
    cin >> n;
    vl a (n);
    FOR (i, 0, n) cin >> a[i];
    if (a[0] != 0) {
        cout << 0 << '\n';
        return 0;
    }
    sort (all (a) );
    ll idx = 1;
    ll prev = 1;
    ll pval = 0;
    ll ans = 1;
    while (idx < n) {
        ll cur = a[idx];
        if (pval != cur - 1) {
            cout << 0;
            return 0;
        }
        ll frq = 0;
        while (idx < n && cur == a[idx]) {
            ans = ans * prev % MOD;
            frq++;
            idx++;
        }
        pval = cur;
        prev = frq;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1024
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 5005
const int inf=1e9,mod=1e9+7;

int n,m,tot,root;
int now[maxn],pre[maxn*2],son[maxn*2],mx[maxn],size[maxn],fac[maxn],inv[maxn];
int f[maxn][maxn];

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

inline void print(int x){
	if (x<0){putchar('-'); x=-x;}
	if (x>=10) print(x/10);
	putchar(x%10+'0');
}

void add(int a,int b){son[++tot]=b,pre[tot]=now[a],now[a]=tot;}
void link(int a,int b){add(a,b),add(b,a);}

void find_root(int x,int fa){
	size[x]=1;
	for (int p=now[x];p;p=pre[p])
		if (son[p]!=fa){
			find_root(son[p],x),size[x]+=size[son[p]];
			mx[x]=max(mx[x],size[son[p]]);
		}
	mx[x]=max(mx[x],n-size[x]);
	if (mx[x]<mx[root]) root=x;
}

void dfs(int x,int fa){
	size[x]=1;
	for (int p=now[x];p;p=pre[p])
		if (son[p]!=fa) dfs(son[p],x),size[x]+=size[son[p]];
}

int C(int n,int m){return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;}
int A(int n,int m){return 1ll*fac[n]*inv[n-m]%mod;}

int main(){
	n=read();
	for (int i=1,x,y;i<n;i++) x=read(),y=read(),link(x,y);
	mx[root]=inf,find_root(1,0);
	if ((~n&1)&&mx[root]==(n>>1)){
		int ans=1,pps=n>>1;
		for (int i=2;i<=pps;i++) ans=1ll*ans*i%mod;
		ans=1ll*ans*ans%mod;
		cout<<ans<<endl;
		return 0;
	}
	fac[0]=1; for (int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[0]=inv[1]=1; for (int i=2;i<=n;i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	for (int i=1;i<=n;i++) inv[i]=1ll*inv[i]*inv[i-1]%mod;
	dfs(root,0); f[0][0]=1; int i=1;
	for (int p=now[root];p;p=pre[p],i++){
		int x=son[p];
		for (int j=0;j<=size[x];j++)
			for (int k=0;k+j<n;k++)
				f[i][j+k]=(f[i][j+k]+1ll*f[i-1][k]*C(size[x],j)%mod*A(size[x],j))%mod;
	}
	--i;
	int ans=0;
	for (int x=0;x<n;x++)
		ans=(ans+1ll*(x&1?-1:1)*fac[n-x]*f[i][x])%mod;
	cout<<(ans+mod)%mod<<endl;
	return 0;
}


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

int main()
{
    int n;
    scanf("%d", &n);
    for (int i=1; i<n+1; i++){  
         
        if( i % 3 == 0){
            printf(" %d", i);
        }else if ((i/1) % 10 == 3){
            printf(" %d", i);
        }else if ((i/10) % 10 == 3){
            printf(" %d", i);
        }else if ((i/100) % 10 == 3){
            printf(" %d", i);
        }else if ((i/1000) % 10 == 3){
            printf(" %d", i);
        }
    }
    printf("\n"); 
    return 0;
}           


Measured memory_bytes: 2096
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=22e4;

int a[N];
int bz[N];
int n,ans;

int main()
{
	scanf("%d",&n);
	fo(i,1,n)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	fd(l,30,1){
		int k=1<<l;
		int kt=1;
		fd(i,n,1)if(!bz[i]){
			while(kt<i&&(bz[kt]||a[kt]+a[i]<k))++kt;
			if(kt==i)break;
			if(a[kt]+a[i]==k){
				bz[kt]=bz[i]=1;
				++ans;
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;

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

vector<vector<P>> g(100010);
vector<ll> dist(100010, INF);

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P>> que;
    dist[s]=0;
    que.push(P(0, s));

    while(!que.empty()){
        P p=que.top(); que.pop();
        ll pcost=p.first, pv=p.second;
        if(dist[pv] < pcost) continue;

        for(int i=0; i<g[pv].size(); i++){
            P p2=g[pv][i];
            ll nv=p2.first, ncost=p2.second;
            if(dist[nv] > dist[pv] + ncost){
                dist[nv] = dist[pv] + ncost;
                que.push(P(dist[nv], nv));
            }
        }
    }
}

int main(){
    int v, e, r; cin>>v>>e>>r;
    for(int i=0; i<e; i++){
        int s, t, d; cin>>s>>t>>d;
        g[s].eb(P(t, d));
    }

    dijkstra(r);

    for(int i=0; i<v; i++){
        if(dist[i]!=INF) cout << dist[i] << endl;
        else cout << "INF" << endl;
    }
}


Measured memory_bytes: 13400
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    long long int n,d;
    cin>>n;
    int a=0;
    char c[n];
    for(int i=0;i<n;i++){
        cin>>c[i];
        if(c[i]=='R') a++;
    }
    int t=a;
    for(int i=0;i<a;i++){
        if(c[i]=='R') t--;
    }
    cout<<t<<endl;
}

Measured memory_bytes: 3788
#include<iostream>

using namespace std;

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


int main(){
  long long n, x,lgcd, a[100009];
  cin >> n >> x;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  if(n==1){
    cout << abs(x-a[0]) << endl;
  }
  else{
    lgcd = gcd(abs(a[0]-x), abs(a[1]-x));
    for(int i=2;i<n;i++){
      lgcd = gcd(lgcd, abs(a[i]-x));
    }
    cout << lgcd << endl;
  }
}

Measured memory_bytes: 1024
input = gets.chomp
card = input.split("\s")
a = card[0].to_i
b = card[1].to_i
if a == 1 && b != 1
    res = "Alice"
elsif b == 1 && a != 1
    res = "Bob"
elsif a > b
    res = "Alice"
elsif b > a
    res = "Bob"
else
    res = "Draw"
end
print(res, "\n")


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

using namespace std;

int main() {
	int n;
	string s;
	cin >> n >> s;
	for (auto c : s)
		if (c == 'R') n -= 2;
	cout << (n < 0 ? "Yes" : "No") << endl;
	return 0;
}


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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

/*[DSU TEMPLATE] int dsu[501], ranks[501];

void resetDSU(){
    for(int i = 0; i < 501; ++i){
        dsu[i] = i; ranks[i] = 0;
    }
}
int find(int node){
    if(dsu[node] == node) return node;
    return dsu[node] = find(dsu[node]);
}
void combine(int a, int b){
    a = find(a); b = find(b);
    if(ranks[a] < ranks[b]){ dsu[a] = b; }
    else if(ranks[a] > ranks[b]){ dsu[b] = a; }
    else { dsu[a] = b; ranks[b]++; }
}*/

int counter[100002];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int x, y;
    cin >> x >> y;

    long long moves = 0;

    if(x < 0 && y > 0){
        moves += 1 + max(0, -x - y);
        x = min(-x, y);
    }

    if(y < x){
        if(x >= 0){
            if(y > 0){
                moves += 2 + abs(y - x);
            } else {
                moves += 1 + abs(y + x);
            }
        } else {
            moves += 2 + abs(-y - -x);
        }
    } else if(x < y){
        moves += y - x;
    }

    cout << moves;

    return 0;
}


Measured memory_bytes: 256
inputs = readlines
# inputs = "3\n500 300 200\n".split("\n")

n = inputs[0].to_i
vn = inputs[1].split(' ').map(&:to_i)

def solve(n, vn)
  vn.sort!
  sum = vn[0]
  (1..(n - 1)).each do |i|
    sum += vn[i]
    sum = sum / 2.0
  end
  sum
end

puts solve(n, vn)


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

void solve(std::string s){
    cout << s[0] << s.size() - 2 << s[s.size() - 1] << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::string s;
    std::cin >> s;
    solve(s);
    return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: C: Sequence
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

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

  ll pd = 0, md = 0, psum = 0, msum = 0;
  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);

    swap(pd, md);
    swap(psum, msum);
    psum += ai, msum += ai;
    if (psum <= 0) pd += 1 - psum, psum = 1;
    if (msum >= 0) md += 1 + msum, msum = -1;
    //printf("%d:%d p=%lld,%lld, m=%lld,%lld\n", i, ai, pd, psum, md, msum);
  }

  printf("%lld\n", min(pd, md));
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var ab = IO.RSInt;
            WriteLine(ab[0] * ab[1]);
        }

        public class IO
        {
            #region Input
            public static int RInt => int.Parse(ReadLine());
            public static long RLong => long.Parse(ReadLine());
            public static double RDouble => double.Parse(ReadLine());

            public static string[] RSString => ReadLine().Split();
            public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
            public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
            #endregion

            #region Output
            public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
            public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
            public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
            #endregion
        }

        public class Mod
        {
            #region
            private readonly static long M = 1000000007;

            public static long Add(long a, long b) => (a * b) % M;
            public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
            public static long Multi(long a, long b) => (a * b) % M;
            #endregion
        }
    }
}

Measured memory_bytes: 28240
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

int ans=0;
const int maxn=10;
int n,a;
vector<int> As(10),Bs(10);
void dfs(int d){

    if(d==n){
        int sum=Bs[0];


        FOR(i,1,n){
            //cerr<<Bs[i]<<" ";
            sum*=Bs[i];
        }
        //cerr<<endl;
        if(sum%2==0){ans++;}
        return;
    }

    for(int i=-1;i<=1;i++){
        Bs[d]=As[d]+i;
        dfs(d+1);

    }

}


int main(){
   
    cin>>n;

    REP(i,n){
        cin>>As[i];
    }
    

    dfs(0);

    cout<<ans<<endl;






}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> S(h);
	rep(i, h) cin >> S[i];
	int ans = inf;
	for (int bit = 0; bit < (1 << h - 1); ++bit) {
		int cnt_h = 0;
		rep(i, h - 1) if (bit & (1 << i)) cnt_h++;
		vector<int> sum(cnt_h + 1, 0);
		int cnt_w = 0;
		bool elf = true;
		rep(i, w) {
			int now = 0;
			vector<int> tmp(cnt_h + 1, 0);
			rep(j, h) {
				if (S[j][i] == '1') tmp[now]++;
				if (bit & (1 << j)) now++;
			}
			rep(j, cnt_h + 1) {
				if (tmp[j] > k) elf = false;
				if (sum[j] + tmp[j] > k) {
					cnt_w++;
					rep(k, cnt_h + 1) {
						sum[k] = tmp[k];
					}
					break;
				}
				else {
					sum[j] += tmp[j];
				}
			}
		}
		if (elf) ans = min(ans, cnt_h + cnt_w);
	}
	dunk(ans);
	return 0;
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(s,x) memset(s,x,sizeof(s))
#define pb push_back
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;

const double PI = acos(-1.0);
const double eps = 1e-8;
const ll MOD = 1e9+7;
const int MAXN = 1e5+5;

int main()
{
    int n, r;
    cin >> n >> r;
    int ans = r;
    if (n < 10)
        ans += 100 * (10 - n);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,a[1000005]; 
int main(){
	in(n);
	for(int i=1;i<=n;i++)in(a[i]);
	sort(a+1,a+1+n);
	if(a[n/2]==a[n/2+1])puts("0");
	else printf("%d\n",a[n/2+1]-a[n/2]);
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int n, k;
	cin >> n >> k;
	int a[n];
	for(int i = 0; i < n; i++)
		cin >> a[i];
	vector<double> v;
	for(int i = 0; i < n; i++){
		v.push_back(1.0*(a[i]+1)/2.0);
	}
	double ans = 0;
	for(int i = 0; i < k; i++)
		ans += v[i];
	double temp = ans;
	for(int i = k; i < n; i++){
		temp += v[i];
		temp -= v[i-k];
		ans = max(ans,	temp);
	}
	cout << fixed << setprecision(15) << ans << endl;
	
	return 0;
}



Measured memory_bytes: 3956
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
-- end of templete

bitCount :: Int -> Int
bitCount n = c4 .&. 0x0000ffff + (shiftR c4 16) .&. 0x0000ffff
  where
    c1 = n .&. 0x55555555 + (shiftR n 1) .&. 0x55555555
    c2 = c1 .&. 0x33333333 + (shiftR c1 2) .&. 0x33333333
    c3 = c2 .&. 0x0f0f0f0f + (shiftR c2 4) .&. 0x0f0f0f0f
    c4 = c3 .&. 0x00ff00ff + (shiftR c3 8) .&. 0x00ff00ff

b2i s = b2i' 0 s
  where
    b2i' r [] = r
    b2i' r ('0':ss) = b2i' (2*r) ss
    b2i' r ('1':ss) = b2i' (2*r+1) ss

main = do
    n <- getInt
    fs <- map (b2i . filter (/=' ')) <$> replicateM n getLine
    ps <- replicateM n getInts
    print $ maximum $ flip map [1..1023] $ (\i -> sum $ zipWith (\p c -> p!!c) ps $ map (bitCount . (.&.i)) fs)

Measured memory_bytes: 1660
# -*- coding: utf-8 -*-
d = set()
s = list(input())
n = len(s)
for c in s:
    d.add(c)

res = 10**5
for c in d:
    cnt = 0
    ss = list(s)
    nn = n
    # print(ss,nn,c)
    while True:
        if len(set(ss))==1:
            break
        cnt += 1
        for i in range(nn-1):
            if ss[i+1]==c:
                ss[i] = c
        ss.pop()
        nn -= 1
    res = min(res, cnt)
print(res)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <cstring>
#include <unordered_set>
#include <unordered_map>

using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const ll MOD = 998244353;
 
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};


int main(){

    int n, c;
    cin >> n >> c;

    int d[50][50];
    REP(i, c) REP(j, c) cin >> d[i][j];

    int color[510][510];
    REP(i, n) REP(j, n) cin >> color[i + 1][j + 1];

    int s[3][40];

    REP(i, 3) REP(j, 40) s[i][j] = 0;

    FOR(i, 1, n + 1) FOR(j, 1, n + 1){
        s[(i + j) % 3][color[i][j] - 1]++;
    }

    int sans[3][40];

    REP(k, 3){
        REP(i, c){
            sans[k][i] = 0;
            REP(j, c){
                sans[k][i] += d[j][i] * s[k][j];
            }
        }
    }
   
    vector<P> v;
    REP(i, c){
        v.push_back(P(sans[2][i], i));
    }
    SORT(v);

    int ans = INF;

    REP(i, c) REP(j, c){
        if(i == j) continue;
        P tmp;
        if(v[0].second == i || v[0].second == j){
            if(v[1].second == i || v[1].second == j){
                tmp = v[2];
            }else{
                tmp = v[1];
            }
        }else{
            tmp = v[0];
        }

        if(ans > tmp.first + sans[0][i] + sans[1][j]){
            ans = tmp.first + sans[0][i] + sans[1][j];
        }
    }

    cout << ans << endl;

}

// 1 1 1 1 2 3 4
// 0 -1 -2 -3 -4 -4 -4

Measured memory_bytes: 1280
#include "bits/stdc++.h"
using namespace std;
static const int MAX = 100;
int mod[MAX+1];

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    bool can = false;
    int n = a;
    while (true) {
        int m = n % b;
        if (m == c) {
            can = true;
            break;
        }
        if (mod[m]) break;
        mod[m] = 1;
        n += a;
    }
    
    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}


Measured memory_bytes: 256
/*
AizuOnline A0225
Title
@kankichi573
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int n;
int dir[26];     // in +1 out -1
int alpha[26];   // tunagatte iruka
char buf[33];
char con[26][26];  //char a->b connection
char con_flag[26]; 
//
int count_char()
{
        int i,cnt=0;

        for(i=0;i<26;i++)
        {
                if (alpha[i])
                {
                        cnt ++;
                        //printf("CH %c\n",'a'+i);
                }
        }
        return(cnt);
}
int find_first()
{
        int i,cnt=0;

        for(i=0;i<26;i++)
                if(alpha[i]>0)
                        return(i);
        return(-1);
}

int connected()
{
        int from;

        from=find_first();
        //printf("FF=%c\n",'a'+from);
        con_flag[from]=1;
        return(connected2(from));
}
int connected2(int node)
{
        int i;
        int cnt=1;
        //printf("CN2=%c\n",'a'+node);

        for(i=0;i<26;i++)
        {
                if(i==node)
                        continue;
                if(con[node][i] && !con_flag[i])
                {
                        //printf("CN2_2=%c\n",'a'+i);

                        con_flag[i]++;
                        cnt += connected2(i);
                }
        }
        return(cnt);
}
main()
{
        int i,j;
        int stt,end,ret,ret1;
        while(EOF!=scanf("%d",&n) && n)
        {
                for(i=0;i<26;i++)
                {
                        alpha[i]=0;
                        dir[i]=0;
                        con_flag[i]=0;
                        for(j=0;j<26;j++)
                                con[i][j]=0;
                }
                for(i=0;i<n;i++)
                {
                        scanf("%s",buf);
                        stt=buf[0]-'a';
                        end=buf[strlen(buf)-1]-'a';
                        dir[stt]++;
                        dir[end]--;
                        alpha[stt]=alpha[end]=1;
                        con[stt][end]=1;
                }

                ret=connected();   // saisho ni toujou suru
                                   //node to tunagatte iru suu
                ret1=count_char(); // node no kazu
#ifdef DEBUG
                printf("r=%d %d\n",ret,ret1);
#endif
                if(ret != ret1)   // subeteno node ga tunagaruka
                {
                        printf("NG\n");
                        continue;
                }

                for(i=0;i<26;i++) //zenbu guuten ka siraberu
                        if(dir[i])
                        {
                                printf("NG\n");
                                goto NEXT;
                        }
                printf("OK\n");
        NEXT:
                ;
        }
return(0);
}

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

using namespace std;

int main(void){
    string n;
    cin >> n;
    for(int i = 0;i<n.size();i++){
        if(n[i]=='9')n[i]='1';
        else n[i]='9';
    }
    cout<<n<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int sum = 0;
		String temp= "";
		while(sc.hasNextLine()){
			String str = sc.nextLine();
			for(int i=0; i < str.length(); i++){
				int num = str.charAt(i) - '0';
				if(num >= 0 && num <= 9){
					temp +=num;
					while(i+1 < str.length()){
						i++;
						num = str.charAt(i) - '0';
						if(num >= 0 && num <= 9){
							temp += num;
						}
						else{
							break;
						}
					}
					sum += Integer.parseInt(temp);
					temp = "";
				}

			}
		}
		System.out.println(sum);
	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();

	}

}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        
        for (int i = 0; i < n; i++) {
            double x1 = scanner.nextDouble();
            double y1 = scanner.nextDouble();
            double x2 = scanner.nextDouble();
            double y2 = scanner.nextDouble();
            double x3 = scanner.nextDouble();
            double y3 = scanner.nextDouble();
            
            double a1 = 2*(x2-x1);
            double b1 = 2*(y2-y1);
            double c1 = x1*x1 - x2*x2 + y1*y1 - y2*y2;
            double a2 = 2*(x3-x1);
            double b2 = 2*(y3-y1);
            double c2 = x1*x1 - x3*x3 + y1*y1 - y3*y3;
            
            double px = (b1*c2 - b2*c1) / (a1*b2 - a2*b1);
            double py = (c1*a2 - c2*a1) / (a1*b2 - a2*b1);
            double r = Math.sqrt((px-x1)*(px-x1) + (py-y1)*(py-y1));
            
            System.out.printf("%.3f %.3f %.3f\n", px, py, r);
        }
    }
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z -> key < x->key){
      x = x->left;
    } 
    else {
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }

  else if(z->key < y->key){
      y->left = z;
    }
  else y->right = z;
	
  }






void inorder(Node u) {  
  if(u != NIL){
    if(u->left != NIL){
      inorder(u->left);
      }
    printf(" %d",u->key);
      
    if(u->right != NIL){
      inorder(u->right);
      }
  }
}

void preorder(Node u){
  printf(" %d",u->key);
  if(u != NIL){
    if(u->left != NIL)preorder(u->left);
    if(u->right != NIL)preorder(u->right);
  }
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com); 
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }}
    return 0;
  }

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

using namespace std;
using ll = long long;

ll cost(ll x, ll y) {
    return (x - y) * (x - y);
}

int main() {
    int n; scanf("%d", &n);
    ll a[n];
    for (int i = 0; i < n; i++) {
        scanf("%lld", &a[i]);
    }

    ll ans = 2e9;
    for (ll y = -100; y <= 100; y++) {
        ll temp = 0;
        for (int i = 0; i < n; i++) {
            temp += cost(a[i], y);
        }

        ans = min(ans, temp);
    }

    printf("%lld\n", ans);
}

Measured memory_bytes: 3732
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"("<<(x).FI<<", "<<(x).SE<<")"<<endl;
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  double T, X;
  cin >> T >> X;
  printf("%f\n", T / X);
  return 0;
}



Measured memory_bytes: 256
import sys

X, Y = map(int, input().split())
N_list = list(map(int,input().split()))
N_answer = []

if len(N_list) == 0:
    print(X)
    sys.exit()
for i in range(100):
    if (X + i) not in N_list:
        N_answer.append(X + i)
    if (X - i) not in N_list:
        N_answer.append(X - i)
    
    if len(N_answer) > 0:
        break

print(min(N_answer))

Measured memory_bytes: 9196
#include <stdio.h>

int sum(char x[]){
	int i,sum=0;

	for(i = 0;x[i]!='\0';i++){
		sum+=x[i] - 48;
	}
	return sum;
}

int main(void){
	int i;
	char a[1001];
	while(1){
		scanf("%s",&a);
		if(sum(a) == 0) break;
		
		printf("%d\n",sum(a));
	}

	return 0;
		
}

Measured memory_bytes: 536
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;
#define FIN freopen("in.txt", "r", stdin);
const int mod = 1e9 + 7;
int cnt[100005];
ll poww(ll a, ll b)
{
    ll ans = 1, base = a;
    while(b)
    {
        if(b & 1)
        {
            ans = ans * base % mod;
        }
        base = base * base % mod;
        b >>= 1;
    }
    return ans % mod;
}
int main()
{
    //FIN;
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int num;
        cin >> num;
        cnt[num]++;
    }
    int ans = -1;
    if(n % 2)
    {
        if(cnt[0] != 1)
        {
            cout << 0 << endl;
            return 0;
        }
        else
        {
            for(int i = 1; i < n; i++)
            {
                if(i % 2 && cnt[i])
                {
                   cout << 0 << endl;
            return 0;
                }
                if(i % 2 == 0 && cnt[i] != 2)
                {
                    cout << 0 << endl;
            return 0;
                }
            }
        }
        
    }
    else
    {
        for(int i = 0; i < n; i++)
        {
            if(i % 2 && cnt[i] != 2)
            {
               cout << 0 << endl;
            return 0;
            }
            if(i % 2 == 0 && cnt[i])
            {
               cout << 0 << endl;
            return 0;
            }
        }
    }
    
    ans = poww(2, n / 2);
        cout << ans << endl;
    return 0;
    
    
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>

using namespace std;

int main(void){
  int a,b,c;
  cin>>a>>b>>c;
  //cout <<a<<b<<c<<endl;

  //cout << a+b+b
  //cout << min(a+b,c)+b << endl;
  if(a+b>=c) cout << b+c << endl;
  else{
    cout << a+2*b+1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#create date: 2020-05-02 21:13

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    x = ni()
    now = 100
    cnt = 0
    while x > now:
        now *= 1.01
        now = int(now)
        #print(now)
        cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9128
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	long x = sc.nextLong();
	long k = sc.nextLong();
	long d = sc.nextLong();
	long X = Math.abs(x);
	if (X/d >= k) {
	    System.out.print(X - k*d);
	} else {
	    long near = X/d;
	    if ((k-near)%2==0) {
		System.out.print(Math.abs(X-near*d)); 
	    } else {
	        System.out.print(Math.abs(X-near*d - d));
	    }
	}
    }
}


Measured memory_bytes: 35896
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define for1(i,n) for(int i=1;i<=(int)(n);i++)
#define debug(x) cout << '>' << #x << ':' << x << endl;
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){  a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N=1e6+3;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n;
      cin>>n;
      int a[n+1];
      for(int i=1;i<=n;i++) cin>>a[i];
      int s=0;
      for(int i=n;i>=1;i--)
      {
            if(i&1) s+=a[i];
            else s-=a[i];
      }
      int ans[n+1];
      ans[1]=s;
      for(int i=2;i<=n;i++)
      {
            ans[i]=2*a[i-1]-ans[i-1];
      }
      for(int i=1;i<=n;i++) cout<<ans[i]<<" ";
}     
// I never lose. I either win or I learn

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

ll a,b;

int main() {
  cin >> a >> b;
  cout << a*b/__gcd(a,b) << endl;  
}

Measured memory_bytes: 256