akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 5555;
int N;
int K;
int P[MAX];
LL C[MAX];

void solve() {
    cin >> N >> K;
    REP(i, N) {
        cin >> P[i];
        P[i]--;
    }
    REP(i, N) {
        cin >> C[i];
    }

    LL ans = -LLINF;
    REP(i, N) {
        VL v;
        {
            int tmp = i;
            do {
                tmp = P[tmp];
                v.EB(C[tmp]);
            } while (tmp != i);
        }

        const auto sum = max(accumulate(ALL(v), 0LL), 0LL);
        LL tail = 0;
        for (int j = 0; j < v.size(); j++) {
           tail += v[j];
            if (K - (j + 1) < 0) break;
           const int nokori = (K - (j + 1)) / v.size();
           chmax<LL>(ans, tail + sum * nokori);
        }
    }

    cout << ans << endl;
}

int main(void) {
#ifndef ONLINE_JUDGE
    const auto in_stream = freopen("../in.txt", "r", stdin);
    if (in_stream == nullptr) {
        cerr << "ERROR!" << endl;
        return 1;
    }
#endif

    solve();

#ifndef ONLINE_JUDGE
    fclose(in_stream);
#endif
}


Measured memory_bytes: 3732
#include<iostream>
#include<vector>
#include <string>

using namespace std;

int main() {
	int N;
	int max=0, sum=0;

	cin >> N;

	vector<int> L(N);

	for (int i = 0; i < N; i++) {
		cin >> L[i];
		sum += L[i];
		if (max < L[i])
			max = L[i];
	}

	if (sum > max * 2)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

}



Measured memory_bytes: 256
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <sstream>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

struct dfs
{
    int i;
    vector<int> &ts;
    vector<int> &tsinv;
    vector<vector<int>> const &adjs;
    void f(int s)
    {
        if (tsinv[s] >= 0)
        {
            return;
        }

        for (auto t : adjs[s])
        {
            f(t);
        }

        ts[i] = s;
        tsinv[s] = i;
        ++i;
        return;
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int n, m;
    cin >> n >> m;
    vector adjs(n, vector<int>());
    rep(i, m)
    {
        int s, t;
        cin >> s >> t;
        --s;
        --t;
        adjs[s].push_back(t);
    }

    vector<int> ts(n, -1), tsinv(n, -1);
    {
        int i = 0;
        auto func = [&](auto self, int s) {
            if (tsinv[s] >= 0)
            {
                return;
            }

            for (auto t : adjs[s])
            {
                self(self, t);
            }

            ts[i] = s;
            tsinv[s] = i;
            ++i;
            return;
        };

        rep(s, n)
        {
            func(func, s);
        }
    }

    vector dp(n, 0);
    int ans = -1;
    rep(i, n)
    {
        int s = ts[i];
        for (auto t : adjs[s])
        {
            int j = tsinv[t];
            chmax(dp[i], dp[j] + 1);
        }

        chmax(ans, dp[i]);
    }

    cout << ans << '\n';

    return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

class UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<int> size;
    vector<vector<int>> group;
public:
    UnionFind(int n = 1) {
        par.resize(n + 1);
        rank.resize(n + 1);
        size.resize(n + 1);
        group.resize(n + 1);
        for (int i = 0; i <= n; ++i) {
            par[i] = i;
            rank[i] = 0;
            size[i] = 1;
            group[i].push_back(i);
        }
    }

    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            int r = find(par[x]);
            return par[x] = r;
        }
    }

    bool is_same(int x, int y) {
        return find(x) == find(y);
    }

    bool unit(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) {
            return false;
        } else {
            if (rank[x] < rank[y]) {
                swap(x, y);
            }
            if (rank[x] == rank[y]) {
                ++rank[x];
            }
            par[y] = x;
            size[x] += size[y];
            return true;
        }
    }

    int get_size(int x) {
        return size[find(x)];
    }

    void merge(int x, int y) {
        x = find(x);
        y = find(y);
        if (group[x].size() > group[y].size()) {
            swap(x, y);
        }
        copy(group[y].begin(), group[y].end(), back_inserter(group[x]));
        group[y].clear();
        par[y] = x;
    }
};

void Main() {
    ll N, M;
    cin >> N >> M;
    vector<P> items(M);
    rep(i, M) {
        ll u, v;
        cin >> u >> v;
        u--;
        v--;
        items[i] = make_pair(u, v);
    }
    UnionFind unionFind(N);
    vector<ll> ans;
    reverse(items.begin(), items.end());
    rep(i, M) {
        P p = items[i];
        ll u = p.first;
        ll v = p.second;
        ll a = unionFind.get_size(u);
        ll b = unionFind.get_size(v);
        if (unionFind.unit(u, v)) {
            ans.push_back(a * b);
        }else {
            ans.push_back(0);
        }
    }
    reverse(ans.begin(), ans.end());
    ll s = 0;
    rep(i, M) {
        s += ans[i];
        cout << s << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 10484
#include <stdio.h>

int main()
{
	char A[200001];
	scanf("%s", A);
	
	int i, j, k, rest[200001], count[26] = {}, num = 0;
	char ans[10000] = {};
	for (i = 0; A[i] != 0; i++);
	for (rest[i--] = -1, k = 0; i >= 0; i--) {
		rest[i] = k;
		if (count[A[i] - 'a'] == 0) num++;
		count[A[i] - 'a']++;
		if (num == 26) for (j = 0, num = 0, k++; j < 26; j++) count[j] = 0;
	}
	
	int l = 0;
	while (1) {
		for (j = 0; j < 26; j++) count[j] = 0;
		for (i++; rest[i] == k; i++) count[A[i] - 'a']++;
		for (j = 0; j < 26; j++) if (count[j] == 0) break;
		ans[l++] = 'a' + j;
		for (k--; A[i] != 0 && A[i] != 'a' + j; i++);
		if (A[i] == 0) break;
	}
	
	printf("%s\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2624
s = input()
S = []
xid = [0] * (10 ** 5 + 1)
xcnt = 0
for c in s:
    if c != "x":
        S.append(c)
        xcnt += 1
    else:
        xid[xcnt] += 1
xid = xid[:xcnt + 1]
ans = 0
if S[0:xcnt // 2] == S[-1:-(xcnt // 2) - 1:-1]:
    for i in range(-(-xcnt // 2)):
        ad = xid[i] - xid[xcnt - i]
        if ad < 0:
            ad = -ad
        ans += ad
    print(ans)
else:
    print(-1)

Measured memory_bytes: 5620
n, m = input().split(" ")
n, m = int(n), int(m)
a = [int(i) for i in input().split(" ")]
vote = sum(a)
voted4 = vote / (4 * m)
a = sorted(a, reverse=True)
ans = 0
for i in a:
    if (i >= voted4):
        ans += 1
    else:
        break
if (ans >= m):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
/*
 * Author: Kewth

 * Date:
  echo -n '  ' && date +%Y.%m.%d # Type "!!sh" in Vim.

 * Solution:
  To be updated after "Accept".

 * Digression:

 * CopyRight:
   __  __                  __   __
  |  |/  |.-----.--.--.--.|  |_|  |--.
  |     < |  -__|  |  |  ||   _|     |
  |__|\__||_____|________||____|__|__|

 */

#include <cstdio>
#include <queue>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

static struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator () (a...); }
} read;

const int Maxn = 55;
char str[Maxn][Maxn];
int id1[Maxn][Maxn], id2[Maxn][Maxn], ip;
bool mvis[Maxn][Maxn];

const int maxn = 2605, maxm = 252605;
int head[maxn], nxt[maxm << 1], to[maxm << 1], cap[maxm << 1], cost[maxm << 1], hp = 1;

inline void add(int u, int v, int ca, int co) {
	if((hp & 1) and !ca) return;
	nxt[++ hp] = head[u];
	head[u] = hp;
	to[hp] = v;
	cap[hp] = ca;
	cost[hp] = co;
	if(!(hp & 1)) add(v, u, 0, - co);
}

ll dis[maxn];
bool inq[maxn], vis[maxn];
int from[maxn];
bool spfa(int s, int t) {
	std::queue<int> q;
	std::fill(dis, dis + t + 1, 1000000000000000000);
	std::fill(inq, inq + t + 1, 0);
	dis[s] = 0;
	q.push(s);
	while(!q.empty()) {
		int u = q.front();
		vis[u] = 1;
		q.pop();
		inq[u] = 0;
		for(int i = head[u]; i; i = nxt[i])
			if(cap[i] and dis[u] + cost[i] < dis[to[i]]) {
				dis[to[i]] = dis[u] + cost[i];
				from[to[i]] = i ^ 1;
				if(!inq[to[i]]) {
					q.push(to[i]);
					inq[to[i]] = 1;
				}
			}
	}
	return dis[t] < 1000000000000000000;
}

ll mincostmaxflow(int s, int t) {
	ll res = 0;
	while(spfa(s, t)) {
		int flow = cap[from[t] ^ 1];
		ll sum = cost[from[t] ^ 1];
		for(int u = to[from[t]]; u != s; u = to[from[u]]) {
			flow = std::min(flow, cap[from[u] ^ 1]);
			sum += cost[from[u] ^ 1];
		}
		cap[from[t] ^ 1] -= flow;
		cap[from[t]] += flow;
		for(int u = to[from[t]]; u != s; u = to[from[u]]) {
			cap[from[u] ^ 1] -= flow;
			cap[from[u]] += flow;
		}
		res += sum * flow;
	}
	return res;
}

void link (int x, int y, int i, int j) {
	if (mvis[i][j] or str[i][j] == '#' or !str[i][j]) return;
	mvis[i][j] = 1;
	add(id1[x][y], id2[i][j], 1, x + y - i - j);
	/* debug("%d %d %d %d\n", x, y, i, j); */
	link(x, y, i + 1, j);
	link(x, y, i, j + 1);
}

int main () {
	int n = read, m = read;
	for (int i = 1; i <= n; i ++)
		scanf("%s", str[i] + 1);
	for (int i = 1; i <= n; i ++)
		for (int j = 1; j <= m; j ++) {
			if (str[i][j] == 'o')
				id1[i][j] = ++ ip;
			if (str[i][j] != '#')
				id2[i][j] = ++ ip;
		}
	int S = ++ ip, T = ++ ip;
	for (int i = 1; i <= n; i ++)
		for (int j = 1; j <= m; j ++) {
			if (str[i][j] == 'o') {
				add(S, id1[i][j], 1, 0);
				link(i, j, i, j);
				for (int ii = 1; ii <= n; ii ++)
					for (int jj = 1; jj <= m; jj ++)
						mvis[ii][jj] = 0;
			}
			if (str[i][j] != '#')
				add(id2[i][j], T, 1, 0);
		}
	printf("%lld\n", - mincostmaxflow(S, T));
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VL a(n);
	rep(i, n) cin >>a[i];
	VL z(n+1);
	auto f=[&](ll md){
		z[0] = md;
		rep(i, n) z[i+1] = a[i] *2 - z[i];
		return md - z[n];
	};
	
	ll hi = 2*MD, lw=-1;
	while(hi - lw >1){
		ll md = (hi + lw) >>1, df = f(md);
		if(df == 0){
			rep(i, n) cout << z[i] <<" "; cout<<"\n";
			break;
		}
		(df > 0? hi: lw) = md;
	}
	return 0;
}


Measured memory_bytes: 2944
N=int(input())

data=[]

for _ in range(N):
    x,y,h=map(int,input().split())
    data.append([x,y,h])
 
def test():
    for cx in range(101):
        for cy in range(101):
            
            for i in range(N):
                if data[i][2]:
                    temph=data[i][2]+abs(data[i][0]-cx)+abs(data[i][1]-cy)
                    flag=True
            
            for d in data:
                if d[2] != max(temph-abs(d[0]-cx)-abs(d[1]-cy),0):
                    flag=False
                    break
                
            if flag:
                print(cx,cy,temph)
                return
            
test()

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#define M 1000000
#define L 12
#define NIL -1
 
char A[M][L];
 
int getChar(char c){
  if(c == 'A') return 1;
  else if(c == 'C') return 2;
  else if(c == 'G') return 3;
  else if(c == 'T') return 4;
}
 
int getKey(char str[]){
  int sum=0,p=1,i;
  for(i=0;i<strlen(str);i++){
    sum+=p*(getChar(str[i]));
    p*=5;
  }
  return sum;
}
 
int h1(int key){return key % M;}
int h2(int key){return 1 + (key%(M-1));}
 
int find(char str[]){
  int i,h,key;
  key = getKey(str);
 
  for(i=0;;i++){
    h = (h1(key) + i*h2(key)) % M;
    if(strcmp(A[h],str) == 0) return 1;
    else if(strlen(A[h]) == 0) return 0;
  }
  return 0;
}
 
int insert(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i=0 ; ; i++){
    h = (h1(key) + i*h2(key)) % M;
    if(strcmp(A[h],str) == 0) return 1;
    else if(strlen(A[h]) == 0){
      strcpy(A[h], str);
      return 0;
    }
  }
  return 0;
}
 
int main(){
  int i,n,h;
  char str[L], ch[9];
 
  scanf("%d", &n);
  for (i=0 ; i<n ; i++){A[i][0]='\0';}
  for (i=0 ; i<n ; i++){
    scanf("%s %s",ch,str);
    if (ch[0] == 'i'){insert(str);}
    else {
      if(find(str)){printf("yes\n");}
      else {printf("no\n");}
    }
  }
  return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

vector<int> v;

void solve() {
  int n, k; scanf("%d %d", &n, &k);
  char state; scanf(" %c", &state);
  int count = 1;
  v.push_back(0);
  for (int i = 1; i < n; ++i) {
    char c; scanf(" %c", &c);
    if (state == c) {
      ++count;
    } else {
      v.push_back(count+v.back());
      count = 1;
      state = c;
    }
  }
  state -= '0';
  if (v.size()%2 == 0) state = !state;
  v.push_back(count+v.back());
  int ans = 0;
  for (int i = 1; i <= (int)v.size()-2*k; ++i) {
    state = !state;
    ans = max(ans, v[min((int)v.size()-1, i+2*k-state)]-v[i-1]);
  }
  if (ans == 0) ans = n;
  printf("%d", ans);
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3944
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define test() ull t;cin>>t;while(t--)
#define pll pair<ll,ll>
#define puu pair<ull,ull>
#define f first
#define s second
#define pb push_back
#define mkp make_pair
#define ins insert
#define Vint vector<int>
#define Vll vector<ll>
#define Vull vector<ull>
#define nl cout<<endl
#define sp cout<<" "
#define MOD 1000000007
#define all(x) x.begin(),x.end()
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};


int main() 
{
	// ios::sync_with_stdio(0);
	// cin.tie(0);
	// cout.tie(0);
	
	ll n,W;
	cin>>n>>W;
	vector<ll> w(n),v(n);
	loop(i,0,n)
		cin>>w[i]>>v[i];

	ll dp[n+1][W+1];

	memset(dp,0,sizeof(dp));

	loop(i,1,n+1){
		loop(j,1,W+1){
			dp[i][j] = dp[i-1][j];
			if(j>=w[i-1])
				dp[i][j] = max(dp[i-1][j-w[i-1]] + v[i-1],dp[i][j]);
		}
	}

	ll ans = 0;

	loop(i,1,n+1)
		ans = max(ans,dp[i][W]);

	cout<<ans;
}

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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;

int main(){
    ll n,m; cin>>n>>m;
    vector<ll> h(n);
    vector<bool> good(n);
    rep(i,n){
        cin>>h[i];
        good[i]=true;
    }
    rep(i,m){
        ll a,b; cin>>a>>b;
        a--; b--;
        if(h[a]==h[b]){
            good[a]=false; good[b]=false;
        }else if(h[a]>h[b]) good[b]=false;
        else good[a]=false;
    }
    ll ans = 0;
    rep(i,n) if(good[i]) ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 3988
a=-1,A=65,d;
char
*N="GKSOCNWLDFVTBRXHAJUPEMQI",
*E="PHLTIDOXQAGWECSUMBKVJFNR",
*R="BCDAFGHEJKLINOPMRSTQVWXU",
s[9];
main(c)
{
for(;c-48&&scanf("%s",s);a+=d/4+1)
{
(c=*s)<A?~a&&printf("%d\n",a),a=d=0:0;
d=c==78?d=N[d]-A:
c==69?d=E[d]-A:d;
if(c==82)d=R[d]-A;
if(c==83)d=N[N[N[d]-A]-A]-A;
if(c==87)d=E[E[E[d]-A]-A]-A;
if(c==76)d=R[R[R[d]-A]-A]-A;
}}

Measured memory_bytes: 0
use std::io;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let mut it = buf.split_whitespace().map(|n| usize::from_str(n).unwrap());
    let (a, b) = (it.next().unwrap(), it.next().unwrap());
    let ans = if a * b % 2 == 0 { "Even" } else { "Odd" };
    println!("{}", ans);
}



Measured memory_bytes: 4352
#include<stdio.h>
#include<algorithm>
using namespace std;
int t[6];
int perm[6];
int u[6];
int dice[6];
void rN(){
	int tmp=dice[0];dice[0]=dice[1];dice[1]=dice[5];dice[5]=dice[4];dice[4]=tmp;
}
void rS(){
	int tmp=dice[0];dice[0]=dice[4];dice[4]=dice[5];dice[5]=dice[1];dice[1]=tmp;
}
void rE(){
	int tmp=dice[0];dice[0]=dice[3];dice[3]=dice[5];dice[5]=dice[2];dice[2]=tmp;
}
void rW(){
	int tmp=dice[0];dice[0]=dice[2];dice[2]=dice[5];dice[5]=dice[3];dice[3]=tmp;
}
char ret[40000];
int chk(){
	for(int i=0;i<6;i++)perm[i]=i;
	do{
		bool ok=true;
		for(int i=0;i<6;i++)if(u[i]>t[perm[i]])ok=false;
		int A=t[perm[dice[0]]]+t[perm[dice[5]]]-u[dice[0]]-u[dice[5]];
		int B=t[perm[dice[1]]]+t[perm[dice[4]]]-u[dice[1]]-u[dice[4]];
		int C=t[perm[dice[2]]]+t[perm[dice[3]]]-u[dice[2]]-u[dice[3]];
		if(B+C<A||A+C+1<B||A+B+1<C)ok=false;
		if(ok)return 1;
	}while(next_permutation(perm,perm+6));
	return 0;
}
int main(){
	while(1){
		for(int i=0;i<6;i++)scanf("%d",t+i);
		int n=0;
		for(int i=0;i<6;i++)n+=t[i];
		if(n==0)break;
		int p,q;scanf("%d%d",&p,&q);p--;
		for(int i=0;i<6;i++)u[i]=0;
		for(int i=0;i<6;i++)dice[i]=i;
		if(chk()==0){
			printf("impossible\n");continue;
		}
		for(int i=0;i<n;i++){
			rE();u[dice[5]]++;
			if(chk()){ret[i]='E';continue;}
			u[dice[5]]--;rW();
			rN();u[dice[5]]++;
			if(chk()){ret[i]='N';continue;}
			u[dice[5]]--;rS();
			rS();u[dice[5]]++;
			if(chk()){ret[i]='S';continue;}
			u[dice[5]]--;rN();
			rW();u[dice[5]]++;
			ret[i]='W';
		}
		for(int i=p;i<q;i++)printf("%c",ret[i]);printf("\n");
	}
}

Measured memory_bytes: 1048
#include <stdio.h>

int main(){
	int a,t;
	long long int sum=0;
	scanf("%d",&a);
	for(int i=0;i<=a;i++){
		if(i%3!=0&&i%5!=0){
			sum+=i;
	}			
}
	printf("%lld",sum);
	return 0;
}

Measured memory_bytes: 1688
#include <bits/stdc++.h>
using namespace std;
int a, b, c, d;
string weigh(int left, int right) {
    if (left == right) {
        return "Balanced";
    }
    return (left > right ? "Left" : "Right");
}
int main() {
    cin >> a >> b >> c >> d;
    cout << weigh(a + b, c + d) << endl;
    return 0;
}


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

set<int> s;

int main() {
	int n;
	scanf("%d", &n);
	for(int i = 0, val; i < n; ++i) {
		scanf("%d", &val);
		s.insert(val);
	}
	printf("%d\n", (int) s.size());
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = 0;
        String c = sc.next();
        for (int i = 0; i < 4;++i){
            k += c.charAt(i) == '+' ? 1 : -1;
        }
        System.out.println(k);
    }

}


Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  vector<string> s(3);
  for(ll i=0;i<3;i++) cin >> s[i];
  for(ll i=0;i<3;i++) cout << s[i][i];
  cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<map>
int main() {
	int N;
	std::vector<std::string> Wx;
	std::cin >> N ;
	Wx.resize(N);
	std::map<std::string, int> kmap;
	for (int i = 0; i < N; i++) {
		std::cin >> Wx[i];
		if ( kmap[Wx[i]] == NULL )
		{ kmap[Wx[i]] = 1; }
		else {
			std::cout << "No" << std::endl;
			return 0;
		}
	}	
	std::string answer = "Yes";
	for (int i = 0; i < N-1; i++) {
		std::string tmpx = Wx[i];
		std::string tmpy = Wx[i+ 1];
		if (tmpx.back() != tmpy.front()) {
			answer = "No";
			break;
		}
	}
	std::cout << answer.c_str() << std::endl;


	return 0;
}

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int64_t n;
  cin >> n;
  
  int64_t total = 0;
  for(int64_t i=1; i<n+1;i++){
    if(i%3==0)continue;
    if(i%5==0)continue;
    total += i;
  }
  cout << total << endl;
  
  return 0;
}



Measured memory_bytes: 3648
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

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


int x, y, s;

int comi(int x, int p){
	return x*(100+p)/100;
}

int main(){
	ios::sync_with_stdio(false);
	while(cin >> x >> y >> s, x){
		int ans = 0;
		REPS(i, s-1)REPS(j, s-1){
			if(comi(i, x) + comi(j, x) == s) ans = max(ans, comi(i, y) + comi(j, y));
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    lb = rli()
    ans = lb[0]+lb[-1]
    for i in range(1,n-1):
        ans += min(lb[i-1],lb[i])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<cstdlib>
using namespace std;
typedef long long ll;
//bool comp(ll a, ll b)
//{
  //  return (a < b);
//}
int main(){

ll n,i,j,k,ans=0;
vector <ll> v,dp;
cin>>n>>k;
for(i=0;i<n;i++){
    cin>>j;
    v.push_back(j);
}
for(i=0;i<n;i++){
        vector<ll> a;
 if(i==0)
   dp.push_back(0);
  else if(i<k){
    for(j=0;j<i;j++)
        a.push_back(abs(v[i]-v[j])+dp[j]);
    dp.push_back(*min_element(a.begin(), a.end()));

  }
   else{
    for(j=i-k;j<i;j++)
        a.push_back(abs(v[i]-v[j])+dp[j]);
        dp.push_back(*min_element(a.begin(), a.end()));

   }
}

cout<<dp[n-1]<<endl;

return 0;
}


Measured memory_bytes: 2548
import java.util.Scanner;

public class Main {

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

        int N = Input.nextInt();
        String S = Input.next();

        int V = 0;
        int Max = 0;
        for (int I = 0; I < N; I++) {
            if (S.charAt(I) == 'I') {
                V++;
            }
            if (V > Max) {
                Max = V;
            }
            if (S.charAt(I) == 'D') {
                V--;
            }

        }
        System.out.println(Max);
    }
}


Measured memory_bytes: 21844
n=gets.to_i
a=gets.split.map(&:to_i).sort.reverse
s=[0]*n

s[0]=1
res=a[0]
i=1
k=2
while k<n
    if s[i]<2
        res+=a[i]
        s[i]+=1
        k+=1
    else
        i+=1
    end
end
puts res


Measured memory_bytes: 32668
/*    ####################  */
/*   # I_LOVE_THUY_LINH #  */
/*  ####################  */
#include <bits/stdc++.h>
#define ll long long
#define db double
#define ld long double
#define ii pair<int,int>
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define matrix vector<vector<ll>>
#define fir first
#define sec second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define sz(a) int((a).size())
#define ms(s,val) memset(s,val,sizeof(s))
#define bitcount(n) __builtin_popcountll(n)
#define getbit(s,k) ((s >> k)&1)
#define turnbit(s,k) (s | (1<<k))
#define offbit(s,k) (s & ~(1<<k))
#define flipbit(s,k) (s ^ (1<<k))
#define prec(n) fixed<<setprecision(n)
#define sqr(x) (ll)(x)*(ll)(x)
#define lcm(a,b) ((ll)a/__gcd((ll)a,(ll)b)*(ll)(b))
#define gcd(a,b) __gcd(a,b)
using namespace std;
const int INF = int(1e9);
ll n;

ll f(ll x){
    if (x == 1) return 1;
    return 2LL*f(x/2) + 1LL;
}
int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    cout << f(n);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    char s[17], r[17]={"CODEFESTIVAL2016"};
    int cnt=0, i;

    scanf("%s", s);

    for(i=0; i<16; i++){
        if(s[i] != r[i])
            cnt++;
    }

    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 128
while True:
    h,w = map(int,input().split())
    if h==0 and w==0:
        break
    for i in range(h):
        for j in range(w):
           if (i+j)%2==0:
               print('#',end='')
           else:
               print('.',end='')
        print()
    print()


Measured memory_bytes: 7000
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846;

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;

ll can_div_count(ll n){
    ll count = 0;
    while(n > 1){
        n = n/2;
        count++;
    }
    return count;
}


int main(void){
    FAST_IO
    
    ll h;
    cin >> h;
    ll n = can_div_count(h);
    ll ans = 1;
    rep(i,n+1){
        ans *= 2;
    }
    cout << ans-1<< endl;
    
    return 0;
}

Measured memory_bytes: 3184
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	int nCount = 0, n50, n100, n500,iSum;
	register int i, j;
	cin >> n500 >> n100 >> n50 >> iSum;
	for (i = 0; i <= n500; ++i){
		if (500 * i > iSum)
			break;
		for (j = 0; j <= n100; ++j){
			if (500 * i + 100 * j > iSum)
				break;
			if ((iSum - j * 100 - i * 500) / 50 <= n50){
				++nCount;
			}
		}
	}
	cout << nCount<<endl;
endapp:
	//system("pause > nul");
	return 0;
}

Measured memory_bytes: 256
import math
n = int(input())
l = 0

xi = []
yi = []
for i in range(n):
    x, y = map(int, input().split())
    xi.append(x)
    yi.append(y)

for j in range(n):
    for k in range(n):
        if j >= k:
            continue
        l += math.sqrt((xi[j]-xi[k])**2 + (yi[j]-yi[k])**2)

print(l*2/n)


Measured memory_bytes: 38384
using System;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadLine[0];
            var d = new Dictionary<char, char>() { { 'A', 'T' }, { 'T', 'A' }, { 'G', 'C' }, { 'C', 'G' } };
            Console.WriteLine(d[n]);

        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public double[] ReadDoubleArray(long N) { var ret = new double[N]; for (long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
    }
}



Measured memory_bytes: 13268
using System;

namespace Volume0_0000
{
	class Program
	{
		static void Main(string[] args)
		{
			for(int i = 1; i <= 9; i++) {
				for(int j = 1; j <= 9; j++) {
					Console.WriteLine($"{i}x{j}={i * j}");
				}
			}
		}
	}
}



Measured memory_bytes: 15808
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <immintrin.h>
# include <cassert>
# include <array>
# include <tuple>
# include <unordered_map>
# include <unordered_set>
# include <thread>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ui32 = unsigned int;
constexpr ll INFLL = 1e18;

#define CHECK_IMPL1(cond)              \
if (!(cond)) {                         \
    DEBUG("expected cond: " << #cond); \
    assert(cond);                      \
}

#define CHECK_IMPL2(cond, message)                                            \
if (!(cond)) {                                                                \
    DEBUG("expected cond: " << #cond << " failed with message: " << message); \
    assert(cond);                                                             \
}
#define CHECK_IMPL(_1, _2, NAME, ...) NAME
#define CHECK(...) CHECK_IMPL(__VA_ARGS__, CHECK_IMPL2, CHECK_IMPL1, CHECK_IMPL0)(__VA_ARGS__)

#ifdef __APPLE__
#define DEBUG(message) std::cerr << message << std::endl;
#else
#define DEBUG(message)
#endif

void solve() {
  string s;
  cin >> s;
  int n = (int)s.size();
  vector<bool> dp(n + 1, false);
  dp[0] = true;
  vector<string> words = {
      "dream",
      "dreamer",
      "erase",
      "eraser"
  };
  for (auto& w : words) {
    reverse(w.begin(), w.end());
  }
  for (int i = 0; i < n; i++) {
    for (auto& w : words) {
      int m = (int)w.size();
      if (i - m + 1 < 0 || !dp[i - m + 1]) {
        continue;
      }
      bool ok = true;
      for (int k = 0; k < m; k++) {
        if (s[i - k] != w[k]) {
          ok = false;
          break;
        }
      }
      if (ok) {
        dp[i + 1] = true;
        break;
      }
    }
//    cout << i << " " << dp[i] << endl;
  }
  if (dp[n]) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
#ifdef __APPLE__
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
#endif
  int t = 1;
//  cin >> t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}


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

int main(void){
    int n;
    long int *a;

    long int money = 1000;

    int i;



    scanf("%d", &n);


    a = (long int*)malloc(sizeof(long int) * n);

    for(i = 0; i < n; i++){
        scanf("%ld", a + i);
    }


    for(i = 0; i < n - 1; i++){
        if(a[i] < a[i + 1]){
            long int number = money / a[i];

            money += (a[i + 1] - a[i]) * number;

        }
    }
    printf("%ld\n", money);


    free(a);

    return 0;
}


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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define int ll

main()
{
  while(1){
    int h,w; cin >> h >> w; if(h == 0) break;
    int s = h*h + w*w;
    bool f = false;
    FOR(i,h+1,sqrt(s)+1){
      int tmp = sqrt(s-i*i);
      if(tmp == 0 or i >= tmp) continue;
      if(s-i*i == tmp * tmp){
	cout << i << " " << tmp << endl;
	f = true;
      }
      if(f) break;
    }
    if(f) continue;
    f = false;
    while(1){
      s++;
      FOR(i,1,sqrt(s)+1){
	int tmp = sqrt(s-i*i);
	if(tmp == 0 or i >= tmp) continue;
	if(s-i*i == tmp * tmp){
	  cout << i << " " << tmp << endl;
	  f = true;
	}
	if(f) break;
      }
      if(f) break;
    }
  }
}



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

using namespace std;

int main() {
    int n, m;
    while (cin >> n >> m) {
        if ((n | m) == 0) break;
        int p[n];
        fill(p, p + n, 0);
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                int p_;
                cin >> p_;
                p[j] += p_;
            }
        }
        cout << *max_element(p, p + n) << endl;
    }
}


Measured memory_bytes: 3132
a,b,c=map(int,input().split())

if a<=b<=c:
    print(a,b,c)
elif a<=c<=b:
    print(a,c,b)
elif b<=a<=c:
    print(b,a,c)
elif b<=c<=a:
    print(b,c,a)
elif c<=a<=b:
    print(c,a,b)
elif c<=b<=a:
    print(c,b,a)

    


Measured memory_bytes: 5592
#include <iostream>
#include <string>
#include<algorithm>
using namespace std;
 
int main() {
    string a,b;
    int c=0,d=0;
 
    while(cin>>a>>b){
        if(a=="0"&&b=="0"){
        	break;
        }	
        for(int i=0;i<4;i++){
            if(a[i]==b[i]){
            	c++;
            }	
        }
         
        for(int j=0;j<4;j++){
            for(int k=0;k<4;k++){
                if(j!=k&&a[j]==b[k]){
                	d++;
                }	
            }
        }
        
        cout<<c<<" "<<d<<endl;
        c=0;
        d=0;
        }
     
     
    return 0;
}

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

int main() {
	int H, W, N; cin >> H >> W >> N;
	int r, c; cin >> r >> c;
	string S, T; cin >> S >> T;
	int uj=1, dj=H, lj=1, rj=W;
	bool flag=true;
	for(int i=N-1; i>=0; --i){
	    if(T[i]=='U') if(dj<H) ++dj;
	    if(T[i]=='D') if(uj>1) --uj;
	    if(T[i]=='L') if(rj<W) ++rj;
	    if(T[i]=='R') if(lj>1) --lj;
	    if(S[i]=='U') ++uj;
	    if(S[i]=='D') --dj;
	    if(S[i]=='L') ++lj;
	    if(S[i]=='R') --rj;
	    flag=(flag && uj<=dj && lj<=rj);
	    // cout << uj << ' ' << dj << ' ' << lj << ' ' << rj << endl;
	}
	if(uj<=r && r<=dj && lj<=c && c<=rj && flag) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    vector<string> b(m);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < m; ++i)
        cin >> b[i];

    for (int i = 0; i + m - 1 < n; ++i) {
        for (int j = 0; j + m - 1 < n; ++j) {
            int ok = 1;
            for (int k = 0; k < m; ++k) {
                for (int l = 0; l < m; ++l) {
                    if (a[i + k][j + l] != b[k][l]) {
                        ok = 0;
                        break;
                    }
                }
            }
            if (ok) {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll x,y,z;cin>>x>>y>>z;
  swap(x,y);
  swap(x,z);
  cout<<x spa y spa z<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>

class PrimeNumbers{
private:
    std::vector<int> dataSet;
    bool isPrimeNumber(int x);
public:
    PrimeNumbers(std::vector<int> vec);
    int getPrimeCount();
};

PrimeNumbers::PrimeNumbers(std::vector<int> vec){
    this->dataSet = vec;
}

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

int PrimeNumbers::getPrimeCount(){
    int returnCount = 0;
    for(int i : dataSet){
        if(isPrimeNumber(i)){
            returnCount++;
        }
    }
    return returnCount;
}

int main(){

    int loop;

    std::cin >> loop;

    int input;
    std::vector<int> vec;

    for(int i = 0;i < loop;i++){
        std::cin >> input ;
        vec.push_back(input);
    }

    PrimeNumbers pn = PrimeNumbers(vec);
    std::cout << pn.getPrimeCount() << std::endl;

    return 0;
}

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

using namespace std;
 
int main () {
  int n;
  cin >> n;
  int a [n];
  int i, j, k, temp;
  for (i = 0; i < n; i++) {
    cin >> a [i];
  }
  cout << a [0];
  for (k = 1; k < n; k++) {
      cout << " " << a [k];
  }
  cout << endl;

  for (i = 1; i < n; i++) {
    temp = a [i];
    j = i - 1;
    while (j >= 0 && a [j] > temp) {
      a [j + 1] = a [j];
      j--;
    }
    a [j + 1] = temp;

  cout << a [0];
  for (k = 1; k < n; k++) {
      cout << " " << a [k];
  }
  cout << endl;
  }

  return 0;
}

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

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

  sort(S.begin(), S.end());
  if(S[0] == S[1] && S[2] == S[3] && S[0] != S[2]){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	h, w := nextInt(), nextInt()
	c := make([][]int, 10)
	for i := range c {
		c[i] = nextInts(10)
	}

	for k := 0; k < 10; k++ {
		for i := 0; i < 10; i++ {
			for j := 0; j < 10; j++ {
				c[i][j] = min(c[i][j], c[i][k]+c[k][j])
			}
		}
	}

	ans := 0
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			a := nextInt()
			if a != -1 {
				ans += c[a][1]
			}
		}
	}
	puts(ans)
}


Measured memory_bytes: 768