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

public class Main{
  public static void main(String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] s = br.readLine().split(" ");
    int n = Integer.parseInt(s[0]);
    int W = Integer.parseInt(s[1]);
    long[] val = new long[n];
    long[] wt = new long[n];
    for(long i=0;i<n;i++){
      String[] str = br.readLine().split(" ");
      wt[(int)i] = Long.parseLong(str[0]);
      val[(int)i] = Long.parseLong(str[1]);
    }
    long[][] dp = new long[n+1][W+1];
    
    for(long i=0;i<=n;i++){
      for(long j=0;j<=W;j++){
        if(i==0 || j==0)
          dp[(int)i][(int)j] = 0;
        else if(j>=wt[(int)(i)-1])
          dp[(int)i][(int)j] = Math.max(dp[(int)(i)-1][(int)j], val[(int)(i)-1] + dp[(int)(i)-1][(int)j-(int)wt[(int)(i)-1]]);
        else
          dp[(int)i][(int)j] = dp[(int)(i)-1][(int)j];
      }
    }
    long max = 0;
    for(long i=0;i<=W;i++)
      max = Math.max(max,dp[(int)n][(int)i]);
    System.out.println(max);
  }
}


Measured memory_bytes: 138288
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll bit[100010], num;
ll n, a[100010], b[100010], par[100010], ans;
vector<ll> same_X[100010], vec[100010];
map<ll, ll> X, Y, mp;
set<ll> S[100010], T[100010];

ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= num)
	{
		bit[i] += x;
		i += i & -i;
	}
}

ll po(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return po(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = po(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return po(x, mod - 2);
}

ll root(ll x) { // �f�[�^x��������؂̍����ċA�œ���Froot(x) = {x�̖؂̍�}
	if (par[x] == x) return x;
	return par[x] = root(par[x]);
}

void unite(ll x, ll y) { // x��y�̖؂𕹍�
	int rx = root(x); //x�̍���rx
	int ry = root(y); //y�̍���ry
	if (rx == ry) return; //x��y�̍�������(=�����؂ɂ���)���͂��̂܂�
	par[rx] = ry; //x��y�̍��������łȂ�(=�����؂ɂȂ�)���Fx�̍�rx��y�̍�ry�ɂ���
}

bool same(ll x, ll y) { // 2�̃f�[�^x, y��������؂������Ȃ�true��Ԃ�
	int rx = root(x);
	int ry = root(y);
	return rx == ry;
}

int main(void)
{
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		par[i] = i;
	}
	for (int i = 0; i < n; i++)
	{
		cin >> a[i] >> b[i];
		X[a[i]]++;
		Y[b[i]]++;
	}
	ll ct = 1;
	for (auto itr = X.begin(); itr != X.end(); ++itr)
	{
		X[itr->first] = ct;
		ct++;
	}
	ct = 1;
	for (auto itr = Y.begin(); itr != Y.end(); ++itr)
	{
		Y[itr->first] = ct;
		ct++;
	}
	for (int i = 0; i < n; i++)
	{
		same_X[X[a[i]]].push_back(Y[b[i]]);
	}
	for (auto itr = X.begin(); itr != X.end(); ++itr)
	{
		for (int i = 1; i < same_X[itr->second].size(); i++)
		{
			unite(same_X[itr->second][0], same_X[itr->second][i]);
		}
	}
	for (int i = 1; i <= n; i++)
	{
		root(i);
	}
	for (auto itr = Y.begin(); itr != Y.end(); ++itr)
	{
		vec[par[itr->second]].push_back(itr->second);
	}
	for (int i = 0; i < n; i++)
	{
		S[par[Y[b[i]]]].insert(X[a[i]]);
		T[Y[b[i]]].insert(X[a[i]]);
	}
	for (auto itr = Y.begin(); itr != Y.end(); ++itr)
	{
		ans += S[par[itr->second]].size() - T[itr->second].size();
	}
	cout << ans << endl;
	int www;
	cin >> www;
}


Measured memory_bytes: 32256
#include "bits/stdc++.h"
using namespace std;
int main() {
    int n,x,ans = 1,now = 0;
    cin >> n >> x;
    for(int i = 0;i<n;i++){
        int l;
        cin >> l;
        now += l;
        if(now <= x)ans++;
    }
    cout << ans;
    return 0;
}

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



int32_t main(){
	string s;
	cin>>s;
	string t = "keyence";
	if(s == t){
		cout<<"YES"<<endl;
		return 0;
	}
	bool can = false;
	int n = s.size();
	for(int i = 0 ; i < n ; i ++){
		for(int j = i ; j < n ; j ++){
			string r;
			for(int w = 0 ; w < n ; w++){
				if(i <= w && w <= j) continue;
				r+=s[w];
			}
			if(r == t) can = true;
		}
	}
	if(can) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
while True:
    w, h = map(int, input().split())
    if w == 0 and h == 0:
        break
    ywalls = [[0]*w for _ in range(h)]
    xwalls = [[0]*w for _ in range(h)]
    for i in range(2*h-1):
        walls = map(int, input().split())
        if i%2==0:
            for j, ele in enumerate(walls):
                ywalls[i//2][j]=ele
        else:
            for j, ele in enumerate(walls):
                xwalls[i//2][j]=ele

    d = [[-1]*w for _ in range(h)]
    sx, sy = 0, 0
    gx, gy = w-1, h-1
    from collections import deque
    q = deque([])
    q.append((sx, sy))
    d[sx][sy] = 0

    while len(q)>0:
        cur = q.popleft()
        #print(cur)
        curx, cury = cur[0], cur[1]
        if curx==gx and cury==gy:
            break
        for dx in range(-1, 2):
            for dy in range(-1, 2):
                if (dx==0 and dy!=0) or (dx!=0 and dy==0):
                    nx, ny = curx+dx, cury+dy
                    if 0<=nx<w and 0<=ny<h and d[ny][nx]==-1:
                        tx, ty = curx, cury
                        if dx==-1:
                            tx -=1
                        elif dy==-1:
                            ty -=1
                        if dx!=0 and ywalls[ty][tx]==0:
                            q.append((nx, ny))
                            d[ny][nx] = d[cury][curx]+1
                        elif dy!=0 and xwalls[ty][tx]==0:
                            q.append((nx, ny))
                            d[ny][nx] = d[cury][curx]+1

    print(d[gy][gx]+1)



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

#define int long long
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fr(i,j,k) for(i = j; i < (k); i++)
#define all(x) x.begin(), x.end()
#define el '\n'
#define remax(a,b) a = max(a, b)
#define remin(a,b) a = min(a, b)
#define sz(x) int32_t(x.size())

typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
// --------------------------------------------------------------------

const pii dxy[] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1} };
const int mod = 1e9 + 7;
const int INF = 2e18;
const ld EPS = 1e-9;
const int NN = 1e5 + 2;

int isp5(int x) {
      if(x >= 1000) return INF;
      int res = x;
      for(int i = 0; i < 4; i++) {
            res *= x;
      }
      return res;
}

// bool check(int x) {
//       int lo = 1, hi = x;
//       while(lo <= hi) {
//             int mid = lo+hi>>1, v = isp5(mid);
//             if(v > x) {
//                   hi = mid - 1;
//             } else if(v < x) {
//                   lo = mid + 1;
//             } else
//                   return 1;
//       }
//       return 0;
// }
void solve() {
      int i = 0, j = 0, x;
      cin >> x;
      fr(i, 2, 151) {
            fr(j, 0, i) {
                  if(isp5(i) - isp5(j) == x) {
                        cout << i << ' ' << j << endl;
                        return;
                  }
            }
      }

      fr(i, 0, 101) {
            fr(j, 0, 101) {
                  if(isp5(i) + isp5(j) == x) {
                        cout << i << ' ' << (-j) << endl;
                        return;
                  }
            }
      }
}

int32_t main() {
      ios::sync_with_stdio(false); cin.tie(0); 
      int T = 1; 
      // cin >> T;
      for(int tc = 1; tc <= T; tc++) {
            solve();
       }
      return 0;
}

Measured memory_bytes: 3616
n = int(input())
xy = [[] for _ in range(n)]
ans = -float("inf")

for i in range(n):
	a = int(input())
	for _ in range(a):
		xy[i].append(tuple(map(int, input().split())))

for i in range(2**n):
	true_or_false = [0] * n
	flag = False
	for j in range(n):
		if (i>>j)&1:
			true_or_false[n-1-j] = 1
	for i, l in enumerate(xy):
		for x, y in l:
			if true_or_false[i] == 1:
				if true_or_false[x-1] != y:
					flag = True
	if not flag:
		ans = max(ans, len([i for i in true_or_false if i == 1]))
print(ans)

Measured memory_bytes: 43116
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    Int ans = 0, curr = A[0];
    for (int i = 0; i < N; i++) {
        if (curr < A[i]) {
            curr = A[i];
        } else {
            ans += curr - A[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3988
import sys
from collections import Counter
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *abc = map(int, readline().split())
lst = list(map(int, read().split()))
s = 10 ** 9 + 7
for i in range(4 ** n):
  tlst = [0] * n
  ti = i
  for j in range(n):
    tlst[j] = ti % 4
    ti //= 4
  c = Counter(tlst)
  if not (c[1] and c[2] and c[3]):
    continue
  else:
    cost = [0] * 3
    for idx, j in enumerate(tlst):
      if j == 0:
        continue
      cost[j - 1] += lst[idx]
    s = min(s, sum(abs(cost[j] - abc[j]) + 10 * (c[j + 1] - 1) for j in range(3)))
print(s)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
    using namespace std;
     
    int n, k, x, ans;
     
    int main() {
        cin >> n;
        cin >> k;
        for (int i = 0; i < n; ++i) {
            cin >> x;
            ans += (x < k - x) ? 2 * x : 2 * (k - x);
        }
        cout << ans << endl;
        return 0;
    }

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

int main()
{
	int n, x;
	cin >> n >> x;
	int sum = 0, c = 10000;
	for(auto i = 0; i < n; ++i){
		int m;
		cin >> m;
		sum += m;
		c = min(c, m);
	}
	cout << n + (x - sum) / c << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
constexpr ll mod = 1e9+7;
ll N,M,L,K;

template<ll mod>
class Fp {
public:
	ll val;
private:
	inline void calc_mod(ll& v) {
		if (v >= mod)v -= mod;
	}
public:
	Fp(){}
	Fp(ll v) :val(v%mod) {
		if (val < 0)val += mod;
	}
	Fp operator+=(const Fp &in) {
		val += in.val;
		calc_mod(val);
		return *this;
	}
	Fp operator+(const Fp &in) const{
		return Fp(*this) += in;
	}
	Fp &operator-=(const Fp &in) {
		val -= in.val;
		calc_mod(val);
		if (val < 0)val += mod;
		return *this;
	}
	Fp operator-(const Fp &in) const{
		return Fp(*this) -= in;
	}
	Fp& operator*=(const Fp& in) {
		val = val * in.val % mod;
		return *this;
	}
	Fp operator*(const Fp &in) const{
		return Fp(*this) *= in;
	}
	Fp& operator/=(const Fp& in) {
		*this *= modpow(in, mod - 2);
		return *this;
	}
	Fp operator/(const Fp& in) const{
		return Fp(*this) /= in;
	}
	bool operator==(const Fp&in)const {
		return val == in.val;
	}
	bool operator!=(const Fp&in)const {
		return val != in.val;
	}
	friend Fp modpow(const Fp& in, ll n){
		if (n == 0)return 1;
		if (n & 1) {
			return in*modpow(in*in, n / 2);
		}
		else {
			return modpow(in*in, n / 2);
		}
	}
};
using modll = Fp<mod>;
class Factorial {
public:
	vector<modll> fact, finv;
	Factorial(ll n) :fact(n + 1, modll(1)), finv(n + 1, modll(1)) {
		for (int i = 2; i <= n; i++) {
			modll tmp(i);
			fact[i] = fact[i - 1] * tmp;
			finv[i] = finv[i - 1] / tmp;
		}
	}
	modll com(const ll& n, const ll& k) {
		if (n < k || n < 0 || k < 0)return modll(0);
		return fact[n] * finv[k] * finv[n - k];
	}
};

int main(){
    Factorial f(3000);
    cin>>N>>K;
    for(int i=1;i<=K;i++){
        cout<<(f.com(K-1,i-1)*f.com(N-K+1,i)).val<<endl;
    }
}

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N;
  int sum = 0;
  cin >> N;
  for (int i = 1; i <= N; i++)
    sum += i;
  cout << sum << endl;
}


Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())
ans = 0
cnt = 0
while x > cnt and y > cnt:
    ans += min(a+b, c*2)
    cnt += 1

if x > cnt:
    while x > cnt:
        ans += min(a, c*2)
        cnt += 1
else:
    while y > cnt:
        ans += min(b, c*2)
        cnt += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <cmath>
using namespace std;

int main()
{
	int N, X;
	cin >> N >> X;
	
	int min = 0;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		X -= tmp;
		min = i ? std::min(min, tmp) : tmp;
	}

	cout << N + (X / min) << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int a, b;

	cin >> a >> b;

	if (a <= 8 && b <= 8) Out("Yay!");
	else Out(":(");
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    std::ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    int t[n],x[n],y[n];
    for(int i=0;i<n;++i)
    cin>>t[i]>>x[i]>>y[i];
    int f=0;
    for(int i=1;i<n;++i)
    {
        t[i]-=t[i-1];
        if(x[i]>x[i-1])
        x[i]-=x[i-1];
        else
        x[i]=x[i-1]-x[i];
        if(y[i]>y[i-1])
        y[i]-=y[i-1];
        else
        y[i]=y[i-1]-y[i];
    }
    for(int i=0;i<n;++i)
    {
    t[i]=t[i]-x[i]-y[i];
    if(t[i]<0||t[i]%2==1)
    f=1;
    }
    if(f==0)
    cout<<"Yes";
    else
    cout<<"No";
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include "atcoder/all"
#define rep(i,n)for(int i=0;i<(int)(n);i++)
using namespace std;
using namespace atcoder;
#define all(a) a.begin(),a.end()
typedef long long ll;
#define vi vector<ll>
typedef pair<ll,ll>P;
const ll inf=1ll<<61;

signed main(){
	int n,m;cin>>n>>m;
	dsu d(n);
	rep(i,m){
		int a,b;cin>>a>>b;
		a--;b--;
		d.merge(a,b);
	}
	set<int>S;
	rep(i,n)S.insert(d.leader(i));
	cout<<S.size()-1<<endl;
}

Measured memory_bytes: 7672
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    print('Yes' if ni() >= 30 else 'No')
    return

solve()


Measured memory_bytes: 9172
def main():
    N = int(input())
    for h in range(1, 3501):
        for n in range(1, 3501):
            if (4*h*n-N*h-N*n) > 0:
                if (N*h*n)%(4*h*n-N*h-N*n) == 0:
                    w = (N*h*n)//(4*h*n-N*h-N*n)
                    print(h,n,w)
                    return

main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define maxl 100010

using namespace std;

int n,m,cnt;
bool flag;
long long ans;
int a[maxl],f[maxl],b[maxl];
map <int,int> mp[maxl];
map <int,int> ::iterator it;
struct node
{
	int val,id;
	bool operator < (const node &b) const
	{
		if(val==b.val)
			return id<b.id;
		else
			return val<b.val;
	}
	bool operator == (const node  &b) const
	{
		return val==b.val && id==b.id;
	}
};
set <node> s;

inline int find(int x)
{
	if(f[x]!=x)
		f[x]=find(f[x]);
	return f[x];
}

inline void prework()
{
	for(int i=1;i<=n;i++)
	{
		f[i]=i;
		mp[i].clear();
	}
	s.clear();
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int u,v,x,y;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		u++;v++;
		x=find(u);y=find(v);
		if(x!=y)
			f[y]=x;
	}
	for(int i=1;i<=n;i++)
		x=find(i);
	for(int i=1;i<=n;i++)
		mp[f[i]][a[i]]++;

}

inline void mainwork()
{
	ans=0;flag=true;node d1,d2;
	int x,y,res=2*(n-1-m);
	cnt=0;
	for(int i=1;i<=n && res>0;i++)
	if(mp[i].begin()!=mp[i].end())
	{
		ans+=mp[i].begin()->first;
		mp[i].begin()->second--;
		res--;
		if(mp[i].begin()->second==0)
			mp[i].erase(mp[i].begin());
		for(it=mp[i].begin();it!=mp[i].end();++it)
		{
			for(int j=1;j<=it->second;j++)
				b[++cnt]=it->first;	
		}
	}
	if(cnt<res)
	{
		flag=false;
		return;
	}
	sort(b+1,b+1+cnt);
	for(int i=1;i<=res;i++)
		ans+=b[i];
	
	/*for(int i=1;i<=n-1-m;i++)
	{
		if(s.size()<2)
		{
			flag=false;
			return;
		}
		d1=(*s.begin());s.erase(s.begin());
		d2=(*s.begin());s.erase(s.begin());
		x=d1.id;y=d2.id;
		ans+=d1.val+d2.val;
		mp[x][d1.val]--;mp[y][d2.val]--;
		if(mp[x].size()<mp[y].size())
			swap(x,y);
		f[y]=x;
		for(it=mp[y].begin();it!=mp[y].end();++it)
			mp[x][it->first]+=it->second;
		mp[y].clear();
		while(mp[x].begin()->second==0)
		{	
			mp[x].erase(mp[x].begin());
			if(mp[x].size()==0)
				break;
		}
		if(mp[x].size()>0)
			s.insert(node{mp[x].begin()->first,x});
	}*/
}

inline void print()
{
	if(flag)
		printf("%lld\n",ans);
	else
		puts("Impossible");
}

int main()
{
	while(~scanf("%d%d",&n,&m))
	{
		prework();
		mainwork();
		print();
	}
	return 0;
}
 

Measured memory_bytes: 10752
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=1010;
int a[N],b[N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') ch=='-'?o=-1:0,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return o*x;
}
inline void work(int x,int y) {
    for(int i=30;~i;i--) {
	if(abs(x)>abs(y)) {
	    if(x<0) x+=1<<i,putchar('L');
	    else x-=1<<i,putchar('R');
	}
	else {
	    if(y<0) y+=1<<i,putchar('D');
	    else y-=1<<i,putchar('U');
	}
    }
}
int main() {
    int n,t;
    cin>>n;
    for(int i=1;i<=n;i++) {
	int x=a[i]=gi(),y=b[i]=gi();
	if(i==1) t=(x+y)&1;
	else if(((x+y)&1)!=t) return cout<<-1,0;
    }
    t^=1,cout<<31+t<<endl;
    if(t) cout<<1<<' ';
    for(int i=30;~i;i--) printf("%d ",1<<i);
    for(int i=1;i<=n;i++) {
	puts("");
	if(t) putchar('R');
	work(a[i]-t,b[i]);
    }
    return 0;
}

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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int x1 = stdIn.nextInt();
		int y1 = stdIn.nextInt();
		int x2 = stdIn.nextInt();
		int y2 = stdIn.nextInt();
		
		
		//まずは辺の長さを出す
		int a = x2 - x1;
		int b = y2 - y1;
		
		int y3 = y2 + a;
		int x3 = x2 - b;
		
		int x4 = x3 - a;
		int y4 = y3 - b;
		
		System.out.println(x3+" "+ y3+" "+x4+" "+y4);
		
		
	}

}


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

int main() {
  int N;
  cin >> N;
  vector<ll> A(3*N);
  for (int i = 0; i < 3*N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  ll ans = 0;
  for (int i = 1; i <= 2*N; i++) {
    if (i % 2 == 1) ans += A[i];
  }
  cout << ans  << endl;
}


Measured memory_bytes: 2560
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int n,k;
vi a;
vi one(60);
int ans;

int l;

signed main(){

    in(n,k);
    resz(n,a);
    in(a);
    rep(i,n){
        rep(j,60){
            if((1LL<<j)&a[i]) one[j]++;
        }
    }
    // show(one);
    REPEAT(i,0,60,false){
        if(one[i]!=max(one[i],n-one[i])){
            if(l+(1LL<<i)<=k){
                one[i]=max(one[i],n-one[i]);
                l+=(1LL<<i);
            }
        }
        ans+=one[i]*(1LL<<i);
    }
    //show(l);
    out(ans);

    return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
from collections import deque


def read():
    H, W, K = list(map(int, input().strip().split()))
    S = []
    for i in range(H):
        s = list(input().strip())
        S.append(s)
    return H, W, K, S


def paint(row, l, r, uid):
    for i in range(l, r):
        row[i] = str(uid)


def copy_row(src, dst, W):
    for i in range(W):
        dst[i] = src[i]


def solve(H, W, K, S):
    uid = 0
    for i in range(H):
        l = 0
        for j in range(W):
            r = j+1
            if S[i][j] == "#":
                uid += 1
                paint(S[i], l, r, uid)
                l = r
        if l > 0:
            r = W
            paint(S[i], l, r, uid)
            h = 0
    
    # fill empty rows
    non_empty_row = -1
    for i in range(H):
        if S[i][0] != ".":
            non_empty_row = i
        elif non_empty_row >= 0 and S[i][0] == ".":
            copy_row(S[non_empty_row], S[i], W)

    for i in range(H-1, -1, -1):
        if S[i][0] != ".":
            non_empty_row = i
        elif non_empty_row >= 0 and S[i][0] == ".":
            copy_row(S[non_empty_row], S[i], W)

    for i in range(H):
        print(" ".join(S[i]))


if __name__ == '__main__':
    inputs = read()
    solve(*inputs)


Measured memory_bytes: 15724
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ll n;
	cin>>n;
	ll arr[n];
	for(int i=0; i<n; i++)
	{
		cin>>arr[i];
	}

	sort(arr,arr+n);

	double sum = arr[0];
	for(int i=1; i<n; i++)
	{
		sum = (sum + arr[i])/2;
	}
	cout<<sum<<endl;
	return 0;
}
	


Measured memory_bytes: 256
package main
import(
    "fmt"
    )
func main(){
    minTime, human := 1000000000000000, 0
    fmt.Scan(&human)
    for i, time:=0, 0; i<5; i++{
        fmt.Scan(&time)
        if minTime > time{
            minTime = time
        }
    }
    ans := 4+human/minTime
    if human%minTime != 0{
        ans ++
    } 
    fmt.Println(ans)
}


Measured memory_bytes: 512
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
            out.flush();
        }
    }

    void solve(InputReader in, PrintWriter out) {
        int a = in.nextInt();
        int p = in.nextInt() + a * 3;
        out.println(p / 2);
    }
}

class InputReader implements AutoCloseable {
    private final Scanner sc = new Scanner(System.in);

    String next() {
        return this.sc.next();
    }

    int nextInt() {
        return Integer.parseInt(this.sc.next());
    }

    long nextLong() {
        return Long.parseLong(this.sc.next());
    }

    double nextDouble() {
        return Double.parseDouble(this.sc.next());
    }

    @Override
    public void close() {
        this.sc.close();
    }
}


Measured memory_bytes: 24020
n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(n)]
x = []
for i,j in a:
    x.append((i,j,1))
for i,j in b:
    x.append((i,j,2))
x.sort()
#print(x)
for i in range(2*n):
    x[i] = (x[i][1],x[i][2])
#print(x)
ans = 0
while len(x):
    maxindex = 0
    maxvalue = -1
    flag = 0
    for i in range(len(x)):
        if x[i][0]>maxvalue and x[i][1]==1:
            flag = 1
            maxvalue = x[i][0]
            maxindex = i
    if flag == 0:
        break
    #if (x[maxindex][1]==1):
        #x.pop(i)
    #else:
    #maxindex2 = 0
    #maxvalue2 = -1
    flag = 0
    for i in range(maxindex+1,len(x)):
        if (x[i][1]==2):
            if (x[i][0]>maxvalue):
                ans += 1
                x.pop(i)
                x.pop(maxindex)
                flag=1
                break
    if (flag==0):
        x.pop(maxindex)
print(ans)

Measured memory_bytes: 9040
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll N;cin>>N;
  map<long double,int> w;
  long double temp;
  FOR(i,1,3501){
    temp=(long double)(4*i-N)/(N*i);
    if(temp>0){
      w[temp]=i;
    }
  }

  FOR(h,1,3501){
    FOR(n,1,3501){
      temp=(long double)(n+h)/(h*n);
      if(w.count(temp)){
        cout<<h<<' '<<n<<' '<<w.at(temp)<<endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <functional>
#include <algorithm>
using namespace std;
typedef tuple<int,int,int> tiii;
typedef struct{
	int x;
	int y;
}dir;
vector<dir>D={
	{-1,-1},{0,-1},{1,-1},
	{-1,0},{1,0},
	{-1,1},{0,1},{1,1},
};

const int H=8,W=8;
vector<function<bool(tiii,tiii)> >sorter={//{num,x,y}
	[](tiii a,tiii b)->bool{
		if(get<0>(a)<get<0>(b))return true;
		if(get<0>(a)>get<0>(b))return false;
		if(get<2>(a)>get<2>(b))return true;
		if(get<2>(a)<get<2>(b))return false;
		if(get<1>(a)>get<1>(b))return true;
		if(get<1>(a)<get<1>(b))return false;
		return false;
	},
	[](tiii a,tiii b)->bool{
		if(get<0>(a)<get<0>(b))return true;
		if(get<0>(a)>get<0>(b))return false;
		if(get<2>(a)<get<2>(b))return true;
		if(get<2>(a)>get<2>(b))return false;
		if(get<1>(a)<get<1>(b))return true;
		if(get<1>(a)>get<1>(b))return false;
		return false;
	}
};

int check2(int color,dir&d,int x,int y,vector<string>&m){
	if(x<0||W<=x||y<0||H<=y||m[y][x]=='.')return -1;
	if(m[y][x]==color)return 0;
	int r=check2(color,d,x+d.x,y+d.y,m);
	if(r<0)return r;
	return r+1;
}
int check1(int color,int x,int y,vector<string>&m){
	int R=-1;
	for(auto &d:D){
		int r=check2(color,d,x+d.x,y+d.y,m);
		if(r>0){
			if(R<0)R=0;
			R+=r;
		}
	}
	return R;
}

int fill2(int color,dir&d,int x,int y,vector<string>&m){
	if(x<0||W<=x||y<0||H<=y||m[y][x]=='.')return -1;
	if(m[y][x]==color)return 0;
	int r=fill2(color,d,x+d.x,y+d.y,m);
	if(r<0)return r;
	m[y][x]=color;
	return r+1;
}
void fill1(int color,int x,int y,vector<string>&m){
	for(auto &d:D)fill2(color,d,x+d.x,y+d.y,m);
}

int main(){
	string color="ox";
	vector<string>m(H);
	for(int h=0;h<H;h++)cin>>m[h];
	int turn=0,pass=0;
	for(;;turn^=1){
		vector<tiii>v;
		for(int y=0;y<H;y++)for(int x=0;x<W;x++)if(m[y][x]=='.'){
			int r=check1(color[turn],x,y,m);
			if(r>0)v.push_back(make_tuple(r,x,y));
		}
		if(v.empty()){
			pass++;
			if(pass>1)break;
		}else{
			pass=0;
			sort(v.begin(),v.end(),sorter[turn]);
			tiii &t=*v.rbegin();
			int x=get<1>(t),y=get<2>(t);
			fill1(color[turn],x,y,m);
			m[y][x]=color[turn];
		}
	}
	for(int h=0;h<H;h++)cout<<m[h]<<endl;
	return 0;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if (s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	public static final int TYPES = 26;
	
	public static long calc(final int D, int[] cs, int[][] ss, int[] answers) {
		int[] lasts = new int[TYPES];
		
		long score = 0;
		for(int i = 0; i < D; i++) {
			final int type = answers[i];
			
			score += ss[i][type];
			lasts[type] = i + 1;
			
			for(int j = 0; j < TYPES; j++) {
				score -= cs[j] * ((i + 1) - lasts[j]);
			}
			System.out.println(score);
		}
		
		return score;
	}
	
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			
			final int D = sc.nextInt();
			
			int[] cs = new int[TYPES];
			for(int i = 0; i < TYPES; i++) {
				cs[i] = sc.nextInt();
			}
			
			int[][] ss = new int[D][TYPES]; 
			for(int i = 0; i < D; i++) {
				for(int j = 0; j < TYPES; j++) {
					ss[i][j] = sc.nextInt();
				}
			}
			
			int[] answers = new int[D];
			for(int i = 0; i < D; i++) {
				answers[i] = sc.nextInt() - 1;
			}
			calc(D, cs, ss, answers);
			
			/*
			for(int i = 0; i < D; i++) {
				System.out.println((i % TYPES) + 1);
			}
			*/
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


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

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n, m;
  cin >> n >> m;
  char a[n][n], b[m][m];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j)
      cin >> a[i][j];
  }
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < m; ++j)
      cin >> b[i][j];
  }
  for (int i = 0; i + m <= n; ++i) {
    for (int j = 0; j + m <= n; ++j) {
      bool ok = 1;
      if (a[i][j] != b[0][0] || a[i + m - 1][j + m - 1] != b[m - 1][m - 1])
        ok = 0;
      for (int x = 0; x < m; ++x) {
        for (int y = 0; y < m; ++y) {
          if (a[i + x][j + y] != b[x][y])
            ok = 0;
          if (!ok)
            break;
        }
        if (!ok)
          break;
      }
      if (ok) {
        cout << "Yes\n";
        return 0;
      }
    }
  }
  cout << "No\n";
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int i,j,n,m,tmp,sum = 0;
    double a,b;
    int number[100];
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++)
    {
        scanf("%d",&number[i]);
        sum += number[i];
    }

    for (i=0; i<n; ++i) {
    for (j=i+1; j<n; ++j) {
      if (number[i] < number[j]) {
        tmp =  number[i];
        number[i] = number[j];
        number[j] = tmp;
      }
    }
  }

  a = (double) number[m-1] / sum;
  b = (double) 1/(4*m);
  if(a>=b)
  {
      printf("Yes\n");
  }
  else
  {
      printf("No\n");
  }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  string str;
  str = "abcdefghijklmnopqrstuwxyz"; 
 
  char i;
  cin >> i ;
  for( int j=0; j<25; j++){
    if( i == str.at(j) ){
      cout << str.at(j+1) << endl ;
    }
  }
}

 

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

const int N=110;
int cnt[N];

int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for (int i=1;i<=k;i++) {
        int m;
        scanf("%d",&m);
        for (int j=1;j<=m;j++) {
            int x;
            scanf("%d",&x);
            cnt[x]++;
        }
    }
    int ans=0;
    for (int i=1;i<=n;i++) {
        ans+=(!cnt[i]);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3812
#include <cstdio>
#include <algorithm>
int main()
{
	int a[3];
	for (int i = 0; i < 3; ++i)
		scanf("%d", a + i);
	std::sort(a, a + 3);
	printf("%d\n", a[0] + a[1]);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h> 
 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 

const double EPS=0.00001;
const long double PI = acos(-1.0);
 
int main(){
    int n;
    cin>>n;
    map<long,int>mp;
    REP(i,n){
        long a;
        cin>>a;
        mp[a]++;
    }
    int res=0;
    for(auto m:mp){
        if(m.first<m.second)res+=m.second-m.first;
        else if(m.first>m.second)res+=m.second;

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

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
	 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
#define clr(a) memset(a,0,sizeof(a))
#define umap unordered_map
#define uset unordered_set
#define fr first
#define sc second
#define pb push_back
#define M int(1e9+7)
#define endl '\n'	
#define largest(a,b,c) (a>b?(a>c? a:c):(b>c? b:c))
#define smallest(a,b,c) (a<b?(a<c? a:c):(b<c? b:c))	

using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;

 
int main(){
	fast_io; cout_precision;
	int n;	cin >> n;
	int arr[n];	for(int i=0; i<n; i++)	cin >> arr[i];
	ll hmin = 0;
	int currMax = arr[0];
	for(int i=1; i<n; i++){
		if(arr[i] >= currMax){
			currMax = arr[i];
		}
		else{
			hmin += currMax - arr[i];
		}
	}
	cout <<hmin <<endl;

	return 0;
}
	

Measured memory_bytes: 4420
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/*
 * AtCoder Grand Contest 026 A "Colorful Slimes 2"
 *   https://agc026.contest.atcoder.jp/tasks/agc026_a/
 */
public class Main {

	public static void main(String[] args) {

		InputScanner in = new InputScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		Task task = new Task();
		task.run(in, out);

		in.close();
		out.close();
	}

	static class Task {

		public void run(InputScanner in, PrintWriter out) {

			int N = in.nextInt();
			int[] a = in.nextIntArray(N);

			int ans = 0;
			for (int i = 1; i < N; i++) {

				if (a[i - 1] == 0) {
					continue;
				}

				if (a[i] == a[i - 1]) {
					a[i] = 0;
					ans++;
				}
			}

			out.println(ans);
		}
	}

	/*
	 * extends java.util.Scanner
	 */
	static class InputScanner {

		Scanner scanner;

		public InputScanner(InputStream inputStream) {
			this.scanner = new Scanner(inputStream);
		}

		public int nextInt() {
			return Integer.parseInt(scanner.next());
		}

		public long nextLong() {
			return Long.parseLong(scanner.next());
		}

		public double nextDouble() {
			return Double.parseDouble(scanner.next());
		}
		public String next() {
			return scanner.next();
		}

		public int[] nextIntArray(int n) {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextInt();
			}
			return ret;
		}

		public int[][] nextIntArray(int h, int w) {
			int[][] ret = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextInt();
				}
			}
			return ret;
		}

		public long[] nextLongArray(int n) {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextLong();
			}
			return ret;
		}

		public long[][] nextlongArray(int h, int w) {
			long[][] ret = new long[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public double[] nextDoubleArray(int n) {
			double[] ret = new double[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextDouble();
			}
			return ret;
		}

		public double[][] nextDoubleArray(int h, int w) {
			double[][] ret = new double[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public String[] nextStringArray(int n) {
			String[] ret = new String[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.next();
			}
			return ret;
		}

		public String[] nextStringArray(String split) {
			String[] ret = scanner.next().split(split);
			return ret;
		}

		public String[][] nextStringArray(int h, int w) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.next();
				}
			}
			return ret;
		}

		public String[][] nextStringArray(int h, String split) {
			String[][] ret = new String[h][];
			for (int i = 0; i < h; i++) {
				ret[i] = scanner.next().split(split);
			}
			return ret;
		}

		public void close() {
			scanner.close();
		}

	}

}


Measured memory_bytes: 21844
#include <iostream>
int main(){
    int b,f,r,v,n;
    int x[4][3][10] = {0};
    std::cin >> n;
    for(int a = 0;a < n;a++){
        std::cin >> b >> f >> r >> v;
        x[b - 1][f - 1][r - 1] = x[b - 1][f - 1][r - 1] + v;
    }
    for(int amatukaze = 0;amatukaze < 3;amatukaze++){
        for(int kagerou = 0;kagerou < 10;kagerou++){
            std::cout <<" ";
            std::cout << x[0][amatukaze][kagerou];
        }
        std::cout << std::endl;
    }
    std::cout <<"####################"<<std::endl;
    for(int yukikaze = 0;yukikaze < 3;yukikaze++){
        for(int siranui = 0;siranui < 10;siranui++){
            std::cout <<" ";
            std::cout << x[1][yukikaze][siranui];
        }
        std::cout << std::endl;
    }
    std::cout <<"####################"<<std::endl;
    for(int nowaki = 0;nowaki < 3;nowaki++){
        for(int kurosio = 0;kurosio < 10;kurosio++){
            std::cout <<" ";
            std::cout <<x[2][nowaki][kurosio];
        }
        std::cout << std::endl;
    }
    std::cout <<"####################"<<std::endl;
    for(int isokaze = 0;isokaze < 3;isokaze++){
        for(int arasi = 0;arasi < 10;arasi++){
            std::cout <<" ";
            std::cout <<x[3][isokaze][arasi];
        }
        std::cout << std::endl;
    }
}

Measured memory_bytes: 3084
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i,n;
    int max,min;
    long sum=0;
    scanf("%d",&n);
    int Ai[n];
    for(i=0;i<n;i++){
        scanf("%d",&Ai[i]);
    }
    max = Ai[0];
    min = Ai[0];
    
    for(i=1;i<n;i++){
        if(max<Ai[i]){
            max = Ai[i];
        }
    }
    for(i=1;i<n;i++){
        if(min>Ai[i]){
            min = Ai[i];
        }
    }
    for(i=0;i<n;i++){
        sum = sum + Ai[i];
        }
    
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}


Measured memory_bytes: 2104
def draw(h, w):
    for x in range(0, h):
        if x == 0 or x == h-1:
            print("#"*w)
        else:
            print("#"+("."*(w-2))+"#")
    print()

while True:
    h, w = map(int, input().split())

    if h == w == 0:
        break;

    draw(h, w)


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    string S;
    cin >> S;

    if (S.back() == 's') {
        S.push_back('e');
    }
    S.push_back('s');

    cout << S << endl;
}

Measured memory_bytes: 3628
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e7+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)


int main()
{
    
    
    int a[5];
    
    rep(i,1,6)
    {
        scf(a[i]);
        
        if(a[i]==0)
        {cout<<i<<endl;
        break;}
        
    }
    
        
 
    
}
   


Measured memory_bytes: 3680
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    public struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        int[] A = LineInt();
        Array.Sort(A);
        double ans = A[0];
        for (int i = 1; i < N; i++) ans = (ans + (A[i] + .0)) / 2.0;
        Console.WriteLine(ans);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <ctime>
#include <sstream>
#define weewoo ios::sync_with_stdio(false);cin.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define se second
#define fi first
#define ctoi(x) (x-'0')
#define pi (acos(-1))
#define llputin(a,n) for(int i=0;i<n;i++){ll x;cin >> x;a.push_back(x);}
#define iputin(a,n) for(int i=0;i<n;i++){int x;cin >> x;a.push_back(x);}

#define MOD ((ll) 1e9 + (ll) 7)
using namespace std;

ll pw(ll x,ll a){
    if(a==0)
        return 1;
    ll t = pw(x,a/2);
    if(a%2==0)
        return (t*t);
    else
        return (t*t*x);
}

bool prime(int x)
{
    if(x < 2) return false;
        for(int i=2; i<= sqrt(x); i++) {
            if ((x%i) == 0) return false;
        }
    return true;
}



int main()
{
    weewoo;string x;
    cin >> x;
    ll ans=0;
    int n = x.size();
    for(int i=0;n-i-1>=0;i++){
        if(x[i]!=x[n-i-1])
            ans++,x[n-i-1]=x[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import Control.Applicative
import Data.List
main = do
    input <- map read . words <$> getLine
    putStrLn $ if check input then "Yes" else "No"

check :: [Int] -> Bool
check [w, h, x, y, r]
    | 0 <= y - r && y + r <= h && 0 <= x - r && x + r <= w = True
    | otherwise = False


Measured memory_bytes: 3664