akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<algorithm>
using namespace std;
int row[16][16];
int col[16][16];
int dp[16][16];
int main(){
	int a;
	scanf("%d",&a);
	while(a--){
		int b,c;
		scanf("%d%d",&b,&c);
		int d;scanf("%d",&d);
		for(int i=0;i<16;i++)
			for(int j=0;j<16;j++)
				row[i][j]=col[i][j]=dp[i][j]=0;
		for(int i=0;i<d;i++){
			int p,q,r,s;
			scanf("%d%d%d%d",&p,&q,&r,&s);
			if(p>r)swap(p,r);
			if(q>s)swap(q,s);
			if(p==r){
				for(int j=q;j<s;j++)col[p][j]=1;
			}else{
				for(int j=p;j<r;j++)row[j][s]=1;
			}
		}
		dp[0][0]=1;
		for(int i=0;i<=b;i++){
			for(int j=0;j<=c;j++){
				if(i<b&&!row[i][j])dp[i+1][j]+=dp[i][j];
				if(j<c&&!col[i][j])dp[i][j+1]+=dp[i][j];
			}
		}if(dp[b][c]==0)printf("Miserable Hokusai!\n");
		else printf("%d\n",dp[b][c]);
	}
}

Measured memory_bytes: 0
#include<stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
int main() {
    long long n, a, m, p, o, max,min, sum[222222],  flag,i,d1,d2;
    long long ans=200000000000000;
    scanf("%lld", &n);
    for (i = 0; i < n; i++) {
        scanf("%lld", &a);
        if (i == 0)
            sum[0] = a;
        else
            sum[i] = sum[i - 1] + a;
    }
    m = 0;
    p = 2;
    for (o = 1; o < n - 1; o++) {
        flag = 0;
        while (flag == 0) {
            d1 = sum[o]-sum[m] * 2  ;
            if (d1 < 0)
                d1 = -d1;
            d2 = sum[o]- sum[m + 1] * 2;
            if (d2 < 0)
                d2 = -d2;
            if (d1 > d2)
                m++;
            else
                flag = 1;
        }
        flag = 0;
        while (flag == 0) {
            d1 = (sum[p] - sum[o])*2-(sum[n-1]-sum[o]);
            if (d1 < 0)
                d1 = -d1;
            d2 = (sum[p+1]-sum[o])*2-(sum[n-1]-sum[o]);
            if (d2 < 0)
                d2 = -d2;
            if (d1 > d2)
                p++;
            else
                flag = 1;
        }
        max = sum[m];
        min = sum[m];
        if (sum[o] - sum[m] > max)
            max = sum[o] - sum[m];
        if (sum[o] - sum[m] <min)
            min = sum[o] - sum[m];
        if (sum[p] - sum[o] > max)
            max = sum[p] - sum[o];
        if (sum[p] - sum[o] <min)
            min = sum[p] - sum[o];
        if (sum[n-1] - sum[p] > max)
            max = sum[n-1] - sum[p];
        if (sum[n-1] - sum[p] <min)
            min = sum[n-1] - sum[p];
        if (ans > max - min)
            ans = max - min;
    }
    printf("%lld\n", ans);
    return 0;
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	ll n;
	cin >> n;
	double ans = 0;
	ll num = (n + 1) / 2;
	ans = 1.*num / (1.*n);
	cout <<setprecision(15);
	cout << ans << endl;
}


Measured memory_bytes: 3752
import math
while True:
    m,f,r = map(int,input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print('F')
    elif m + f >= 80:
        print('A')
    elif m + f >= 65 and m + f < 80:
        print('B')
    elif m + f >= 50 and m + f < 65:
        print('C')
    elif m + f >= 30 and m + f < 50:
        if r >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')


Measured memory_bytes: 5652
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

#include <boost/multiprecision/cpp_int.hpp>
namespace boost_multiprecision = boost::multiprecision;
#define lll boost_multiprecision::cpp_int

lll popcount(lll x){
    lll ret = 0;
    while(x > 0){
        ret += (x&1);
        x /= 2;
    }
    return ret;
}

int N;
string S;
lll X = 0;

signed main(){
    cin >> N >> S;

    int cnt = 0;
    rep(i, S.size()){
        X = X*2 + (S[i]-'0');
        if(S[i] == '1') cnt++;
    }

    lll tmp0 = X % (cnt+1);
    lll tmp1 = 0;
    if(cnt-1 > 0) tmp1 = X % (cnt-1);
    
    ll t0 = 1;
    ll t1 = 1;
    vector<int> v(N);
    for(int i=S.size()-1; i>=0; i--){
        if(S[i] == '0'){
            lll tmp = (tmp0 + t0) % (cnt+1);
            int ans = 1;
            while(tmp > 0){
                tmp %= popcount(tmp);
                ans++;
            }
            v[i] = ans;
        }
        else{
            if(cnt == 1) v[i] = 0;
            else{
                lll tmp = (tmp1 - t1 + cnt-1) % (cnt-1);
                int ans = 1;
                while(tmp > 0){
                    tmp %= popcount(tmp);
                    ans++;
                }
                v[i] = ans;
            }
        }
        t0 = (t0 * 2) % (cnt+1);
        if(cnt-1 > 0) t1 = (t1 * 2) % (cnt-1);
    }

    rep(i, N) cout << v[i] << endl;
}

Measured memory_bytes: 4548
//Name: Spiral Pattern
//Level: 2
//Category: シミュレーション
//Note: 

/**
 * n×nの領域を用意して、左下隅から渦巻きをたどるようにして埋めていく。
 * 現在の進行方向について、壁にぶつかるときか、もう1歩進むと他の線に干渉するというときには右に曲がる。
 */
#include <iostream>
#include <vector>
#include <string>

using namespace std;

// ostream support for vector.
template<typename T>
ostream& operator <<(ostream &os, const vector<T> &v) {
    for(const T &t : v) {
        os << t << endl;
    }
    return os;
}

template<typename T>
struct Pair {
    T a, b;

    Pair() : a(T()), b(T()) {}
    Pair(const T &a, const T &b) : a(a), b(b) {}

    Pair& operator += (const Pair &p) {
        a += p.a;
        b += p.b;
        return *this;
    }

    friend Pair operator +(Pair p1, const Pair &p2) {
        p1 += p2;
        return p1;
    }

    friend ostream& operator <<(ostream &os, const Pair &p) {
        return os << "(" << p.a << ", " << p.b << ")";
    }

    /* vector accessor mixin {{{*/
    template<typename U>
    auto of(U &u) const -> decltype(u[a][b]) {
        return u[a][b];
    }

    template<typename U>
    bool valid_in(const U &u) const {
        return a < u.size() && b < u[0].size();
    }
    /*}}}*/
};

static const Pair<int> DELTA[4] = {
    Pair<int>(-1, 0), Pair<int>(0, -1), Pair<int>(1, 0), Pair<int>(0, 1)
};

bool solve(bool first) {
    if(!first) cout << endl;
    int N;
    cin >> N;

    vector<string> f(N, string(N, ' '));
    Pair<int> pos(N-1, 0);
    int dir = 1;
    bool stucked = false;
    while(true) {
        pos.of(f) = '#';
        auto next = pos + DELTA[dir];
        auto nn = next + DELTA[dir];
        auto nl = next + DELTA[(dir+3)%4];
        if(nl.valid_in(f) && nl.of(f) == '#') {
            break;
        }
        if(!next.valid_in(f) || (nn.valid_in(f) && nn.of(f) == '#')) {
            if(stucked) break;
            dir = (dir + 3) % 4;
            stucked = true;
        } else {
            stucked = false;
            pos = next;
        }
    }
    cout << f;
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(2);

    bool first = true;
    int N;
    cin >> N;
    while(N-- && solve(first)) {
        first = false;
    }
    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    cin >> n;
    vector<ll> x(n), y(n);
    REP(i, n) cin >> x[i] >> y[i];

    double dist = 0;
    vector<ll> ord(n);
    iota(ALL(ord), 0);
    do {
        FOR(i, 1, n) {
            ll pre = ord[i-1], cur = ord[i];
            dist += hypot(x[pre]-x[cur], y[pre]-y[cur]);
        }
    } while(next_permutation(ALL(ord)));

    ll frac = 1;
    REP(i, n) frac *= i+1;
    dist /= frac;
    cout << fixed << setprecision(9) << dist << endl;

    return 0;
}

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

int variation(vector<string> s)
{
    sort(s[0].begin(), s[0].end());
    sort(s[1].begin(), s[1].end());
    for(int k = 0; k < 2; ++k)
    {
        char tmp = '-';
        string nondup;
        for(int i = 0; i < s[k].size(); ++i)
        {
            if(tmp != s[k][i])
            {
                nondup.push_back(s[k][i]);
                tmp = s[k][i];
            }
        }
        s[k] = nondup;
    }
    int r = 0;
    for(int i = 0; i < s[0].size(); ++i)
    {
        for(int k = 0; k < s[1].size(); ++k)
        {
            if(s[0][i] == s[1][k]) ++r;
        }
    }

    return r;
}

int main()
{
    int n;
    string s;
    cin >> n >> s;
    
    int ans = 0;
    for(int i = 1; i < n; ++i)
    {
        vector<string> xy = {s.substr(0,i), s.substr(i)};
        ans = max(ans, variation(xy));
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n,cnt[8] = {},mx,mn,c = 0,cnt2 = 0;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    for(int i = 0;i < n;i++){
      for(int j = 0;j <= 7;j++){
        if(a[i] >=400*j & a[i] < 400*(j+1)){
            cnt[j]++;
            cnt2++;
        }
      }
    }
    for(int i = 0;i <= 7;i++){
        if(cnt[i] != 0){
            c++;
        }
    }
    mx = c + (n-cnt2);
    if(c >= 1){
        mn = c;
    }else{
        mn = 1;
    }
    cout << mn << " " << mx << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n,k;
ll c[2010][2010];
int main(){
	cin>>n>>k;
	REP(i,2010){
		c[i][0]=1;
		c[i][i]=1;
	}
	for(int i=1;i<2010;i++){
		for(int j=1;j<i;j++){
			c[i][j]=c[i-1][j-1]+c[i-1][j];
			c[i][j]%=MOD;
		}
	}
	
	for(int i=1;i<=k;i++){
		cout<<(c[n-k+1][i]*c[k-1][i-1])%MOD<<endl;
	}
	return 0;
}

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

int main() {
	int a, b, k;
	cin >> a >> b >> k;

	for (int i = a; i <= min(b, a + k - 1); i++) cout << i << endl;
	for (int i = max(b - k + 1, a + k); i <= b; i++) cout << i << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

int main()
{
	int n,m;scanf("%d%d",&n,&m);
	if (n>m) swap(n,m);
	if (n==1&&m==1) puts("1");
	else if (n==1) printf("%d",m-2);
	else printf("%lld",(LL)(n-2)*(m-2));
	return 0;
}

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

signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N)cin>>A[i];
  vector<int> AS=A;
  sort(begin(AS),end(AS));
  int tmax=AS[N-1],smax=AS[N-2];
  rep(i,N){
    if(A[i]==AS[N-1]){
      cout<<AS[N-2]<<endl;
    }else{
      cout<<AS[N-1]<<endl;
    }
  }
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
#define N 300005
#define mod 998244353
#define ll long long
using namespace std;
ll fac[N],inv[N],k,f[N];
int n,a,b;
ll calc(int n,int m)
{
	if(m>n||m<0)return 0;
	return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main()
{
	fac[0]=inv[0]=inv[1]=1;
	for(int i=1;i<=N;i++)fac[i]=1ll*fac[i-1]*i%mod;
	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-1]*inv[i]%mod;
	scanf("%d%d%d%lld",&n,&a,&b,&k);
	if(k==0){puts("1");return 0;}
	ll ans=0;
	for(int i=0;i<=n;i++)
		if((k-a*i)%b==0&&(k-a*i>=0))
		{
			int t=(k-a*i)/b;
			f[i]=(calc(n,i)*calc(n,t))%mod;
			ans=(ans+f[i])%mod;
		}
	printf("%lld\n",ans);
	return 0;
}

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

int n, x, y, ans;

inline int xabs(register int o) {
	return o < 0 ? -o : o;
}

int gcd(register int a, register int b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
	scanf("%d%d%d", &n, &x, &y); --n; ans = xabs(x - y);
	while (n--) {
		scanf("%d", &y); y = xabs(x - y);
		ans = gcd(ans, y);
	}
	printf("%d\n", ans);
	return 0;
}

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

int small[3][3] = {0, 1, 0,
		   1, 1, 1,
		   0, 1, 0};
int normal[3][3] = {1, 1, 1,
		    1, 1, 1,
		    1, 1, 1};
int big[5][5] = {0, 0, 1, 0, 0,
		 0, 1, 1, 1, 0,
		 1, 1, 1, 1, 1,
		 0, 1, 1, 1, 0,
		 0, 0, 1, 0, 0};

int map[10][10];
int x, y, size;
int white = 0;
int black = 0;

int main(){
	while(scanf("%d,%d,%d", &x, &y, &size) != EOF){
		switch(size){
			case 1:
				for(int i = 0; i < 3; i++){
					for(int j = 0; j < 3; j++){
						if(0 <= x-1+i && x-1+i < 10 && 0 <= y-1+j && y-1+j < 10)
							map[x-1+i][y-1+j] += small[i][j];
					}
				}
				break;
			case 2:
				for(int i =0; i < 3; i++){
					for(int j=0; j < 3; j++){
						if(0 <= x-1+i && x-1+i < 10 && 0 <= y-1+j && y-1+j < 10)
							map[x-1+i][y-1+j] += normal[i][j];
					}
				}
				break;
			case 3:
				for(int i=0; i < 5; i++){
					for(int j=0; j < 5; j++){
						if(0 <= x-2+i && x-2+i < 10 && 0 <= y-2+j && y-2+j < 10)
							map[x-2+i][y-2+j] += big[i][j];
					}
				}
				break;
		}
	}
	for(int i=0; i < 10; i++){
		for(int j=0; j < 10; j++){
			if(map[i][j] == 0) white++;
			black = max(black, map[i][j]);
		}
	}

	cout << white << endl;
	cout << black << endl;

}

Measured memory_bytes: 1208
# coding: utf-8

start_col = ["0", "1"]

s = input().rstrip()


def get_next(prev: str):
    if prev == "0":
        return "1"
    else:
        return "0"


ans = len(s)
for i in start_col:
    current = i
    cnt = 0
    for j in range(len(s)):
        if s[j] != current:
            cnt += 1
        current = get_next(current)
    ans = min(ans, cnt)

print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime> 
#define full(a) a.begin(), a.end()

#define sz(x) ((int)(x).size())
#define lli long long int
using namespace std;

int inp() {
    int n; cin >> n;
    return n;
}

void prntv(vector<int> vec) {
    for (auto i : vec)cout << i << " ";
    cout << endl;
}
void solve() {
    string t; cin >> t;
    int count = 0;
    int mx = 0;
    for(int i = 0; i < 3; i++){
        if (t[i] == 'R') {
            count++;
        }
        else {
            mx = max(mx, count);
            count = 0;
        }
    }

    mx = max(mx, count);
    count = 0;
    cout << mx << endl;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    //int n; cin >> n;
    //while(n--)
        solve();

    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, m;
string str;

int main(){
	cin >> n >> m;
	if(n < m){cout << 0 << endl;}
	else{cout << 10 << endl;}
	return 0;
}

Measured memory_bytes: 256
K = int(input())
A, B = map(int, input().split())


def calculate(k, a, b):
    result = False
    for i in range(a, b + 1):
        if i % k == 0:
            result = True
            break

    if result == True:
        print("OK")
    else:
        print("NG")


calculate(K, A, B)


Measured memory_bytes: 9116
// AGC029 B
#include <iostream>
#include <set>

using namespace std;

signed main() {
    int N;
    cin >> N;
    multiset<int> A;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        A.insert(a);
    }

    int ret = 0;
    while (!A.empty()) {
        auto it = A.end();
        it--;
        int val = *it;
        A.erase(it);

        int tmp = 1;
        while (tmp <= val) tmp *= 2;

        it = A.find(tmp - val);
        if (it != A.end()) {
            A.erase(it);
            ++ret;
        }
    }

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

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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

class task {
public:
	ll a;
	ll b;
	task() : a(0), b(0) {}
	task(ll a_, ll b_) : a(a_), b(b_) {}
};

bool tcmp(const task &l, const task &r) {
	if(l.b < r.b) {
		return true;
	} else if(l.b == r.b) {
		return l.a < r.a;
	} else {
		return false;
	}
}

int main(int argc, const char* argv[]) {
	ll n;
	cin >> n;
	vector<task> v(n);
	rep(i, n) {
		cin >> v[i].a >> v[i].b;
	}
	sort(v.begin(), v.end(), tcmp);

	ll t = 0;
	bool ret = true;
	rep(i, n) {
		t += v[i].a;
		if(v[i].b < t) {
			ret = false;;
			break;
		}
	}

	YesNo(ret);

	return 0;
}


Measured memory_bytes: 3328
#pragma GCC optimize ("O3")
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <bitset>
#include <cstdio>

using namespace std;
using namespace std::placeholders;

// namespace { struct NoSync { NoSync() { cin.tie(0); ios::sync_with_stdio(false); } } nosync; }

using ll = long long;
#define float double

constexpr ll INF = 999999999;
constexpr ll MOD = 1e9 + 7;

#define y0 Y0
#define y1 Y1
#define j0 J0
#define j1 J1
#define prev PREV
#define next NEXT

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i##_len = (n), i = (i##_len) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define permutations(v) sort(all(v));for(bool v##p = true; v##p; v##p=next_permutation(all(v)))
#define UNIQUE(v) (v).erase(unique(all(v)), (v).end())
#define REMOVE(v) (v).erase(remove(all(v)), (v).end())
#define ROTATE(v, n) rotate((v).begin(), (v).begin() + (n), (v).end())
#define TO_SUMS(v) partial_sum(all(v), (v).begin())
#define SUMS(srcv, dstv) partial_sum(all(srcv), (dstv).begin())
#define nth_bit(n) (1LL<<(n))

template <typename T> T high()  { return numeric_limits<T>::max(); }
template <typename T> T high(T) { return numeric_limits<T>::max(); }
template <typename T> T low()   { return numeric_limits<T>::lowest(); }
template <typename T> T low(T)  { return numeric_limits<T>::lowest(); }

template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }

// f には functional のオブジェクトが便利 (lambda 式も   [](int a){ return a / 2 }   みたいな)
template<class C, class F> inline C mapped(const C& c, F f){// mapっていうSTLがあるから...
    // ex: mapped(v, bind(plus<ll>(), _1, 2))   [v の各要素について x + 2]
    C r; r.reserve(c.size()); transform(all(c), back_inserter(r), f); return r;
}
template<class C, class F> inline C filtered(const C& c, F f){
    // ex: filtered(v, bind(equal_to<ll>(), bind(modulus<ll>(), _1, 2), 0)   [x mod 2 == 0 な x を取ってくる]
    C r; copy_if(all(c), back_inserter(r), f); return r;
}
template<class C, class I, class F> inline typename C::value_type foldl(const C& c, I i, F f){
    // ex: foldl(v, 1, multiplies<int>())   [v の総乗]
    return accumulate(all(c), static_cast<typename C::value_type>(i), f);
}


int main(){
    ll a, b;
    cin >> a >> b;

    cout << a * b << " " << 2 * (a + b) << endl;

    return 0;
}



Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(){
    string s;
    cin >> s;
    map<int,int> freq;
    for(int i = 0; i < s.size(); i++){
        freq[s[i]-'a']++;
    }
    map<int,int> last;
    int ok = 1;
    for(int j = 0; j < 26; j++){
        last[j] = -10000;
    }
    for(int i = 0; i < s.size(); i++){
        int best = -1;
        for(int j = 0; j < 26; j++){
            if(last[j] >= i-2) continue;
            if(freq[j] == 0) continue;
            if(best == -1 || freq[j] > freq[best]){
                best = j;
            }
        }
        if(best == -1){
            ok = 0;
            break;
        }
        freq[best]--;
        last[best] = i;
    }
    if(ok){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


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

int main() {
    int N;
    cin >> N;
    string ans = "No";
    for(int i = 0; i <= N; i++) {
        for(int j = 0; j <= N; j++) {
            if(N == 4*i + 7*j) {
                ans = "Yes";
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3560
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

vector<int> g[14];
double dp[1<<14];

int main() {
  int n,m,P;
  while(cin>>n>>m>>P) {
    REP(i,n) g[i].clear();
    REP(i,m) {
      int a, b;
      cin >> a >> b;
      a--;b--;
      g[a].push_back(b);
      g[b].push_back(a);
    }
    REP(S,1<<n) dp[S] = 1;
    REP(S,1<<n) {
      if (!(S&1)) continue;
      vector<int> v;
      REP(i,n) if (S>>i&1) v.push_back(i);
      REP(Q,1<<v.size()) {
        int T = 0;
        REP(i,v.size())
          if (Q>>i&1)
            T |= 1<<v[i];
        if (!(T&1)) continue;
        if (S==T) continue;
        double p = 1;
        REP(i,n) {
          if (T>>i&1) {
            FOR(it, g[i]) {
              if ((S^T)>>*it&1) {
                p = p*P/100;
              }
            }
          }
        }
        dp[S] -= dp[T] * p;
        // cout << bitset<4>(S) << " " << bitset<4>(T) << " " << p << endl;
      }
    }
    printf("%.10f\n", dp[(1<<n)-1]);
  }
}

Measured memory_bytes: 1360
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,N,ans=0;
  cin>>N;
  vec t(N+1,0),v(N);
  rep(i,N){
    cin>>t[i+1];
    t[i+1]<<=1;
    t[i+1]+=t[i];
  }
  rep(i,N){
    cin>>v[i];
    v[i]<<=1;
  }
  vec maxv(t[N]+1,0);
  rep(i,N){
    For(j,t[i],t[i+1]){
      maxv[j+1]=v[i];
    }
    if(i){
      maxv[t[i]]=min(v[i],v[i-1]);
    }
  }
  maxv[0]=0;
  rep1(j,t[N])chmin(maxv[j],maxv[j-1]+1);
  maxv[t[N]]=0;
  brep(j,t[N]){
    chmin(maxv[j],maxv[j+1]+1);
    ans+=maxv[j];
  }
  cout<<ans/4<<".";
  print(ans%4*25);
}

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



int main()
{
    int n;
    cin >> n;
    for (int i = 0; i <= 30; i++)
    {
        for (int j = 0; j <= 20;j++)
        {
            if(4*i+7*j==n)
            {
                cout << "Yes";
                
                return 0;
            }
        }
    }
    
    cout << "No";
    return 0;
}


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

typedef long long ll;

int main() {
    int A, B;
    cin >> A >> B;
    cout << (B - 1 + A - 2) / (A - 1) << "\n";
}

Measured memory_bytes: 256
N,K=map(int,input().split())
pr=998244353
ku=[list(map(int, input().split())) for i in range(K)]
l=[0]*(N)
l[0]=1
for i in range(1,N):
    t=0
    for j in ku:
        if i>=j[0]:
            if i>j[1]:
                t+=l[i-j[0]]-l[i-j[1]-1]
            else:
                t+=l[i-j[0]]
    l[i]=(l[i-1]+t)%pr
print((l[-1]-l[-2])%pr)


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

#define ll long long
using namespace std;
int n;
ll a[55], b[55];
ll tmp, ans;
bool ok;

int main() {
    //freopen("../in", "r", stdin);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) scanf("%lld", &a[i]);
    while (!ok) {
        ok = 1;
        tmp = 0;
        for (int i = 0; i < n; ++i) {
            b[i] = a[i] / n;
            tmp += b[i];
            a[i] -= b[i] * n;
        }
        for (int i = 0; i < n; ++i) {
            a[i] += tmp - b[i];
            if (a[i] >= n) ok = 0;
        }
        ans += tmp;
    }
    printf("%lld\n", ans);
    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++)
typedef long long ll;
using P = pair<ll,ll>;

signed main() {
	ll x, n;
	cin >> x >> n;
	vector<ll> a(102);
	rep(i, n){
		ll p; cin >> p;
		a[p] = 1;
	}
	P ans(99999, -1);
	for (int i = 0; i <= 101; i++) {
		if (a[i] == 1) continue;
		int dif = abs(x - i);
		ans = min(ans, P(dif, i));
	}
	cout << ans.second << endl;
}


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

int main() {
    int n;
    int a[200];
    int ans = 30;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        int count = 0;
        for (int j = 0; j < 30; j++) {
            if (a[i] % 2 == 0) {
                count++;
                a[i] /= 2;
            }
        }
        ans = min(count, ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<li, li> pt;

#define fi first
#define se second
#define lson ((p<<1))
#define rson ((p<<1)+1)
#define mid ((L+R)>>1)
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

ll const INF = 1e12;

ll n, m, a, b, x, mask, dp[5000];

int main() {
    fastIO;
    cin >> n >> m;
    for(li i = 1; i <= (1 << n); i ++) dp[i] = INF;
    dp[0] = 0;
    for(li i = 0; i < m; i ++) {
        cin >> a >> b;
        li mask = 0;
        for(li j = 0; j < b; j ++) {
            cin >> x;
            x--;
            mask += (1 << x);
        }

        for(li j = 0; j < (1 << n); j ++) {
            if(dp[j] == INF) continue;
            dp[j | mask] = min(dp[j | mask], dp[j] + a);
        }
    }

    if(dp[(1 << n) - 1] == INF) cout << "-1\n";
    else cout << dp[(1 << n) - 1];

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;

#define w(x)            int x;  cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fo(i,a,b)       for(int i = a; i < b; i++)
//int tc = 0;
//printf("Case #%d: %d\n",tc,);

/*
    string binary = bitset<8>(input number).to_string(); //to binary
    cout<<binary<<"\n";

    unsigned long decimal = bitset<8>(binary).to_ulong();   //binary to decimal
    cout<<decimal<<"\n";
*/

int main(){
    FIO;
    //w(t)
       //tc++;
       int k;
       string s;
       cin >> k>>s;
       if(s.length() > k){
           fo(i,0,k){
               cout<<s[i];
           }
           cout<<"...";
       }
       else{
           cout<<s;
       }
        
    return 0;
}

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

int main(){
    int a,b,c;cin>>a>>b>>c;
    int d=b/a;
    if(d>c){
        cout<<c<<endl;
    }
    else{
        cout<<d<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <string.h>
#include <map>
#include <bitset>

#define Z class
#define ln cout<<'\n'
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
// sort(vec.begin(), vec.end()); std::greater<>()
// reverse(vec.begin(), vec.end());
// scanf("%s",s);
// printf("%d\n",end-start+1);
// ceil (a + (b - 1)) / b

//===== グラフ受け取り =====//
/*
    int N, M; cin >> N >> M;
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);

        // 無向グラフの場合は以下を追加
        // G[b].push_back(a);
    }
    
    // == 重み付きグラフ == //
    
    struct Edge {
        int to; 
        int weight; 
        Edge(int t, int w) : to(t), weight(w) { }
    };
    using Graph = vector<vector<Edge>>;
    int main() {
        int N, M; cin >> N >> M;
        Graph G(N);
        for (int i = 0; i < M; ++i) {
            int from, to, weight;
            cin >> from >> to >> weight;
            G[from].push_back(Edge(to, weight));
        }
    }
*/    

using namespace std;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
using pll = pair<long long, long long>;

template<class T> inline bool chmax(T& a, T b){ if(a < b) { a=b; return 1; }return 0;}
template<class T> inline bool chmin(T& a, T b){ if(a > b) { a=b; return 1; }return 0;}
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;

int main(){
    string s; cin >> s;
    string res = "Good";
    rep(i, 3) {
        if(s[i] == s[i+1]) res = "Bad";
    }
   cout << res << endl;
}






Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s=sc.nextLine();
		int l=s.length();
		System.out.println(s.charAt(0)+""+(l-2)+""+s.charAt(l-1));
	}
}


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

const int MOD = (int)1e9+7;

int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  for(int i=0;i<N;i++)  cin >> L.at(i);

  sort(L.begin(),L.end());
  int sum=0;
  for(int i=0;i<N-1;i++){
    sum+=L.at(i);
  }
  if(sum>L.at(N-1)) cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
//19
#include<iostream>
#include<queue>

using namespace std;

struct S{
  int b,f,t;
};

int main(){
  for(int n;cin>>n,n;){
    int b[2][101]={{}};
    for(int i=0;i<2;i++){
      for(int j=0;j<n;j++){
	cin>>b[i][j];
      }
    }
    queue<S> que;
    S is={0,0,0};
    que.push(is);
    is.b=1;
    que.push(is);
    bool mem[2][100]={{}};
    while(!que.empty()){
      S s=que.front();
      while(b[s.b][s.f]==1&&b[s.b][s.f+1]==1){
	s.f++;
      }
      while(b[s.b][s.f]==2){
	s.f--;
      }
      if(s.f==n-1)break;
      que.pop();
      if(mem[s.b][s.f]++)continue;
      for(int i=0;i<3;i++){
	if(s.f+i<n){
	  S ns={s.b^1,s.f+i,s.t+1};
	  que.push(ns);
	}
      }
    }
    if(que.empty()){
      cout<<"NA"<<endl;
    }else{
      cout<<que.front().t<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int a, b, c, d;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b >> c >> d;
  cout << max(a*b, c*d) << endl;
}

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

int main(){
int M,N; cin>>M>>N;
  if(M>N){cout<<"safe"<<endl;}
  else {cout<<"unsafe"<<endl;}
}


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

int main(void) {

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int sub_x = tx - sx;
    int sub_y = ty - sy;

    string s = "";
    for (int i = 0; i < sub_y; i++) s += "U";
    for (int i = 0; i < sub_x; i++) s += "R";
    for (int i = 0; i < sub_y; i++) s += "D";
    for (int i = 0; i < sub_x; i++) s += "L";

    s += "LU";
    for (int i = 0; i < sub_y; i++) s += "U";
    for (int i = 0; i < sub_x; i++) s += "R";
    s += "RDRD";
    for (int i = 0; i < sub_y; i++) s += "D";
    for (int i = 0; i < sub_x; i++) s += "L";
    s += "LU";

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class MyClass
{
    public static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int minValue = 1 << 30;
        int ans = -(1 << 30);
        for (int i = 0; i < n; i++)
        {
            int a = int.Parse(Console.ReadLine());
            if (i >= 1)
            {
                ans = Math.Max(ans, a - minValue);
            }
            minValue = Math.Min(a, minValue);
        }
        Console.WriteLine(ans);
    }
}


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

int main(){
    int n;
    cin >> n ;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];}
    
    for(int j=n-1; j>=0; j--){
        if(j==n-1){cout << a[j];}
        else{cout << " " << a[j];}
         }
    cout << endl;
    return 0;

    
}

Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 long double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007LL
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  101LL
#define tmod             998244353LL
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<pair< ll ,ll > > &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
ll P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n,ll m);

bool check(int m,vector<ll> &A,int n)
{
    for(int i=0;i<=n-m;i++)
    {
        if(A[i]!=A[i+m] ) return true;
    }
    return false;
}

int main()
{
fast;
ll q=1,t;
//cin >> q; t = q;
while(q--)
{
    ll i,j,n,m,k,l,r,a=0,b=0,c=0,d=0,e,g=1,p,u,v,w,x,y,flag=0;
    //n=m=k=i=j=l=r=a=b=c=d=u=v=w=p=x=y=0;
    cin >> x >> y;
    a = y/2 - x;
    b = 2*(x) - y/2;
    if(y%2==0 and a >=0  and b >=0 and a+b == x and 2*a+b == y/2) cout << "Yes";
    else cout << "No";
}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n,ll m)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2,m);
    if(n%2==0){return (temp*temp)%m;}
    else{return (b*((temp*temp)%m))%m;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<pair<ll,ll> > &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid].F==ser)
    {
        return mid;
    }
    else if(PS[mid].F > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

void Sieve(int n)
{
    //memset(P,true,sizeof(P));
    //P[0] = false;
    //P[1]= false;
    for(int i=1;i<=n;i++) P[i] = i;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i]==i)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                if(P[j]==j)
                    P[j]=i;
            }
        }
    }

}



Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <fstream>
#include <stdint.h>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

constexpr int evx[4] = { 1, 0, -1, 0 };
constexpr int evy[4] = { 0, 1, 0, -1 };

//----------------------------------
//----------------------------------

signed main()
{
    ios::sync_with_stdio(false);
        int n;
        cin >> n;
        vector<int> a;
        for(int i = 0; i < n; i++)
        {
                int tmp;
                cin >> tmp;
                a.push_back(tmp-1);
        }

        int num = 0;
        for(int i = 0; i < n; ++i)
        {
                if(a[i] > i)
                        if(a[a[i]] == i)
                                num++;
        }
        cout << num << '\n';
}



Measured memory_bytes: 892
def main():
    inf = 10**9
    H, N = map(int, input().split())
    AB = []
    for n in range(N):
        a, b = map(int, input().split())
        AB.append((a, b))
    AB.sort(reverse=True, key=lambda x: x[0])
    dp = [inf] * (H + 10 ** 4)
    dp[0] = 0
    for a, b in AB:
        for h in range(H):
            if dp[h] != inf:
                tmp = dp[h] + b
                if tmp < dp[h + a]:
                    dp[h + a] = tmp
    print(min(dp[H:]))
 
 
main()

Measured memory_bytes: 3692
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}
int main() {
    int N;
    string s;
    cin >> N >> s;
    int res = 1;
    char tmp = s[0];
    rep(i, 1, N) {
        if(tmp != s[i]) {
            res++;
            tmp = s[i];
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 512
n = gets.chomp.to_i

hash = {}
(1..100).each do |x|
  (1..100).each do |y|
    (1..100).each do |z|
      count = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
      hash[count] ||= 0
      hash[count] += 1
    end
  end
end

(1..n).each do |i|
  puts hash[i].to_i
end


Measured memory_bytes: 16704
package main

import (
	"fmt"
	"strings"
)

func main() {
	var H, W int
	_, _ = fmt.Scan(&H, &W)
	sharp := 0
	field := make([][]string, H)
	for i := 0; i < H; i++ {
		var tmp string
		_, _ = fmt.Scan(&tmp)
		tmpArr := strings.Split(tmp, "")
		field[i] = make([]string, W)
		for j := 0; j < W; j++ {
			field[i][j] = tmpArr[j]
			if tmpArr[j] == "#" {
				sharp++
			}
		}
	}
	queue := []point{{0 ,0}}
	vectors := []vector{{1, 0}, {0, 1}, {-1, 0}, {0, -1}}
	distance := 0
	goalDistance := -1
	for len(queue) != 0 {
		length := len(queue)
		for i := 0; i < length; i++ {
			p := queue[0]
			queue = queue[1:]
			f := field[p.h][p.w]
			if f != "." {
				continue
			}
			field[p.h][p.w] = "$"
			if p.h == H - 1 && p.w == W - 1 {
				queue = make([]point, 0)
				goalDistance = distance + 1
				break
			}
			for _, v := range vectors {
				next := point{p.h + v.h, p.w + v.w}
				if next.h >= H || next.h < 0 || next.w >= W || next.w < 0 {
					continue
				}
				queue = append(queue, next)
			}
		}
		distance++
	}
	if goalDistance > 0 {
		fmt.Println((H * W) - sharp - goalDistance)
	} else {
		fmt.Println("-1")
	}
}

type point struct {
	h, w int
}

type vector struct {
	h, w int
}

Measured memory_bytes: 1152
#include<stdio.h>
#define REP(i,n) for (int i = 0 ; i < (int)n ; i++)
typedef long long ll;

int main(){
    int m,f,r;
    while(1){
        scanf("%d %d %d",&m,&f,&r);
        
        if( m == -1 && f == -1 && r == -1 ) break;

        if( m == -1 || f == -1 ) printf("F\n");
        else if( m+f >= 80 ) printf("A\n");
        else if( m+f >= 65 && m+f < 80 ) printf("B\n");
        else if( m+f >= 50 && m+f < 65 ) printf("C\n");
        else if( m+f >= 30 && m+f < 50 ){
            if( r >= 50 ) printf("C\n");
            else printf("D\n");
        }
        else if( m+f < 30 ) printf("F\n");

    }
}


Measured memory_bytes: 2100
//E
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
typedef long long ll;

struct apple{
	int col,val;
}a[3*maxn];

bool cmp(apple p,apple q){ return p.val>q.val; }
	
int main()
{
	int x,y,A,B,C;
	scanf("%d%d%d%d%d",&x,&y,&A,&B,&C);
	for(int i=1;i<=A+B+C;i++){
		scanf("%d",&a[i].val);
		if(i<=A) a[i].col=1;
		else if(i<=A+B) a[i].col=2;
		else a[i].col=3;
	}
	sort(a+1,a+A+B+C+1,cmp);
	ll ans=0; int sum=0;
	for(int i=1;i<=A+B+C;i++){
		if(a[i].col==1&&x) {
			x--;ans+=(ll)a[i].val;
		}
		if(a[i].col==2&&y) {
			y--; ans+=(ll)a[i].val;	
		}
		if(a[i].col==3){
			ans+=(ll)a[i].val;
			sum++;
		}
//		cout<<a[i].val<<endl;
		if(sum==x+y)break;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 6172