akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

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;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	rep(i,1e9){
		if(i%2==0){
			c-=b;
			if(c<=0){
				cout<<"Yes"<<endl;
				return 0;
			}
		}else{
			a-=d;
			if(a<=0){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
}

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

int counter(int num);

int n;
vector<int> a(20);
vector<vector<int>> x(20, vector<int>(20));
vector<vector<int>> y(20, vector<int>(20));

int main(){
    cin >> n;
    int i, j;
//    for (i = 1; i <= n; i++){
    for (i = 0; i < n; i++){
        cin >> a.at(i);
//        for (j = 1; j <= a.at(i); j++){
        for (j = 0; j < a.at(i); j++){
            cin >> x.at(i).at(j) >> y.at(i).at(j);
        }
    }
    int bits;
    int ans = 0;    
    for (bits = 0; bits < (1 << n); bits++){
        bool flg = true;
//        for (i = 1; i <= n; i++){
        for (i = 0; i < n; i++){
//            if( !(bits & (1 << (i-1)))){
            if( !(bits & (1 << (i)))){
                continue;
            }
//            for (j = 1; j <= a.at(i); j++){
            for (j = 0; j < a.at(i); j++){
                if (((bits >> (x.at(i).at(j)-1)) & 1) ^ (y.at(i).at(j)) ){
//                if (((bits >> (x.at(i).at(j))) & 1) ^ (y.at(i).at(j)) ){
                    flg = false;
                }
            }
        }
        if (flg == true){
            ans = max(ans, counter(bits));
        }
    }
    cout << ans << endl;
    return 0;
}

int counter(int num){
    //  数値が全部0であれば再帰終了
    if (num == 0){
        return 0;
    }
    //  LSBと1でand演算、1であればカウント
    //  右ビットシフトして再帰
    return counter(num >> 1) + (num & 1);
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>//sort
#include <vector>
#include <string>
#include <map>//pair
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
  long long N, A, B;
  cin >> N >> A >> B;
  long long ans =A * (N / (A + B));
  //ans *= A;
  long long diff = N % (A + B);
  ans += min(diff, A);
  cout << ans << endl;
}


Measured memory_bytes: 256
// f-pure.yml
#include "bits/stdc++.h"
using namespace std;

// Defines
#define pb push_back
#define mpr make_pair
#define mtp make_tuple
#define all(x) (x).begin(), (x).end()
// Basic type definitions
using ll = long long; using ull = unsigned long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<long long, long long>;
// PBDS order statistic tree
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds; 
template <typename T, class comp = less<T>> using os_tree = tree<T, null_type, comp, rb_tree_tag, tree_order_statistics_node_update>;
template <typename K, typename V, class comp = less<K>> using treemap = tree<K, V, comp, rb_tree_tag, tree_order_statistics_node_update>;
// HashSet
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash { ll operator()(ll x) const { return x ^ RANDOM; } };
template <typename T, class Hash> using hashset = gp_hash_table<T, null_type, Hash>;
template <typename K, typename V, class Hash> using hashmap = gp_hash_table<K, V, Hash>;
// More utilities
template <typename C> int SZ(C &v) { return v.size(); }
template <typename T, typename U> void maxa(T &a, U b) { a = max(a, b); }
template <typename T, typename U> void mina(T &a, U b) { a = min(a, b); }
const ll INF = 0x3f3f3f3f, LLINF = 0x3f3f3f3f3f3f3f3f;

const int MN = 1001, MM = 2001;
int N, M,
    A[MM], B[MM];
vector<int> g[MN];

int len = INF;
vector<int> ans;
int dis[MN], par[MN];

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

    cin >> (N) >> (M);
    for (auto i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        g[a].pb(b);
        A[i] = a; B[i] = b;
    }

    for (auto i = 0; i < M; i++) {
        memset(dis, 0x3f, sizeof dis);
        queue<int> q;
        q.push(B[i]); dis[B[i]] = 0; par[B[i]] = -1;
        while (!q.empty()) {
            int c = q.front(), cdis = dis[c]; q.pop();
            for (int to : g[c]) {
                if (dis[to] == INF) {
                    dis[to] = cdis + 1;
                    par[to] = c;
                    q.push(to);
                }
            }
        }
        if (dis[A[i]] + 1 < len) {
            len = dis[A[i]] + 1;
            ans.clear();
            for (int c = A[i]; c != -1; c = par[c])
                ans.pb(c);
        }
    }

    if (len == INF)
        cout << (-1) << '\n';
    else {
        cout << (len) << '\n';
        for (auto x : ans)
            cout << (x) << '\n';
    }

    return 0;
}



Measured memory_bytes: 3744
#include <climits>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <vector>
using namespace std;

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

constexpr int MAX_N = 100;

int n, m;
map<int, int> G[MAX_N];

int base;
int ans = -1;

void calc(const vector<int> &nodes) {
	const int V = nodes.size();

	vector<int> idx(n, -1);
	for(int i = 0; i < V; ++i) {
		idx[nodes[i]] = i;
	}

	for(int bit = 0; bit < (1 << V); ++bit) {
		int sum = 0;

		for(int i = 0; i < V; ++i) {
			if(bit & (1 << i)) continue;

			int score = INT_MAX;
			const int v = nodes[i];

			for(int j = 0; j < V; ++j) {
				if(i == j || (bit & (1 << j))) continue;

				const int u = nodes[j];
				if(!G[u].count(v)) goto ng;
				chmin(score, G[u][v]);
			}

			if(score != INT_MAX) sum += score;
		}
	 
		chmax(ans, sum);
	ng:;
	}
}

void dfs(int v = 0) {
	if(v == n) return;

	if(static_cast<int>(G[v].size()) <= base) {
		vector<int> nodes(G[v].size() + 1);

		auto it = G[v].cbegin();
		for(int i = 0; it != G[v].cend(); ++i, ++it) {
			nodes[i] = it->first;
		}
		nodes.back() = v;
		calc(nodes);
	}
	dfs(v + 1);
}

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

	cin >> n >> m;

	base = sqrt(2 * m);

	for(int i = 0; i < m; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		--a; --b;
		G[a].insert({b, c});
		G[b].insert({a, c});
	}

	dfs();

	if(ans == -1) {
		vector<int> nodes(n);
		iota(nodes.begin(), nodes.end(), 0);
		calc(nodes);
	}

	cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1220
#include<iostream>
using namespace std;
int main(){
	int n, h, pre, ans;
	pre = ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> h;
		if(pre <= h){
			ans++;
			pre = h;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const int M = 1e9+7;
const int INF = 1<<30;

int _;
char s[200005];

ll gcd(ll a,ll b) {return b==0?a:gcd(b,a%b);}
ll qpow(ll a,ll b) {ll s=1;while(b){if(b&1)s=(s*a)%M;b>>=1;a=(a*a)%M;}return s;}



int main()
{
    int n,k,c;
    cin>>n>>k>>c>>s+1;
    int last = -1;
    vector<int> v;
    for(int i=1;i<=n;i++)
    {
        if(s[i]=='o' && (last==-1 || last+c<i))
        {
            last = i;
            v.pb(i);
        }
    }
    int sz = v.size();
    //for(int i=0;i<sz;i++) cout<<"G: "<<v[i]<<endl;
    if(sz>k) return 0;
    else
    {
        vector<int> ans;
        int u = v[sz-1]+1;
        int t = n;
        int flag = 0;
        while(t>=u)
        {
            if(s[t]=='o') {flag = 1;v[sz-1]=t;break;}
            t--;
        }
        if(!flag) ans.pb(t);
        for(int i=sz-2;i>-1;i--)
        {
            int t = v[i+1]-c-1;
            int u = v[i]+1;
            int flag = 0;
            while(t>=u)
            {
                if(s[t]=='o') {flag = 1;v[i]=t;break;}
                t--;
            }
            if(!flag) ans.pb(t);
        }
        for(int i=ans.size()-1;i>=0;i--) cout<<ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

ll dist[310][310];

int main(){
	int n; cin >> n;
	ll sum = 0;
	for( int i = 0; i < n; ++i ){
		for( int j = 0; j < n; ++j ){
			cin >> dist[i][j];
			sum += dist[i][j];
		}
	}
	sum /= 2;
	set<int> s;
	for( int k = 0; k < n; ++k ){
		for( int i = 0; i < n; ++i ){
			for( int j = 0; j < n; ++j ){
				if( dist[i][j] > dist[i][k]+dist[k][j] ){
					cout << -1 << endl;
					return 0;
				}
				if( dist[i][j] == dist[i][k]+dist[k][j] && i != j && j != k && k != i ){
					int a = i, b = j;
					if( a > b ) swap(a, b);
					s.insert(1000*a+b);
				}
			}
		}
	}
	for( auto x : s ){
		int a = x/1000, b = x%1000;
		sum -= dist[a][b];
	}
	cout << sum << endl;
}

Measured memory_bytes: 3072
#pragma GCC optimize("Ofast",3,"inline")
#include <cstdio>
#define N 2005
#define rep(i,a,b) for(i=a;i<b;++i)
using namespace std;
int n,m,Q;
char mp[N][N];
int l[N][N];
int u[N][N];
int dp[N][N];
int e1[N][N];
int e2[N][N];
int i,j;
inline void Init()
{
	scanf("%d %d %d\n",&n,&m,&Q);
	rep(i,1,n+1)
		scanf("%s",mp[i]+1);
	rep(i,1,n+1)
		rep(j,1,m+1)
			dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]+(mp[i][j]=='1');
	rep(i,1,n+1)
	{
		rep(j,1,m+1)
		{
			l[i][j]=l[i][j-1];
			if(mp[i][j]=='1' && mp[i][j-1]=='1')++l[i][j];
		}
	}
	rep(i,1,n+1)
		rep(j,1,m+1)
			l[i][j]+=l[i-1][j];
	rep(i,1,n+1)
	{
		rep(j,1,m+1)
		{
			u[i][j]=u[i-1][j];
			if(mp[i][j]=='1' && mp[i-1][j]=='1')++u[i][j];
		}
	}
	rep(i,1,n+1)
		rep(j,1,m+1)
			u[i][j]+=u[i][j-1];
	rep(i,1,n+1)
	{
		rep(j,1,m+1)
		{
			e1[i][j]=e1[i][j-1];
			if(mp[i][j]=='1' && mp[i][j-1]=='1')e1[i][j]++;
		}
	}
	rep(i,1,n+1)
		rep(j,1,m+1)
			e1[i][j]+=e1[i-1][j];
	rep(i,1,n+1)
	{
		rep(j,1,m+1)
		{
			e2[i][j]=e2[i-1][j];
			if(mp[i][j]=='1' && mp[i-1][j]=='1')e2[i][j]++;
		}
	}
	rep(i,1,n+1)
		rep(j,1,m+1)
			e2[i][j]+=e2[i][j-1];
/*	rep(i,1,n+1)
	{
		rep(j,1,m+1)
		{
			printf("<%d,%d>",e1[i][j],e2[i][j]);
        }
        puts("");
	}*/
}
inline void Solve()
{
	int x1,y1,x2,y2;
	int point_count;
	int edge_count;
	while(Q--)
	{
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		point_count=dp[x2][y2]-dp[x1-1][y2]-dp[x2][y1-1]+dp[x1-1][y1-1];
		edge_count=0;
		edge_count+=l[x2][y2]-l[x1-1][y2]-l[x2][y1-1]+l[x1-1][y1-1];
		edge_count+=u[x2][y2]-u[x1-1][y2]-u[x2][y1-1]+u[x1-1][y1-1];
		//int more=e1[x2][y1]-e1[x1-1][y1]+e2[x1][y2]-e2[x1][y1-1];
		int more=0;
		more+=e1[x2][y1]-e1[x1-1][y1]-e1[x2][y1-1]+e1[x1-1][y1-1];
		more+=e2[x1][y2]-e2[x1][y1-1]-e2[x1-1][y2]+e2[x1-1][y1-1];
	//	printf("edge_count:%d\n",edge_count);
		/*rep(i,x1,x2+1)
			if(mp[i][y1]=='1' && mp[i][y1-1]=='1')--edge_count;
		rep(j,y1,y2+1)
			if(mp[x1][j]=='1' && mp[x1-1][j]=='1')--edge_count;*/
			edge_count-=more;
		printf("%d\n",point_count-edge_count);
	}
}
int main()
{
	Init();
	Solve();
	return 0;
}

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

using namespace std;

#define rep(loop, N) for (int loop = 0; loop < N; loop++)

struct Node {
	Node* parent = NULL;
	vector<Node*> child;
	long long value = 0;
};
struct Edge {
	int parent = 0;
	int child = 0;
	bool operator <(const Edge& right) const { return parent < right.parent; }
};
struct Tree {
	vector<Node> node;
	Tree(int, vector<Edge>);
};
Tree::Tree(int nodeNum, vector<Edge> edge) {
	node.resize(nodeNum);
	for (Edge& it : edge) {
		node[it.child].parent = &node[it.parent];
		node[it.parent].child.push_back(&node[it.child]);
	}
}

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
		else {
			break;
		}
	}
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}
long long gcd(long long num1, long long num2) {
	return num2 == 0 ? num1 : gcd(num2, num1 % num2);
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	long long m_module = 1000000007;
	vector<struct Memo> memo;
public:
	long long calculate(int, int);
	Combination1(int, long long);
};
long long Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, long long module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_Sheep_and_Wolves(void) {

	int S, W; cin >> S >> W;

	cout << (S <= W ? "unsafe" : "safe") << endl;
	return;
}

void B_Battle(void) {

	int A, B, C, D; cin >> A >> B >> C >> D;

	while (1) {
		C -= B;
		if (C <= 0) {
			cout << "Yes" << endl;
			return;
		}
		A -= D;
		if (A <= 0) {
			cout << "No" << endl;
			return;
		}
	}
}

int main(void) {

	cout << fixed << setprecision(15);

	//A_Sheep_and_Wolves();
	B_Battle();
	return 0;
}


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

int main(){
    int64_t N, K;
    cin >> N >> K;
    vector<int64_t> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    sort(A.begin(), A.end());

    const int64_t INF = 1e18;
    int64_t ok = INF, ng = -INF-1;
    while(ok-ng>1){
        int64_t m = (ok+ng)/2;
        int64_t num = 0;

        if(m < 0){
            int negL = 0, posR = 0;
            for(int i=0; i<N; i++){
                if(A[i] < 0){
                    while(negL < N && A[negL]*A[i] > m) negL++;
                    num += N-negL;
                }else if(A[i] == 0){
                    if(m >= 0) num += N;
                }else{
                    while(posR < N && A[posR]*A[i] <= m) posR++;
                    num += posR;
                }
            }
        }else{
            int negL = N, posR = N;
            for(int i=0; i<N; i++){
                if(A[i] < 0){
                    while(negL > 0 && A[negL-1]*A[i] <= m) negL--;
                    num += N-negL;
                }else if(A[i] == 0){
                    if(m >= 0) num += N;
                }else{
                    while(posR > 0 && A[posR-1]*A[i] > m) posR--;
                    num += posR;
                }
            }
        }

        for(int i=0; i<N; i++) if(A[i]*A[i] <= m) num--;
        num /= 2;
        (num >= K ? ok : ng) = m;
    }
    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(){
    int x, y;
    for(int i = 0; i < 10000; ++i){
        cin >> x;
        cin >> y;
        if(0 == x && 0 == y) { break; }
		if(x > y) { swap(x, y); }
        cout << x << " " << y << endl;
    }
    return 0;
}



Measured memory_bytes: 3076
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <climits>

using namespace std;

int main() {
	string s;
	int k;

	cin >> k;

	cin >> s;

	if (s.size() > k) {
		s = s.substr(0,k) + "...";
		cout << s << endl;
	}

	if (s.size() <= k) {
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 999999999

vector<string> split(string s,char ch){
    vector<string> ret;
    string tmp ="";
    rep(i,s.size()){
        if(s[i]==ch){
            ret.pb(tmp);
            tmp = "";
        }else tmp+=s[i];
    }
    if(tmp.size())ret.pb(tmp);
    return ret;
}

int main(){
    int n;
    cin>>n;
    rep(i,n){
        string s;
        cin>>s;
        vector<string> list = split(s,':');
        int h,m;
        h = stoi(list[0]);
        m = stoi(list[1]);

        int x,y;
        x = 60*m;
        y = 300*h+5*m;
        x%=3600;
        y%=3600;
        
        if( abs(x-y)<300 || abs(x-y)>3300 )cout<<"alert"<<endl;
        else if( 900<=abs(x-y) && abs(x-y)<=2700)cout<<"safe"<<endl;
        else cout<<"warning"<<endl;
    }
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    cin >> a;
    set<int> seen = {a[0]};
    map<int, int> profits;
    for(int i = 1; i < n; i++) {
        profits[a[i] - *seen.begin()]++;
        seen.insert(a[i]);
    }
    cout << profits.rbegin()->second << endl;
    return 0;
}


Measured memory_bytes: 9984
<?php
fscanf(STDIN, "%d %d", $N, $M);
$A = array_map('intval' , explode(" ", trim(fgets(STDIN))));
rsort($A);

while($M > 0) {
    $base = $A[0] / 2;
    foreach ($A as $k => $v) {
        if ($base <= $v) {
            if ($M > 0) {
                $A[$k] /= 2;
                $M--;
            } else {
                break;
            }
        }
    }
    rsort($A);
}

$ans = 0;
foreach ($A as $v) {
    $ans += intval($v);
}
echo $ans;


Measured memory_bytes: 16884
s = input()
t = input()
maxi = 0 
for i in range(len(s)):
    maxG = 0
    if len(s[i:len(t)+i]) >= len(t):
        for l, j in zip(s[i:len(t)+i], t):
            if l == j:
                maxG += 1
        maxi = max(maxi, maxG)
print(len(t)-maxi)


Measured memory_bytes: 9004
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    long long n;
    cin >> n;
    long long s;
    cin >> s;

    if(n == s){
        cout << n + 1 << endl;
        return 0;
    }

    int i = 2;
    for(; i < 1000000; i++){
        if((long long)i * i > n){
            break;
        }
        long long sum = 0;
        long long temp = n;
        while(temp > 0){
            sum += (temp % i);
            temp /= i;
        }
        if(sum == s){
            cout << i << endl;
            return 0;
        }
    }

    int upper = n / i;
    long long b = i;
    for(int j = upper; j >= 1; j--){
        long long r = n % b;
        long long sum = j + r;

        if(s <= sum && (sum - s) <= r && (sum - s) % j == 0){
            long long diff = (sum - s) / j;
            cout << b + diff << endl;
            return 0;
        }

        long long bPlus = r / j + 1;
        b += bPlus;
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  
  int sum=0;
  int n=0,i,j;
  int flag=0;
  int a[200][10];
  int b=0,c=0;
  scanf("%d", &n);

  for(i=0;i<n;i++){
    scanf("%d %d", &b,&c);
    for(j=0;j<2;j++){
      if(j == 0){
        a[i][j] = b;
      }else{
        a[i][j] = c;
      }
    }
  }

  for(i=0;i<n-2;i++){
    if(a[i][0] == a[i][1] && a[i+1][0] == a[i+1][1] && a[i+2][0] == a[i+2][1]){
      flag++;
    }
  }
  
  if(flag>=1){
    printf("Yes");
  }else{
    printf("No");
  }
  
 return 0; 
}

Measured memory_bytes: 1740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define MAX 10000000000
#define INF INT_MAX

pair<int, int> A[2000000];
int size;

void heapIncreaseKey(int i, pair<int, int> key){
  if(key.first < A[i].first)
    assert(false);
  A[i] = key;
  while(i > 1 && A[i/2].first < A[i].first){
    swap(A[i].first, A[i/2].first);
    i = i/2;
  }
}

void maxHeapInsert(pair<int, int> key){
  size++;
  A[size].first = -INF;
  heapIncreaseKey(size, key);
}
void maxHeapify(ll i){
  int l = i*2;
  int r = i*2+1;
  int largest;
  if(l <= size && A[l].first > A[i].first)
    largest = l;
  else
    largest = i;
  if(r <= size && A[r].first > A[largest].first)
    largest = r;
  if(largest != i){
    swap(A[i], A[largest]);
    maxHeapify(largest);
  }
}
P heapExtractMax(){
  if(size < 1){
    assert(false);
  }
  pair<int, int> maxv = A[1];
  A[1] = A[size];
  size--;
  maxHeapify(1);
  return maxv;
}

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

  int n; cin >> n;

  vector< vector< P > > f(n);
  for(int i = 0; i < n; i++){
    int u, k; cin >> u >> k;
    for(int j = 0; j < k; j++){
      int v, c; cin >> v >> c;
      f[u].push_back(make_pair(v, c));
    }
  }

  //priority_queue< P, vector<P>, greater<P> > que;
  vector<ll> d(n, MAX);
  d[0] = 0;
  //que.push(make_pair(0, 0));
  maxHeapInsert(make_pair(0, 0));

  while(size != 0){
    P q = heapExtractMax();
    if(q.first > d[q.second]) continue;
    
    for(int i = 0; i < f[q.second].size(); i++){
      if(d[ f[q.second][i].first ] > d[q.second] + f[q.second][i].second){
        d[ f[q.second][i].first ] = d[q.second] + f[q.second][i].second;
        maxHeapInsert(make_pair(-d[ f[q.second][i].first ], f[q.second][i].first));
      }
    }
  }

  for(int i = 0; i < n; i++){
    cout << i << " " << d[i] << endl;
  }

  return 0;
}

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

#define ll long long
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define pii pair<int, int>

using namespace std;

int solve();

#define TASK ""

int main()
{
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // DEBUG
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}

vector<pii> a;
vector<int> b;

bool cmp(pii a, pii b)
{
    return (a.X > b.X || (a.X == b.X && a.Y < b.Y));
}

int solve()
{
    int n, h;
    int cnt = 0;
    cin >> n >> h;
    for (int i = 0; i < n; i++)
    {
        int x, y;
        cin >> x >> y;
        a.pb(mp(x, y));
    }
    sort(a.begin(), a.end(), cmp);
    for (int i = 1; i < n; i++)
    {
        if (a[i].Y > a[0].X)
        {
            b.pb(a[i].Y);
        }
    }
    sort(b.rbegin(), b.rend()); int l = 0;
    while(h > 0 && l < (int)b.size())
    {
        h -= b[l];
        cnt++;
        l++;
    }
    if (h <= 0)
    {
        cout << cnt << endl;
        return 0;
    }
    h -= a[0].Y;
    cnt++;
    if (h <= 0)
    {
        cout << cnt << endl;
        return 0;
    }
    cnt += ceil((double)h / (double)a[0].X);
    cout << cnt << endl;
    return 0;
}


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

int main(void){
    ll n;
    cin >> n;

    ll a[n], b[n], c[n];
    rep(i, n){
        cin >> a[i];
    }
    rep(i, n){
        cin >> b[i];
    }
    rep(i, n){
        cin >> c[i];
    }

    sort(a, a+n);
    sort(b, b+n);
    sort(c, c+n);

    ll ans = 0;
    rep(i, n){
        ll count_a = 0, count_c = 0;
        count_a = lower_bound(a, a + n, b[i]) - a;
        count_c = c + n - upper_bound(c, c + n, b[i]);
        ans += count_a * count_c;
    }

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


Measured memory_bytes: 2560
#include<stdio.h>

int max(int a, int b){
  return a > b ? a : b;
}

int min(int a, int b){
  return a < b ? a : b;
}

int main(){
  int N, K;
  scanf("%d %d ", &N, &K);
  int white[2 * K + 1][2 * K + 1];
  int black[2 * K + 1][2 * K + 1];
  for(int x = 0; x <= 2 * K; x++){
    for(int y = 0; y <= 2 * K; y++){
      white[x][y] = 0;
      black[x][y] = 0;
    }
  }
  
  for(int i = 0; i < N; i++){
    int x, y;
    char c;
    scanf("%d %d %c ", &x, &y, &c);
    if(c == 'W') white[x % (2 * K) + 1][y % (2 * K) + 1]++;
    else black[x % (2 * K) + 1][y % (2 * K) + 1]++;
  }
  
  for(int y = 0; y <= 2 * K; y++){
    for(int x = 1; x <= 2 * K; x++){
      white[x][y] += white[x - 1][y];
      black[x][y] += black[x - 1][y];
    }
  }
  
  for(int x = 0; x <= 2 * K; x++){
    for(int y = 1; y <= 2 * K; y++){
      white[x][y] += white[x][y - 1];
      black[x][y] += black[x][y - 1];
    }
  }
  
  int w[4][4];
  int b[4][4];
  
  int count = 0;
  for(int x = 0; x <= 2 * K; x++){
    for(int y = 0; y <= 2 * K; y++){
      int cnt = 0;
      
      for(int i = 0; i < 4; i++){
        for(int j = 0; j < 4; j++){
          int xi = min(max(x - K + i * K, 0), 2 * K);
          int yj = min(max(y - K + j * K, 0), 2 * K);
          w[i][j] = white[xi][yj];
          b[i][j] = black[xi][yj];
        }
      }
      
      for(int i = 0; i < 4; i++){
        for(int j = 0; j < 4; j++){
          if((i + j) & 1){
            if(i < 3 && j < 3)
              cnt += 2 * w[i][j] - 2 * b[i][j];
            else
              cnt += w[i][j] - b[i][j];
          }else{
            if(i < 3 && j < 3)
              cnt += - 2 * w[i][j] + 2 * b[i][j];
            else if(i == 3 && j == 3)
              cnt += b[i][j];
            else
              cnt += -w[i][j] + b[i][j];
          }
        }
      }
      count = max(cnt, count);
    }
  }
  
  printf("%d\n", count);
  
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  priority_queue <int> pq;
  for (int i = 0; i < 2*n; i++) {
    int a;
    cin >> a;
    pq.push(a);
  }
  int ans = 0;
  for (int i = 0; i < 2*n; i++) {
    if (i%2 == 1) {
      ans += pq.top();
    }
    pq.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
t=list(input())
for i in range(len(t)):
    if t[i]=="?":
        if len(t)==1:
            print("D")
            sys.exit()
        else:
            if i==0:
                if t[1]=="D":
                    t[0]="P"
                else:
                    t[0]="D"
            elif i==len(t)-1:
                t[i]="D"
            else:
                if t[i-1]=="P":
                    t[i]="D"
                elif t[i+1]=="D":
                    t[i]="P"
                elif t[i+1]=="?":
                    t[i]="P"
                    t[i+1]="D"
                else:
                    t[i]="D"
print("".join(t))

Measured memory_bytes: 10892
main()
{
 int a, b, c;
 int i;
 int n = 0;

 scanf("%d%d%d", &a, &b, &c);
 
 for(i = a; i <= b; i++){
  if(c % i == 0)n = n++;
 }
 printf("%d\n", n);

 return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
#include <unordered_set>

#define _CRT_SECURE_NO_WARNINGS

#define FOR(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

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

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

string s;
vs vec = { "dream","dreamer","erase","eraser" };

bool flag = false;
void solve(int k) {
	if (k == s.size()) flag = true;
	REP(i, 4) {
		if (s.substr(k, vec[i].size()) == vec[i]) {
			solve(k + vec[i].size());
		}
	}
}

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

	cin >> s;
	solve(0);

	cout << (flag ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 2128
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    s = input()
    t = input()
    import string

    l = string.ascii_lowercase

    for i in l:
        trial = set()
        for k,j in enumerate(s):
            if i == j:
                trial.add(t[k])
                if len(trial) > 1:
                    print("No")
                    exit()
        trial = set()
        for k,j in enumerate(t):
            if i == j:
                trial.add(s[k])
                if len(trial) > 1:
                    print("No")
                    exit()

    print("Yes")



if __name__=="__main__":
    main()


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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;

void solve() {
	int n;
	cin >> n;
	vector<vector<pair<int, int>>> a(n);
	for (int i = 0; i < n; i++) {
		int m;
		cin >> m;
		for (int j = 0; j < m; j++) {
			int x, y;
			cin >> x >> y;
			x--;
			a[i].pb({ x, y });
		}
	}

	int ans = 0;
	for (int mask = 0; mask < (1 << n); mask++) {
		int cnt = 0;
		bool good = true;
		for (int i = 0; i < n; i++) {
			if ((mask >> i) & 1) {
				for (auto& p : a[i]) {
					if (p.second != ((mask >> p.first) & 1)) good = false;
				}
				cnt++;
			}
		}
		if (good) ans = max(ans, cnt);
	}
	cout << ans;
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
  ll n, tmp;
  vector<ll> a;

  cin >> n;
  for (ll i = 0; i < n; i++) {
    cin >> tmp;
    a.push_back(tmp);
  }
  
  ll cnt = 0;
  for (ll i = 0; i < n; i++) {
    if (a[i] == cnt + 1) {
      cnt++;
    }
  }

  if (cnt == 0) {
    cout << -1 << endl;
  } else {
    cout << n - cnt << endl;
  }
}


Measured memory_bytes: 3444
n = int(input())
s = dict()

cnt = 0
for _ in range(n):
    si = input()
    if si not in s.keys():
        s[si] = 1
    else:
        s[si] += 1

    cnt = max(cnt, s[si])

for k in sorted(s):
    if s[k] == cnt:
        print(k)

Measured memory_bytes: 35408
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    map<string,int>mp;
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    mp[s] = a;
    mp[t] = b;
    string f;
    cin >> f;
    mp[f]--;
    cout << mp[s] << " " << mp[t] << endl;
}


Measured memory_bytes: 256
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100;

int n;
int a[MAXN];

void run() {
	scanf("%d",&n); REP(i,n) scanf("%d",&a[i]);
	int ret=0;
	for(int l=0,r=l;l<n;l=r) {
		while(r<n&&a[l]==a[r]) ++r;
		int cnt=r-l;
		ret+=cnt/2;
	}
	printf("%d\n",ret);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const lli inf = 1e18;

lli dfs(int node, vector<int> &used, vector<lli> score, vector<vector<lli> > &adj){
	lli res = inf;
	for(int i: used){
		res = min(res, adj[i][node]);
	}
	if(res == 0) return 0;
	
	score.push_back(res);
	for(int i=0; i<(int)used.size(); i++){
		score[i] = min(score[i], adj[used[i]][node]);
		res += score[i];
	}
	
	used.push_back(node);
	for(int i=node+1; i<(int)adj.size(); i++){
		res = max(res, dfs(i, used, score, adj));
	}
	used.pop_back();
	return res;
}

lli solve(vector<vector<lli> > &adj){
	int n = adj.size();
	vector<int> used(1);
	vector<lli> score(1);
	lli res = 0;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			if(adj[i][j] == 0) continue;
			used[0] = i;
			score[0] = adj[i][j];
			res = max(res, dfs(j, used, score, adj));
		}
	}
	return res;
}

int main(){
	int n,m;
	cin >> n >> m;
	vector<vector<lli> > adj(n, vector<lli>(n, 0));
	for(int i=0; i<m; i++){
		int a,b,c;
		cin >> a >> b >> c;
		a--; b--;
		adj[a][b] = adj[b][a] = c;
	}
	cout << solve(adj) << endl;
	return 0;
}


Measured memory_bytes: 3216
#include <stdio.h>
#include <string.h>
 
int main(void) {
  int x[5];
  for (int i = 0; i < 5; i++) {
    scanf("%d", &x[i]);
  }
  for (int i = 0; i < 5; i++) {
    if (x[i] == 0) {
      printf("%d\n", i + 1);
    }
  }
  return 0;
}

Measured memory_bytes: 1700
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
    char str[10000];

    while (scanf("%s", str) != EOF){
        int cnt_JOI = 0, cnt_IOI = 0;
        for (int i = 0; i < strlen(str); i++){
            if (str[i] == 'J'){
                if (str[i + 1] == 'O' && str[i + 2] == 'I'){
                    cnt_JOI++;
                }
            }
            else if (str[i] == 'I'){
                if (str[i + 1] == 'O' && str[i + 2] == 'I'){
                    cnt_IOI++;
                }
            }
        }
        printf("%d\n", cnt_JOI);
        printf("%d\n", cnt_IOI);
    }

    return (0);
}

Measured memory_bytes: 980
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define mp make_pair
using namespace std;

int dp[3][100005];

int main() {

    int N;
    cin >> N;
    vector<int> a(N), b(N), c(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i] >> c[i];
    }

    dp[0][0] = a[0];
    dp[1][0] = b[0];
    dp[2][0] = c[0];
    for (int i = 1; i < N; i++) {
        dp[0][i] = a[i] + max(dp[1][i - 1], dp[2][i - 1]);
        dp[1][i] = b[i] + max(dp[0][i - 1], dp[2][i - 1]);
        dp[2][i] = c[i] + max(dp[0][i - 1], dp[1][i - 1]);
    }
    cout << max(max(dp[0][N - 1], dp[1][N - 1]), dp[2][N - 1]) << endl;

    return 0;
}

Measured memory_bytes: 2560
N = int(input())
t = []
x = []
y = []
x.append(0)
y.append(0)
t.append(0)
for i in range(N):
    a = list(map(int,input().split()))
    t.append(a[0])
    x.append(a[1])
    y.append(a[2])

flag = True
for i in range(1,N+1):
    a = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])
    T = t[i] - t[i-1]
    if T < a:
        flag = False
        break
    b = T -a
    if b % 2 == 0:
        continue
    else:
        flag = False
        break

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 11828
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //ATTENTION: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/
int A, B;
/**********************************/

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

    if(A+B<=9) cout << A+B << endl;
    else cout << "error" << endl;
}


Measured memory_bytes: 256
fn main() {
    let n = readln();
    let v: Vec<(i32, i32, i32)> = readlns(n-1);
    for i in 0..n {
        let mut cur = 0;
        for &(c, s, f) in &v[i..n-1] {
            cur = max(s, (cur + f-1) / f * f) + c;
        }
        println!("{}", cur);
    }
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashSet;

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n { vs.push(readln()); }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(String, bool, f32, f64, isize, i8, i16, i32, i64, usize, u8, u16, u32, u64);
impl<T> FromLn for Vec<T> where T: FromLn {
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


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


#define vt vector
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
#define ll long long
#define ld long double
#define ar array
#define inf() ifstream cin("d.txt")
#define onf() ofstream cout("test.txt")
#define mod 1000000007
#define pb push_back
#define endl cout<<"\n";
#define prt1(a) cout<<a<<" "
#define prt2(a,b) cout<<a<<" "<<b<<" "
#define prt3(a,b,c) cout<<a<<" "<<b<<" "<<c<<" "
#define in(a) cin>>a
#define inn(a,b) cin>>a>>b
#define innn(a,b,c) cin>>a>>b>>c 
#define rep(i,st,end) for(int i=st;i<end;i++)
#define repv(i,st,end) for(int i=st;i>=end;i--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define TEST ll tc;cin>>tc;while(tc--)
#define EACH(x, a) for (auto& x: a)

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {
    cin >> x;
}
void read(double& d) {
    string t;
    read(t);
    d=stod(t);
}
void read(long double& d) {
    string t;
    read(t);
    d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
    read(h);
    read(t...);
}
template<class A> void read(vt<A>& x) {
    EACH(a, x)
        read(a);
}
template<class A, size_t S> void read(array<A, S>& x) {
    EACH(a, x)
        read(a);
}
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a <<"\n";
    err(++it, args...);
}


void solve()
{
    ll n;
    read(n);
    vt<ll>a(n),b(n);
    rep(i,0,n)
    {  
        ll x,y;
        read(x,y) ;
        a[i] = (x+y);
        b[i] = (x-y) ;    
    }
    sort(all(a));
    sort(all(b));

    ll ans= 0 ;
    cout<<max({a[n-1]-a[0], b[n-1]-b[0]});

   
   


}

 int main()
 {
    fio;
    ll k = 1;
    ll tc = 1;
    //cin>>tc;
    while(tc--){
       // cout<<"Case #"<<k<<": ";k++;
        solve();
        endl;
    }
    
 }




Measured memory_bytes: 6352
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int a,b;
    while(cin>>a>>b,a+b){
        vi v(a);rep(i,a)cin>>v[i];
        sort(all(v));
        int now=1;
        int ans=0;
        for(int i=a-1;i>=0;i--){
            if(now!=b)ans+=v[i];
            else{
                now=1;continue;
            }
            now++;
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3168
def main():
    high, width = map(int, input().split())
    data = [list(map(int, input().split())) for i in range(10)]
    inf = 10 ** 10
    kyori = [inf for i in range(10)]
    kyori[1] = 0

    itta = set()
    itta.add(1)
    while len(itta) < 10:
        now_kyori = inf
        ind = -1

        for ele_now in itta:
            for ele_next in range(10):
                if ele_now == ele_next or ele_next in itta:
                    continue
                length = kyori[ele_now] + data[ele_next][ele_now]
                if length < now_kyori:
                    now_kyori = length
                    ind = ele_next
        itta.add(ind)
        kyori[ind] = now_kyori


    ans = 0
    for i in range(high):
        get_data = list(map(int, input().split()))
        for ele in get_data:
            if ele == -1 or ele == 1:
                continue
            ans += kyori[ele]

    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 40556
import java.util.Scanner;

//Treasure Hunt II
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==-1)break;
			double x = 1;
			double y = 0;
			for(int i=2;i<=n;i++){
				double d = Math.sqrt(x*x+y*y);
				double dx = -y/d;
				double dy = x/d;
				x+=dx;
				y+=dy;
			}
			System.out.printf("%.2f\n%.2f\n", x, y);
		}
	}
}

Measured memory_bytes: 12000
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    string s;
    cin >> s;
    if( s == "SUN" ) cout << 7;
    if( s == "MON" ) cout << 6;
    if( s == "TUE" ) cout << 5;
    if( s == "WED" ) cout << 4;
    if( s == "THU" ) cout << 3;
    if( s == "FRI" ) cout << 2;
    if( s == "SAT" ) cout << 1;
    cout << endl;
    return 0;
}



Measured memory_bytes: 256